]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/togglepeopletag.php
Merge branch 'master' of gitorious.org:social/mainline
[quix0rs-gnu-social.git] / lib / togglepeopletag.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
35 /**
36  * Form for editing a peopletag
37  *
38  * @category Form
39  * @package  StatusNet
40  * @author   Shashi Gowda <connect2shashi@gmail.com>
41  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
42  * @link     http://status.net/
43  *
44  * @see      GroupEditForm
45  */
46 class SearchProfileForm extends Form
47 {
48     var $peopletag;
49
50     function __construct($out, Profile_list $peopletag)
51     {
52         parent::__construct($out);
53         $this->peopletag = $peopletag;
54     }
55
56     /**
57      * ID of the form
58      *
59      * @return string ID of the form
60      */
61     function id()
62     {
63         return 'form_peopletag-add-' . $this->peopletag->id;
64     }
65
66     /**
67      * class of the form
68      *
69      * @return string of the form class
70      */
71     function formClass()
72     {
73         return 'form_peopletag_edit_user_search';
74     }
75
76     /**
77      * Action of the form
78      *
79      * @return string URL of the action
80      */
81     function action()
82     {
83         return common_local_url('profilecompletion');
84     }
85
86     /**
87      * Name of the form
88      *
89      * @return void
90      */
91     function formLegend()
92     {
93         // TRANS: Form legend.
94         $this->out->element('legend', null, sprintf(_('Search and list people')));
95     }
96
97     /**
98      * Data elements of the form
99      *
100      * @return void
101      */
102     function formData()
103     {
104         // TRANS: Dropdown option for searching in profiles.
105         $fields = array('fulltext'    => _('Everything'),
106                         // TRANS: Dropdown option for searching in profiles.
107                         'nickname'    => _('Nickname'),
108                         // TRANS: Dropdown option for searching in profiles.
109                         'fullname'    => _('Fullname'),
110                         // TRANS: Dropdown option for searching in profiles.
111                         'description' => _('Description'),
112                         // TRANS: Dropdown option for searching in profiles.
113                         'location'    => _('Location'),
114                         // TRANS: Dropdown option for searching in profiles.
115                         'uri'         => _('URI (Remote users)'));
116
117
118         $this->out->hidden('peopletag_id', $this->peopletag->id);
119         $this->out->input('q', null);
120         // TRANS: Dropdown field label.
121         $this->out->dropdown('field', _m('LABEL','Search in'), $fields,
122                         // TRANS: Dropdown field title.
123                         _('Choose a field to search.'), false, 'fulltext');
124     }
125
126     /**
127      * Action elements
128      *
129      * @return void
130      */
131     function formActions()
132     {
133         // TRANS: Button text to search profiles.
134         $this->out->submit('submit', _m('BUTTON','Search'));
135     }
136 }
137
138 class UntagButton extends Form
139 {
140     var $profile;
141     var $peopletag;
142
143     function __construct($out, Profile $profile, Profile_list $peopletag)
144     {
145         parent::__construct($out);
146         $this->profile = $profile;
147         $this->peopletag = $peopletag;
148     }
149
150     /**
151      * ID of the form
152      *
153      * @return string ID of the form
154      */
155     function id()
156     {
157         return 'form_peopletag-' . $this->peopletag->id . '-remove-' . $this->profile->id;
158     }
159
160     /**
161      * class of the form
162      *
163      * @return string of the form class
164      */
165     function formClass()
166     {
167         return 'form_user_remove_peopletag';
168     }
169
170     /**
171      * Action of the form
172      *
173      * @return string URL of the action
174      */
175
176     function action()
177     {
178         return common_local_url('removepeopletag');
179     }
180
181     /**
182      * Name of the form
183      *
184      * @return void
185      */
186     function formLegend()
187     {
188         // TRANS: Form legend.
189         // TRANS: %1$s is a nickname, $2$s is a list.
190         $this->out->element('legend', null, sprintf(_('Remove %1$s from list %2$s'),
191             $this->profile->nickname, $this->peopletag->tag));
192     }
193
194     /**
195      * Data elements of the form
196      *
197      * @return void
198      */
199     function formData()
200     {
201         $this->out->hidden('peopletag_id', $this->peopletag->id);
202         $this->out->hidden('tagged', $this->profile->id);
203     }
204
205     /**
206      * Action elements
207      *
208      * @return void
209      */
210     function formActions()
211     {
212         // TRANS: Button text to untag a profile.
213         $this->out->submit('submit', _m('BUTTON','Remove'));
214     }
215 }
216
217 class TagButton extends Form
218 {
219     var $profile;
220     var $peopletag;
221
222     function __construct($out, Profile $profile, Profile_list $peopletag)
223     {
224         parent::__construct($out);
225         $this->profile = $profile;
226         $this->peopletag = $peopletag;
227     }
228
229     /**
230      * ID of the form
231      *
232      * @return string ID of the form
233      */
234     function id()
235     {
236         return 'form_peopletag-' . $this->peopletag->id . '-add-' . $this->profile->id;
237     }
238
239     /**
240      * class of the form
241      *
242      * @return string of the form class
243      */
244     function formClass()
245     {
246         return 'form_user_add_peopletag';
247     }
248
249     /**
250      * Action of the form
251      *
252      * @return string URL of the action
253      */
254     function action()
255     {
256         return common_local_url('addpeopletag');
257     }
258
259     /**
260      * Name of the form
261      *
262      * @return void
263      */
264     function formLegend()
265     {
266         // TRANS: Legend on form to add a profile to a list.
267         // TRANS: %1$s is a nickname, %2$s is a list.
268         $this->out->element('legend', null, sprintf(_('Add %1$s to list %2$s'),
269             $this->profile->nickname, $this->peopletag->tag));
270     }
271
272     /**
273      * Data elements of the form
274      *
275      * @return void
276      */
277     function formData()
278     {
279         UntagButton::formData();
280     }
281
282     /**
283      * Action elements
284      *
285      * @return void
286      */
287     function formActions()
288     {
289         // TRANS: Button text to tag a profile.
290         $this->out->submit('submit', _m('BUTTON','Add'));
291     }
292 }
293
294 class TaggedProfileItem extends Widget
295 {
296     var $profile=null;
297
298     function __construct($out=null, $profile)
299     {
300         parent::__construct($out);
301         $this->profile = $profile;
302     }
303
304     function show()
305     {
306         $this->out->elementStart('a', array('class' => 'url',
307                                             'href' => $this->profile->profileurl,
308                                             'title' => $this->profile->getBestName()));
309         $avatarUrl = $this->profile->avatarUrl(AVATAR_MINI_SIZE);
310         $this->out->element('img', array('src' => $avatarUrl,
311                                          'width' => AVATAR_MINI_SIZE,
312                                          'height' => AVATAR_MINI_SIZE,
313                                          'class' => 'avatar photo',
314                                          'alt' => $this->profile->getBestName()));
315         $this->out->element('span', 'fn nickname', $this->profile->nickname);
316         $this->out->elementEnd('a');
317     }
318 }