tagprofileform.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. protected $target = null;
  46. /**
  47. * Constructor
  48. *
  49. * @param Action $action Action we're being embedded into
  50. * @param array $options Array of optional parameters
  51. * 'user' a user instead of current
  52. * 'content' notice content
  53. * 'inreplyto' ID of notice to reply to
  54. * 'lat' Latitude
  55. * 'lon' Longitude
  56. * 'location_id' ID of location
  57. * 'location_ns' Namespace of location
  58. */
  59. function __construct(Action $action, Profile $target)
  60. {
  61. parent::__construct($action);
  62. $this->target = $target;
  63. }
  64. /**
  65. * ID of the form
  66. *
  67. * @return string ID of the form
  68. */
  69. function id()
  70. {
  71. return 'form_tagprofile_'.$target->id;
  72. }
  73. /**
  74. * Class of the form
  75. *
  76. * @return string class of the form
  77. */
  78. function formClass()
  79. {
  80. return 'form_tagprofile form_settings';
  81. }
  82. /**
  83. * Action of the form
  84. *
  85. * @return string URL of the action
  86. */
  87. function action()
  88. {
  89. return common_local_url('tagprofile', array('id' => $this->target->id));
  90. }
  91. /**
  92. * Legend of the Form
  93. *
  94. * @return void
  95. */
  96. function formLegend()
  97. {
  98. // TRANS: Form legend for notice form.
  99. $this->out->element('legend', null, sprintf(_m('ADDTOLIST', 'List %s'), $this->target->getNickname()));
  100. }
  101. /**
  102. * Data elements
  103. *
  104. * @return void
  105. */
  106. function formData()
  107. {
  108. if (Event::handle('StartShowTagProfileFormData', array($this))) {
  109. $this->hidden('token', common_session_token());
  110. $this->hidden('id', $this->target->id);
  111. $this->elementStart('ul', 'form_data');
  112. $this->elementStart('li');
  113. $tags = Profile_tag::getTagsArray($this->out->getScoped()->id, $this->target->id, $this->out->getScoped()->id);
  114. // TRANS: Field label on list form.
  115. $this->input('tags', _m('LABEL','Lists'),
  116. ($this->arg('tags')) ? $this->arg('tags') : implode(' ', $tags),
  117. // TRANS: Field title on list form.
  118. _('Lists for this user (letters, numbers, -, ., and _), comma- or space- separated.'));
  119. $this->elementEnd('li');
  120. $this->elementEnd('ul');
  121. Event::handle('EndShowTagProfileFormData', array($this));
  122. }
  123. }
  124. function formActions()
  125. {
  126. // TRANS: Button text to save lists.
  127. $this->out->submit('save', _m('BUTTON', 'Save'));
  128. }
  129. }