peopletageditform.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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/form.php';
  32. require_once INSTALLDIR.'/lib/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. /**
  47. * peopletag to edit
  48. */
  49. var $peopletag = null;
  50. var $tagger = null;
  51. /**
  52. * Constructor
  53. *
  54. * @param Action $out output channel
  55. * @param User_group $group group to join
  56. */
  57. function __construct($out=null, Profile_list $peopletag=null)
  58. {
  59. parent::__construct($out);
  60. $this->peopletag = $peopletag;
  61. $this->tagger = Profile::getKV('id', $peopletag->tagger);
  62. }
  63. /**
  64. * ID of the form
  65. *
  66. * @return string ID of the form
  67. */
  68. function id()
  69. {
  70. return 'form_peopletag_edit-' . $this->peopletag->id;
  71. }
  72. /**
  73. * class of the form
  74. *
  75. * @return string of the form class
  76. */
  77. function formClass()
  78. {
  79. return 'form_settings';
  80. }
  81. /**
  82. * Action of the form
  83. *
  84. * @return string URL of the action
  85. */
  86. function action()
  87. {
  88. return common_local_url('editpeopletag',
  89. array('tagger' => $this->tagger->nickname, 'tag' => $this->peopletag->tag));
  90. }
  91. /**
  92. * Name of the form
  93. *
  94. * @return void
  95. */
  96. function formLegend()
  97. {
  98. // TRANS: Form legend for list edit form.
  99. // TRANS: %s is a list.
  100. $this->out->element('legend', null, sprintf(_('Edit list %s'), $this->peopletag->tag));
  101. }
  102. /**
  103. * Data elements of the form
  104. *
  105. * @return void
  106. */
  107. function formData()
  108. {
  109. $id = $this->peopletag->id;
  110. $tag = $this->peopletag->tag;
  111. $description = $this->peopletag->description;
  112. $private = $this->peopletag->private;
  113. $this->out->elementStart('ul', 'form_data');
  114. $this->out->elementStart('li');
  115. $this->out->hidden('id', $id);
  116. // TRANS: Field label for list.
  117. $this->out->input('tag', _m('LABEL','List'),
  118. ($this->out->arg('tag')) ? $this->out->arg('tag') : $tag,
  119. // TRANS: Field title for list.
  120. _('Change the list (letters, numbers, -, ., and _ are allowed).'));
  121. $this->out->elementEnd('li');
  122. $this->out->elementStart('li');
  123. $desclimit = Profile_list::maxDescription();
  124. if ($desclimit == 0) {
  125. // TRANS: Field title for description of list.
  126. $descinstr = _('Describe the list or topic.');
  127. } else {
  128. // TRANS: Field title for description of list.
  129. // TRANS: %d is the maximum number of characters for the description.
  130. $descinstr = sprintf(_m('Describe the list or topic in %d character.',
  131. 'Describe the list or topic in %d characters.',
  132. $desclimit),
  133. $desclimit);
  134. }
  135. // TRANS: Field label for description of list.
  136. $this->out->textarea('description', _('Description'),
  137. ($this->out->arg('description')) ? $this->out->arg('description') : $description,
  138. $descinstr);
  139. // TRANS: Checkbox label to mark a list private.
  140. $this->out->checkbox('private', _('Private'), $private);
  141. $this->out->elementEnd('li');
  142. $this->out->elementEnd('ul');
  143. }
  144. /**
  145. * Action elements
  146. *
  147. * @return void
  148. */
  149. function formActions()
  150. {
  151. // TRANS: Button text to save a list.
  152. $this->out->submit('submit', _('Save'));
  153. $this->out->submit('form_action-yes',
  154. // TRANS: Button text to delete a list.
  155. _m('BUTTON','Delete'),
  156. 'submit',
  157. 'delete',
  158. // TRANS: Button title to delete a list.
  159. _('Delete this list.'));
  160. }
  161. function showProfileList()
  162. {
  163. $tagged = $this->peopletag->getTagged();
  164. // TRANS: Header in list edit form.
  165. $this->out->element('h2', null, _('Add or remove people'));
  166. $this->out->elementStart('div', 'profile_search_wrap');
  167. // TRANS: Header in list edit form.
  168. $this->out->element('h3', null, _m('HEADER','Search'));
  169. $search = new SearchProfileForm($this->out, $this->peopletag);
  170. $search->show();
  171. $this->out->element('ul', array('id' => 'profile_search_results', 'class' => 'empty'));
  172. $this->out->elementEnd('div');
  173. $this->out->elementStart('ul', 'profile-lister');
  174. while ($tagged->fetch()) {
  175. $this->out->elementStart('li', 'entity_removable_profile');
  176. $this->showProfileItem($tagged);
  177. $this->out->elementStart('span', 'entity_actions');
  178. $untag = new UntagButton($this->out, $tagged, $this->peopletag);
  179. $untag->show();
  180. $this->out->elementEnd('span');
  181. $this->out->elementEnd('li');
  182. }
  183. $this->out->elementEnd('ul');
  184. }
  185. function showProfileItem($profile)
  186. {
  187. $item = new TaggedProfileItem($this->out, $profile);
  188. $item->show();
  189. }
  190. }