searchsub.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. // This file is part of GNU social - https://www.gnu.org/software/social
  3. //
  4. // GNU social is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Affero General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // GNU social is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Affero General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Affero General Public License
  15. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  16. defined('GNUSOCIAL') || die();
  17. /**
  18. * Form for subscribing to a user
  19. *
  20. * @category Plugin
  21. * @package SearchSubPlugin
  22. * @author Brion Vibber <brion@status.net>
  23. * @author Evan Prodromou <evan@status.net>
  24. * @author Sarven Capadisli <csarven@status.net>
  25. * @copyright 2011-2019 Free Software Foundation, Inc http://www.fsf.org
  26. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  27. *
  28. * @see UnsubscribeForm
  29. */
  30. class SearchSubForm extends Form
  31. {
  32. /**
  33. * Name of search to subscribe to
  34. */
  35. public $search = '';
  36. /**
  37. * Constructor
  38. *
  39. * @param Action $out output channel (usually HTMLOutputter)
  40. * @param string $search name of search to subscribe to
  41. */
  42. public function __construct($out = null, $search = null)
  43. {
  44. parent::__construct($out);
  45. $this->search = $search;
  46. }
  47. /**
  48. * ID of the form
  49. *
  50. * @return int ID of the form
  51. */
  52. public function id()
  53. {
  54. return 'search-subscribe-' . $this->search;
  55. }
  56. /**
  57. * class of the form
  58. *
  59. * @return string of the form class
  60. */
  61. public function formClass()
  62. {
  63. // class to match existing styles...
  64. return 'form_user_subscribe ajax';
  65. }
  66. /**
  67. * Action of the form
  68. *
  69. * @return string URL of the action
  70. */
  71. public function action()
  72. {
  73. return common_local_url('searchsub', array('search' => $this->search));
  74. }
  75. /**
  76. * Legend of the Form
  77. *
  78. * @return void
  79. * @throws Exception
  80. */
  81. public function formLegend()
  82. {
  83. // TRANS: Form legend.
  84. $this->out->element('legend', null, _m('Subscribe to this search'));
  85. }
  86. /**
  87. * Data elements of the form
  88. *
  89. * @return void
  90. */
  91. public function formData()
  92. {
  93. $this->out->hidden(
  94. 'subscribeto-' . $this->search,
  95. $this->search,
  96. 'subscribeto'
  97. );
  98. }
  99. /**
  100. * Action elements
  101. *
  102. * @return void
  103. * @throws Exception
  104. */
  105. public function formActions()
  106. {
  107. $this->out->submit(
  108. 'submit',
  109. // TRANS: Button text for subscribing to a search.
  110. _m('BUTTON', 'Subscribe'),
  111. 'submit',
  112. null,
  113. // TRANS: Button title for subscribing to a search.
  114. _m('Subscribe to this search.')
  115. );
  116. }
  117. }