togglepeopletag.php 7.9 KB

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