3 * StatusNet, the distributed open-source microblogging tool
5 * Form for editing a peopletag
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.
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.
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/>.
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/
29 if (!defined('STATUSNET') && !defined('LACONICA')) {
33 require_once INSTALLDIR.'/lib/form.php';
34 require_once INSTALLDIR.'/lib/togglepeopletag.php';
37 * Form for editing a peopletag
41 * @author Shashi Gowda <connect2shashi@gmail.com>
42 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
43 * @link http://status.net/
48 class PeopletagEditForm extends Form
54 var $peopletag = null;
60 * @param Action $out output channel
61 * @param User_group $group group to join
64 function __construct($out=null, Profile_list $peopletag=null)
66 parent::__construct($out);
68 $this->peopletag = $peopletag;
69 $this->tagger = Profile::staticGet('id', $peopletag->tagger);
75 * @return string ID of the form
80 return 'form_peopletag_edit-' . $this->peopletag->id;
86 * @return string of the form class
91 return 'form_settings';
97 * @return string URL of the action
102 return common_local_url('editpeopletag',
103 array('tagger' => $this->tagger->nickname, 'tag' => $this->peopletag->tag));
112 function formLegend()
114 $this->out->element('legend', null, sprintf(_('Edit peopletag %s'), $this->peopletag->tag));
118 * Data elements of the form
125 $id = $this->peopletag->id;
126 $tag = $this->peopletag->tag;
127 $description = $this->peopletag->description;
128 $private = $this->peopletag->private;
130 $this->out->elementStart('ul', 'form_data');
132 $this->out->elementStart('li');
133 $this->out->hidden('id', $id);
134 $this->out->input('tag', _('Tag'),
135 ($this->out->arg('tag')) ? $this->out->arg('tag') : $tag,
136 _('Change the tag (letters, numbers, -, ., and _ are allowed)'));
137 $this->out->elementEnd('li');
139 $this->out->elementStart('li');
140 $desclimit = Profile_list::maxDescription();
141 if ($desclimit == 0) {
142 $descinstr = _('Describe the people tag or topic');
144 $descinstr = sprintf(_('Describe the people tag or topic in %d characters'), $desclimit);
146 $this->out->textarea('description', _('Description'),
147 ($this->out->arg('description')) ? $this->out->arg('description') : $description,
149 $this->out->checkbox('private', _('Private'), $private);
150 $this->out->elementEnd('li');
151 $this->out->elementEnd('ul');
160 function formActions()
162 $this->out->submit('submit', _('Save'));
163 $this->out->submit('form_action-yes',
164 _m('BUTTON','Delete'),
167 _('Delete this people tag'));
170 function showProfileList()
172 $tagged = $this->peopletag->getTagged();
173 $this->out->element('h2', null, 'Add or remove people');
175 $this->out->elementStart('div', 'profile_search_wrap');
176 $this->out->element('h3', null, 'Add user');
177 $search = new SearchProfileForm($this->out, $this->peopletag);
179 $this->out->element('ul', array('id' => 'profile_search_results', 'class' => 'empty'));
180 $this->out->elementEnd('div');
182 $this->out->elementStart('ul', 'profile-lister');
183 while ($tagged->fetch()) {
184 $this->out->elementStart('li', 'entity_removable_profile');
185 $this->showProfileItem($tagged);
186 $this->out->elementStart('span', 'entity_actions');
187 $untag = new UntagButton($this->out, $tagged, $this->peopletag);
189 $this->out->elementEnd('span');
190 $this->out->elementEnd('li');
192 $this->out->elementEnd('ul');
195 function showProfileItem($profile)
197 $item = new TaggedProfileItem($this->out, $profile);