tagprofileform.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <?php
  2. /**
  3. * StatusNet, the distributed open-source microblogging tool
  4. *
  5. * Form for tagging a profile with 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 Evan Prodromou <evan@status.net>
  25. * @author Sarven Capadisli <csarven@status.net>
  26. * @copyright 2009 StatusNet, Inc.
  27. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  28. * @link http://status.net/
  29. */
  30. if (!defined('GNUSOCIAL')) { exit(1); }
  31. /**
  32. * Form for tagging a profile with a peopletag
  33. *
  34. * @category Form
  35. * @package StatusNet
  36. * @author Evan Prodromou <evan@status.net>
  37. * @author Sarven Capadisli <csarven@status.net>
  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 HTMLOutputter
  42. */
  43. class TagProfileForm extends Form
  44. {
  45. public $widgetOpts;
  46. public $scoped;
  47. protected $target = null;
  48. /**
  49. * Constructor
  50. *
  51. * @param Action $action Action we're being embedded into
  52. * @param array $options Array of optional parameters
  53. * 'user' a user instead of current
  54. * 'content' notice content
  55. * 'inreplyto' ID of notice to reply to
  56. * 'lat' Latitude
  57. * 'lon' Longitude
  58. * 'location_id' ID of location
  59. * 'location_ns' Namespace of location
  60. */
  61. function __construct(Action $action, Profile $target)
  62. {
  63. parent::__construct($action);
  64. $this->target = $target;
  65. }
  66. /**
  67. * ID of the form
  68. *
  69. * @return string ID of the form
  70. */
  71. function id()
  72. {
  73. return 'form_tagprofile_'.$target->id;
  74. }
  75. /**
  76. * Class of the form
  77. *
  78. * @return string class of the form
  79. */
  80. function formClass()
  81. {
  82. return 'form_tagprofile form_settings';
  83. }
  84. /**
  85. * Action of the form
  86. *
  87. * @return string URL of the action
  88. */
  89. function action()
  90. {
  91. return common_local_url('tagprofile', array('id' => $this->target->id));
  92. }
  93. /**
  94. * Legend of the Form
  95. *
  96. * @return void
  97. */
  98. function formLegend()
  99. {
  100. // TRANS: Form legend for notice form.
  101. $this->out->element('legend', null, sprintf(_m('ADDTOLIST', 'List %s'), $this->target->getNickname()));
  102. }
  103. /**
  104. * Data elements
  105. *
  106. * @return void
  107. */
  108. function formData()
  109. {
  110. if (Event::handle('StartShowTagProfileFormData', array($this))) {
  111. $this->hidden('token', common_session_token());
  112. $this->hidden('id', $this->target->id);
  113. $this->elementStart('ul', 'form_data');
  114. $this->elementStart('li');
  115. $tags = Profile_tag::getTagsArray($this->out->getScoped()->id, $this->target->id, $this->out->getScoped()->id);
  116. // TRANS: Field label on list form.
  117. $this->input('tags', _m('LABEL','Lists'),
  118. ($this->arg('tags')) ? $this->arg('tags') : implode(' ', $tags),
  119. // TRANS: Field title on list form.
  120. _('Lists for this user (letters, numbers, -, ., and _), comma- or space- separated.'));
  121. $this->elementEnd('li');
  122. $this->elementEnd('ul');
  123. Event::handle('EndShowTagProfileFormData', array($this));
  124. }
  125. }
  126. function formActions()
  127. {
  128. // TRANS: Button text to save lists.
  129. $this->out->submit('save', _m('BUTTON', 'Save'));
  130. }
  131. }