togglepeopletag.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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. /**
  33. * Form for editing a peopletag
  34. *
  35. * @category Form
  36. * @package StatusNet
  37. * @author Shashi Gowda <connect2shashi@gmail.com>
  38. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  39. * @link http://status.net/
  40. *
  41. * @see GroupEditForm
  42. */
  43. class SearchProfileForm extends Form
  44. {
  45. var $peopletag;
  46. function __construct($out, Profile_list $peopletag)
  47. {
  48. parent::__construct($out);
  49. $this->peopletag = $peopletag;
  50. }
  51. /**
  52. * ID of the form
  53. *
  54. * @return string ID of the form
  55. */
  56. function id()
  57. {
  58. return 'form_peopletag-add-' . $this->peopletag->id;
  59. }
  60. /**
  61. * class of the form
  62. *
  63. * @return string of the form class
  64. */
  65. function formClass()
  66. {
  67. return 'form_peopletag_edit_user_search';
  68. }
  69. /**
  70. * Action of the form
  71. *
  72. * @return string URL of the action
  73. */
  74. function action()
  75. {
  76. return common_local_url('profilecompletion');
  77. }
  78. /**
  79. * Name of the form
  80. *
  81. * @return void
  82. */
  83. function formLegend()
  84. {
  85. // TRANS: Form legend.
  86. $this->out->element('legend', null, sprintf(_('Search and list people')));
  87. }
  88. /**
  89. * Data elements of the form
  90. *
  91. * @return void
  92. */
  93. function formData()
  94. {
  95. // TRANS: Dropdown option for searching in profiles.
  96. $fields = array('fulltext' => _('Everything'),
  97. // TRANS: Dropdown option for searching in profiles.
  98. 'nickname' => _('Nickname'),
  99. // TRANS: Dropdown option for searching in profiles.
  100. 'fullname' => _('Fullname'),
  101. // TRANS: Dropdown option for searching in profiles.
  102. 'description' => _('Description'),
  103. // TRANS: Dropdown option for searching in profiles.
  104. 'location' => _('Location'),
  105. // TRANS: Dropdown option for searching in profiles.
  106. 'uri' => _('URI (Remote users)'));
  107. $this->out->hidden('peopletag_id', $this->peopletag->id);
  108. $this->out->input('q', null);
  109. // TRANS: Dropdown field label.
  110. $this->out->dropdown('field', _m('LABEL','Search in'), $fields,
  111. // TRANS: Dropdown field title.
  112. _('Choose a field to search.'), false, 'fulltext');
  113. }
  114. /**
  115. * Action elements
  116. *
  117. * @return void
  118. */
  119. function formActions()
  120. {
  121. // TRANS: Button text to search profiles.
  122. $this->out->submit('submit', _m('BUTTON','Search'));
  123. }
  124. }
  125. class UntagButton extends Form
  126. {
  127. var $profile;
  128. var $peopletag;
  129. function __construct($out, Profile $profile, Profile_list $peopletag)
  130. {
  131. parent::__construct($out);
  132. $this->profile = $profile;
  133. $this->peopletag = $peopletag;
  134. }
  135. /**
  136. * ID of the form
  137. *
  138. * @return string ID of the form
  139. */
  140. function id()
  141. {
  142. return 'form_peopletag-' . $this->peopletag->id . '-remove-' . $this->profile->id;
  143. }
  144. /**
  145. * class of the form
  146. *
  147. * @return string of the form class
  148. */
  149. function formClass()
  150. {
  151. return 'form_user_remove_peopletag';
  152. }
  153. /**
  154. * Action of the form
  155. *
  156. * @return string URL of the action
  157. */
  158. function action()
  159. {
  160. return common_local_url('removepeopletag');
  161. }
  162. /**
  163. * Name of the form
  164. *
  165. * @return void
  166. */
  167. function formLegend()
  168. {
  169. // TRANS: Form legend.
  170. // TRANS: %1$s is a nickname, $2$s is a list.
  171. $this->out->element('legend', null, sprintf(_('Remove %1$s from list %2$s'),
  172. $this->profile->nickname, $this->peopletag->tag));
  173. }
  174. /**
  175. * Data elements of the form
  176. *
  177. * @return void
  178. */
  179. function formData()
  180. {
  181. $this->out->hidden('peopletag_id', $this->peopletag->id);
  182. $this->out->hidden('tagged', $this->profile->id);
  183. }
  184. /**
  185. * Action elements
  186. *
  187. * @return void
  188. */
  189. function formActions()
  190. {
  191. // TRANS: Button text to untag a profile.
  192. $this->out->submit('submit', _m('BUTTON','Remove'));
  193. }
  194. }
  195. class TagButton extends Form
  196. {
  197. var $profile;
  198. var $peopletag;
  199. function __construct($out, Profile $profile, Profile_list $peopletag)
  200. {
  201. parent::__construct($out);
  202. $this->profile = $profile;
  203. $this->peopletag = $peopletag;
  204. }
  205. /**
  206. * ID of the form
  207. *
  208. * @return string ID of the form
  209. */
  210. function id()
  211. {
  212. return 'form_peopletag-' . $this->peopletag->id . '-add-' . $this->profile->id;
  213. }
  214. /**
  215. * class of the form
  216. *
  217. * @return string of the form class
  218. */
  219. function formClass()
  220. {
  221. return 'form_user_add_peopletag';
  222. }
  223. /**
  224. * Action of the form
  225. *
  226. * @return string URL of the action
  227. */
  228. function action()
  229. {
  230. return common_local_url('addpeopletag');
  231. }
  232. /**
  233. * Name of the form
  234. *
  235. * @return void
  236. */
  237. function formLegend()
  238. {
  239. // TRANS: Legend on form to add a profile to a list.
  240. // TRANS: %1$s is a nickname, %2$s is a list.
  241. $this->out->element('legend', null, sprintf(_('Add %1$s to list %2$s'),
  242. $this->profile->nickname, $this->peopletag->tag));
  243. }
  244. /**
  245. * Data elements of the form
  246. *
  247. * @return void
  248. */
  249. function formData()
  250. {
  251. UntagButton::formData();
  252. }
  253. /**
  254. * Action elements
  255. *
  256. * @return void
  257. */
  258. function formActions()
  259. {
  260. // TRANS: Button text to tag a profile.
  261. $this->out->submit('submit', _m('BUTTON','Add'));
  262. }
  263. }
  264. class TaggedProfileItem extends Widget
  265. {
  266. var $profile=null;
  267. function __construct($out=null, $profile)
  268. {
  269. parent::__construct($out);
  270. $this->profile = $profile;
  271. }
  272. function show()
  273. {
  274. $this->out->elementStart('a', array('class' => 'url',
  275. 'href' => $this->profile->profileurl,
  276. 'title' => $this->profile->getBestName()));
  277. $avatarUrl = $this->profile->avatarUrl(AVATAR_MINI_SIZE);
  278. $this->out->element('img', array('src' => $avatarUrl,
  279. 'width' => AVATAR_MINI_SIZE,
  280. 'height' => AVATAR_MINI_SIZE,
  281. 'class' => 'avatar photo',
  282. 'alt' => $this->profile->getBestName()));
  283. $this->out->element('span', 'fn nickname', $this->profile->nickname);
  284. $this->out->elementEnd('a');
  285. }
  286. }