pollprefs.php 2.0 KB

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