pollprefs.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. if (!defined('GNUSOCIAL')) {
  3. exit(1);
  4. }
  5. class PollPrefsForm extends Form
  6. {
  7. public function __construct(Action $out, User_poll_prefs $prefs = null)
  8. {
  9. parent::__construct($out);
  10. $this->prefs = $prefs;
  11. }
  12. /**
  13. * Visible or invisible data elements
  14. *
  15. * Display the form fields that make up the data of the form.
  16. * Sub-classes should overload this to show their data.
  17. *
  18. * @return void
  19. */
  20. public function formData()
  21. {
  22. $this->elementStart('fieldset');
  23. $this->elementStart('ul', 'form_data');
  24. $this->elementStart('li');
  25. $this->checkbox(
  26. 'hide_responses',
  27. _('Do not deliver poll responses to my home timeline'),
  28. ($this->prefs instanceof User_poll_prefs && $this->prefs->hide_responses)
  29. );
  30. $this->elementEnd('li');
  31. $this->elementEnd('ul');
  32. $this->elementEnd('fieldset');
  33. }
  34. /**
  35. * Buttons for form actions
  36. *
  37. * Submit and cancel buttons (or whatever)
  38. * Sub-classes should overload this to show their own buttons.
  39. *
  40. * @return void
  41. */
  42. public function formActions()
  43. {
  44. $this->submit('submit', _('Save'));
  45. }
  46. /**
  47. * ID of the form
  48. *
  49. * Should be unique on the page. Sub-classes should overload this
  50. * to show their own IDs.
  51. *
  52. * @return int ID of the form
  53. */
  54. public function id()
  55. {
  56. return 'form_poll_prefs';
  57. }
  58. /**
  59. * Action of the form.
  60. *
  61. * URL to post to. Should be overloaded by subclasses to give
  62. * somewhere to post to.
  63. *
  64. * @return string URL to post to
  65. */
  66. public function action()
  67. {
  68. return common_local_url('pollsettings');
  69. }
  70. /**
  71. * Class of the form. May include space-separated list of multiple classes.
  72. *
  73. * @return string the form's class
  74. */
  75. public function formClass()
  76. {
  77. return 'form_settings';
  78. }
  79. }