]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/peopletageditform.php
Merge branch 'master' into social-master
[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 class PeopletagEditForm extends Form
48 {
49     /**
50      * peopletag to edit
51      */
52
53     var $peopletag = null;
54     var $tagger    = null;
55
56     /**
57      * Constructor
58      *
59      * @param Action     $out   output channel
60      * @param User_group $group group to join
61      */
62     function __construct($out=null, Profile_list $peopletag=null)
63     {
64         parent::__construct($out);
65
66         $this->peopletag = $peopletag;
67         $this->tagger    = Profile::getKV('id', $peopletag->tagger);
68     }
69
70     /**
71      * ID of the form
72      *
73      * @return string ID of the form
74      */
75     function id()
76     {
77         return 'form_peopletag_edit-' . $this->peopletag->id;
78     }
79
80     /**
81      * class of the form
82      *
83      * @return string of the form class
84      */
85     function formClass()
86     {
87         return 'form_settings';
88     }
89
90     /**
91      * Action of the form
92      *
93      * @return string URL of the action
94      */
95     function action()
96     {
97         return common_local_url('editpeopletag',
98                 array('tagger' => $this->tagger->nickname, 'tag' => $this->peopletag->tag));
99     }
100
101     /**
102      * Name of the form
103      *
104      * @return void
105      */
106     function formLegend()
107     {
108         // TRANS: Form legend for list edit form.
109         // TRANS: %s is a list.
110         $this->out->element('legend', null, sprintf(_('Edit list %s'), $this->peopletag->tag));
111     }
112
113     /**
114      * Data elements of the form
115      *
116      * @return void
117      */
118     function formData()
119     {
120         $id = $this->peopletag->id;
121         $tag = $this->peopletag->tag;
122         $description = $this->peopletag->description;
123         $private = $this->peopletag->private;
124
125         $this->out->elementStart('ul', 'form_data');
126
127         $this->out->elementStart('li');
128         $this->out->hidden('id', $id);
129
130         // TRANS: Field label for list.
131         $this->out->input('tag', _m('LABEL','List'),
132                           ($this->out->arg('tag')) ? $this->out->arg('tag') : $tag,
133                           // TRANS: Field title for list.
134                           _('Change the list (letters, numbers, -, ., and _ are allowed).'));
135         $this->out->elementEnd('li');
136
137         $this->out->elementStart('li');
138         $desclimit = Profile_list::maxDescription();
139         if ($desclimit == 0) {
140             // TRANS: Field title for description of list.
141             $descinstr = _('Describe the list or topic.');
142         } else {
143             // TRANS: Field title for description of list.
144             // TRANS: %d is the maximum number of characters for the description.
145             $descinstr = sprintf(_m('Describe the list or topic in %d character.',
146                                     'Describe the list or topic in %d characters.',
147                                     $desclimit),
148                                  $desclimit);
149         }
150         // TRANS: Field label for description of list.
151         $this->out->textarea('description', _('Description'),
152                              ($this->out->arg('description')) ? $this->out->arg('description') : $description,
153                              $descinstr);
154         // TRANS: Checkbox label to mark a list private.
155         $this->out->checkbox('private', _('Private'), $private);
156         $this->out->elementEnd('li');
157         $this->out->elementEnd('ul');
158     }
159
160     /**
161      * Action elements
162      *
163      * @return void
164      */
165     function formActions()
166     {
167         // TRANS: Button text to save a list.
168         $this->out->submit('submit', _('Save'));
169         $this->out->submit('form_action-yes',
170                       // TRANS: Button text to delete a list.
171                       _m('BUTTON','Delete'),
172                       'submit',
173                       'delete',
174                       // TRANS: Button title to delete a list.
175                       _('Delete this list.'));
176     }
177
178     function showProfileList()
179     {
180         $tagged = $this->peopletag->getTagged();
181         // TRANS: Header in list edit form.
182         $this->out->element('h2', null, _('Add or remove people'));
183
184         $this->out->elementStart('div', 'profile_search_wrap');
185         // TRANS: Header in list edit form.
186         $this->out->element('h3', null, _m('HEADER','Search'));
187         $search = new SearchProfileForm($this->out, $this->peopletag);
188         $search->show();
189         $this->out->element('ul', array('id' => 'profile_search_results', 'class' => 'empty'));
190         $this->out->elementEnd('div');
191
192         $this->out->elementStart('ul', 'profile-lister');
193         while ($tagged->fetch()) {
194             $this->out->elementStart('li', 'entity_removable_profile');
195             $this->showProfileItem($tagged);
196             $this->out->elementStart('span', 'entity_actions');
197             $untag = new UntagButton($this->out, $tagged, $this->peopletag);
198             $untag->show();
199             $this->out->elementEnd('span');
200             $this->out->elementEnd('li');
201         }
202         $this->out->elementEnd('ul');
203     }
204
205     function showProfileItem($profile)
206     {
207         $item = new TaggedProfileItem($this->out, $profile);
208         $item->show();
209     }
210 }