]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/peopletageditform.php
Merge remote-tracking branch 'mainline/1.0.x' into people_tags_rebase
[quix0rs-gnu-social.git] / lib / peopletageditform.php
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
29 if (!defined('STATUSNET') && !defined('LACONICA')) {
30     exit(1);
31 }
32
33 require_once INSTALLDIR.'/lib/form.php';
34 require_once INSTALLDIR.'/lib/togglepeopletag.php';
35
36 /**
37  * Form for editing a peopletag
38  *
39  * @category Form
40  * @package  StatusNet
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/
44  *
45  * @see      GroupEditForm
46  */
47
48 class PeopletagEditForm extends Form
49 {
50     /**
51      * peopletag to edit
52      */
53
54     var $peopletag = null;
55     var $tagger    = null;
56
57     /**
58      * Constructor
59      *
60      * @param Action     $out   output channel
61      * @param User_group $group group to join
62      */
63
64     function __construct($out=null, Profile_list $peopletag=null)
65     {
66         parent::__construct($out);
67
68         $this->peopletag = $peopletag;
69         $this->tagger    = Profile::staticGet('id', $peopletag->tagger);
70     }
71
72     /**
73      * ID of the form
74      *
75      * @return string ID of the form
76      */
77
78     function id()
79     {
80         return 'form_peopletag_edit-' . $this->peopletag->id;
81     }
82
83     /**
84      * class of the form
85      *
86      * @return string of the form class
87      */
88
89     function formClass()
90     {
91         return 'form_settings';
92     }
93
94     /**
95      * Action of the form
96      *
97      * @return string URL of the action
98      */
99
100     function action()
101     {
102         return common_local_url('editpeopletag',
103                 array('tagger' => $this->tagger->nickname, 'tag' => $this->peopletag->tag));
104     }
105
106     /**
107      * Name of the form
108      *
109      * @return void
110      */
111
112     function formLegend()
113     {
114         $this->out->element('legend', null, sprintf(_('Edit peopletag %s'), $this->peopletag->tag));
115     }
116
117     /**
118      * Data elements of the form
119      *
120      * @return void
121      */
122
123     function formData()
124     {
125         $id = $this->peopletag->id;
126         $tag = $this->peopletag->tag;
127         $description = $this->peopletag->description;
128         $private = $this->peopletag->private;
129
130         $this->out->elementStart('ul', 'form_data');
131
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');
138
139         $this->out->elementStart('li');
140         $desclimit = Profile_list::maxDescription();
141         if ($desclimit == 0) {
142             $descinstr = _('Describe the people tag or topic');
143         } else {
144             $descinstr = sprintf(_('Describe the people tag or topic in %d characters'), $desclimit);
145         }
146         $this->out->textarea('description', _('Description'),
147                              ($this->out->arg('description')) ? $this->out->arg('description') : $description,
148                              $descinstr);
149         $this->out->checkbox('private', _('Private'), $private);
150         $this->out->elementEnd('li');
151         $this->out->elementEnd('ul');
152     }
153
154     /**
155      * Action elements
156      *
157      * @return void
158      */
159
160     function formActions()
161     {
162         $this->out->submit('submit', _('Save'));
163         $this->out->submit('form_action-yes',
164                       _m('BUTTON','Delete'),
165                       'submit',
166                       'delete',
167                       _('Delete this people tag'));
168     }
169
170     function showProfileList()
171     {
172         $tagged = $this->peopletag->getTagged();
173         $this->out->element('h2', null, 'Add or remove people');
174
175         $this->out->elementStart('div', 'profile_search_wrap');
176         $this->out->element('h3', null, _m('BUTTON', 'Search'));
177         $search = new SearchProfileForm($this->out, $this->peopletag);
178         $search->show();
179         $this->out->element('ul', array('id' => 'profile_search_results', 'class' => 'empty'));
180         $this->out->elementEnd('div');
181
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);
188             $untag->show();
189             $this->out->elementEnd('span');
190             $this->out->elementEnd('li');
191         }
192         $this->out->elementEnd('ul');
193     }
194
195     function showProfileItem($profile)
196     {
197         $item = new TaggedProfileItem($this->out, $profile);
198         $item->show();
199     }
200 }