peopletageditform.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * Form for editing a peopletag
  6. *
  7. * PHP version 5
  8. *
  9. * LICENCE: This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. * @category Form
  23. * @package StatusNet
  24. * @author Shashi Gowda <connect2shashi@gmail.com>
  25. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  26. * @link http://status.net/
  27. */
  28. if (!defined('STATUSNET') && !defined('LACONICA')) {
  29. exit(1);
  30. }
  31. require_once INSTALLDIR . '/lib/util/form.php';
  32. require_once INSTALLDIR . '/lib/profile/togglepeopletag.php';
  33. /**
  34. * Form for editing a peopletag
  35. *
  36. * @category Form
  37. * @package StatusNet
  38. * @author Shashi Gowda <connect2shashi@gmail.com>
  39. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  40. * @link http://status.net/
  41. *
  42. * @see GroupEditForm
  43. */
  44. class PeopletagEditForm extends Form
  45. {
  46. public $widgetOpts;
  47. public $scoped;
  48. /**
  49. * peopletag to edit
  50. */
  51. var $peopletag = null;
  52. var $tagger = null;
  53. /**
  54. * Constructor
  55. *
  56. * @param Action $out output channel
  57. * @param User_group $group group to join
  58. */
  59. function __construct($out=null, Profile_list $peopletag=null)
  60. {
  61. parent::__construct($out);
  62. $this->peopletag = $peopletag;
  63. $this->tagger = Profile::getKV('id', $peopletag->tagger);
  64. }
  65. /**
  66. * ID of the form
  67. *
  68. * @return string ID of the form
  69. */
  70. function id()
  71. {
  72. return 'form_peopletag_edit-' . $this->peopletag->id;
  73. }
  74. /**
  75. * class of the form
  76. *
  77. * @return string of the form class
  78. */
  79. function formClass()
  80. {
  81. return 'form_settings';
  82. }
  83. /**
  84. * Action of the form
  85. *
  86. * @return string URL of the action
  87. */
  88. function action()
  89. {
  90. return common_local_url('editpeopletag',
  91. array('tagger' => $this->tagger->nickname, 'tag' => $this->peopletag->tag));
  92. }
  93. /**
  94. * Name of the form
  95. *
  96. * @return void
  97. */
  98. function formLegend()
  99. {
  100. // TRANS: Form legend for list edit form.
  101. // TRANS: %s is a list.
  102. $this->out->element('legend', null, sprintf(_('Edit list %s'), $this->peopletag->tag));
  103. }
  104. /**
  105. * Data elements of the form
  106. *
  107. * @return void
  108. */
  109. function formData()
  110. {
  111. $id = $this->peopletag->id;
  112. $tag = $this->peopletag->tag;
  113. $description = $this->peopletag->description;
  114. $private = $this->peopletag->private;
  115. $this->out->elementStart('ul', 'form_data');
  116. $this->out->elementStart('li');
  117. $this->out->hidden('id', $id);
  118. // TRANS: Field label for list.
  119. $this->out->input('tag', _m('LABEL','List'),
  120. ($this->out->arg('tag')) ? $this->out->arg('tag') : $tag,
  121. // TRANS: Field title for list.
  122. _('Change the list (letters, numbers, -, ., and _ are allowed).'));
  123. $this->out->elementEnd('li');
  124. $this->out->elementStart('li');
  125. $desclimit = Profile_list::maxDescription();
  126. if ($desclimit == 0) {
  127. // TRANS: Field title for description of list.
  128. $descinstr = _('Describe the list or topic.');
  129. } else {
  130. // TRANS: Field title for description of list.
  131. // TRANS: %d is the maximum number of characters for the description.
  132. $descinstr = sprintf(_m('Describe the list or topic in %d character.',
  133. 'Describe the list or topic in %d characters.',
  134. $desclimit),
  135. $desclimit);
  136. }
  137. // TRANS: Field label for description of list.
  138. $this->out->textarea('description', _('Description'),
  139. ($this->out->arg('description')) ? $this->out->arg('description') : $description,
  140. $descinstr);
  141. // TRANS: Checkbox label to mark a list private.
  142. $this->out->checkbox('private', _('Private'), $private);
  143. $this->out->elementEnd('li');
  144. $this->out->elementEnd('ul');
  145. }
  146. /**
  147. * Action elements
  148. *
  149. * @return void
  150. */
  151. function formActions()
  152. {
  153. // TRANS: Button text to save a list.
  154. $this->out->submit('submit', _('Save'));
  155. $this->out->submit('form_action-yes',
  156. // TRANS: Button text to delete a list.
  157. _m('BUTTON','Delete'),
  158. 'submit',
  159. 'delete',
  160. // TRANS: Button title to delete a list.
  161. _('Delete this list.'));
  162. }
  163. function showProfileList()
  164. {
  165. $tagged = $this->peopletag->getTagged();
  166. // TRANS: Header in list edit form.
  167. $this->out->element('h2', null, _('Add or remove people'));
  168. $this->out->elementStart('div', 'profile_search_wrap');
  169. // TRANS: Header in list edit form.
  170. $this->out->element('h3', null, _m('HEADER','Search'));
  171. $search = new SearchProfileForm($this->out, $this->peopletag);
  172. $search->show();
  173. $this->out->element('ul', array('id' => 'profile_search_results', 'class' => 'empty'));
  174. $this->out->elementEnd('div');
  175. $this->out->elementStart('ul', 'profile-lister');
  176. while ($tagged->fetch()) {
  177. $this->out->elementStart('li', 'entity_removable_profile');
  178. $this->showProfileItem($tagged);
  179. $this->out->elementStart('span', 'entity_actions');
  180. $untag = new UntagButton($this->out, $tagged, $this->peopletag);
  181. $untag->show();
  182. $this->out->elementEnd('span');
  183. $this->out->elementEnd('li');
  184. }
  185. $this->out->elementEnd('ul');
  186. }
  187. function showProfileItem($profile)
  188. {
  189. $item = new TaggedProfileItem($this->out, $profile);
  190. $item->show();
  191. }
  192. }