]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/togglepeopletag.php
Merge remote-tracking branch 'mainline/1.0.x' into people_tags_rebase
[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
47 class SearchProfileForm extends Form
48 {
49     var $peopletag;
50
51     function __construct($out, Profile_list $peopletag)
52     {
53         parent::__construct($out);
54         $this->peopletag = $peopletag;
55     }
56
57     /**
58      * ID of the form
59      *
60      * @return string ID of the form
61      */
62
63     function id()
64     {
65         return 'form_peopletag-add-' . $this->peopletag->id;
66     }
67
68     /**
69      * class of the form
70      *
71      * @return string of the form class
72      */
73
74     function formClass()
75     {
76         return 'form_peopletag_edit_user_search';
77     }
78
79     /**
80      * Action of the form
81      *
82      * @return string URL of the action
83      */
84
85     function action()
86     {
87         return common_local_url('profilecompletion');
88     }
89
90     /**
91      * Name of the form
92      *
93      * @return void
94      */
95
96     function formLegend()
97     {
98         $this->out->element('legend', null, sprintf(_('Search and list people')));
99     }
100
101     /**
102      * Data elements of the form
103      *
104      * @return void
105      */
106
107     function formData()
108     {
109         $fields = array('fulltext'    => 'Everything',
110                         'nickname'    => 'Nickname',
111                         'fullname'    => 'Fullname',
112                         'description' => 'Description',
113                         'location'    => 'Location',
114                         'uri'         => 'Uri (Remote users)');
115         
116
117         $this->out->hidden('peopletag_id', $this->peopletag->id);
118         $this->out->input('q', null);
119         $this->out->dropdown('field', _('Search in'), $fields,
120                         _('Choose a field to search'), false, 'fulltext');
121     }
122
123     /**
124      * Action elements
125      *
126      * @return void
127      */
128
129     function formActions()
130     {
131         $this->out->submit('submit', _('Search'));
132     }
133 }
134
135 class UntagButton extends Form
136 {
137     var $profile;
138     var $peopletag;
139
140     function __construct($out, Profile $profile, Profile_list $peopletag)
141     {
142         parent::__construct($out);
143         $this->profile = $profile;
144         $this->peopletag = $peopletag;
145     }
146
147     /**
148      * ID of the form
149      *
150      * @return string ID of the form
151      */
152
153     function id()
154     {
155         return 'form_peopletag-' . $this->peopletag->id . '-remove-' . $this->profile->id;
156     }
157
158     /**
159      * class of the form
160      *
161      * @return string of the form class
162      */
163
164     function formClass()
165     {
166         return 'form_user_remove_peopletag';
167     }
168
169     /**
170      * Action of the form
171      *
172      * @return string URL of the action
173      */
174
175     function action()
176     {
177         return common_local_url('removepeopletag');
178     }
179
180     /**
181      * Name of the form
182      *
183      * @return void
184      */
185
186     function formLegend()
187     {
188         $this->out->element('legend', null, sprintf(_('Untag %s as %s'),
189             $this->profile->nickname, $this->peopletag->tag));
190     }
191
192     /**
193      * Data elements of the form
194      *
195      * @return void
196      */
197
198     function formData()
199     {
200         $this->out->hidden('peopletag_id', $this->peopletag->id);
201         $this->out->hidden('tagged', $this->profile->id);
202     }
203
204     /**
205      * Action elements
206      *
207      * @return void
208      */
209
210     function formActions()
211     {
212         $this->out->submit('submit', _('Remove'));
213     }
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
235     function id()
236     {
237         return 'form_peopletag-' . $this->peopletag->id . '-add-' . $this->profile->id;
238     }
239
240     /**
241      * class of the form
242      *
243      * @return string of the form class
244      */
245
246     function formClass()
247     {
248         return 'form_user_add_peopletag';
249     }
250
251     /**
252      * Action of the form
253      *
254      * @return string URL of the action
255      */
256
257     function action()
258     {
259         return common_local_url('addpeopletag');
260     }
261
262     /**
263      * Name of the form
264      *
265      * @return void
266      */
267
268     function formLegend()
269     {
270         $this->out->element('legend', null, sprintf(_('Tag %s as %s'),
271             $this->profile->nickname, $this->peopletag->tag));
272     }
273
274     /**
275      * Data elements of the form
276      *
277      * @return void
278      */
279
280     function formData()
281     {
282         UntagButton::formData();
283     }
284
285     /**
286      * Action elements
287      *
288      * @return void
289      */
290
291     function formActions()
292     {
293         $this->out->submit('submit', _('Add'));
294     }
295 }
296
297 class TaggedProfileItem extends Widget
298 {
299     var $profile=null;
300
301     function __construct($out=null, $profile)
302     {
303         parent::__construct($out);
304         $this->profile = $profile;
305     }
306
307     function show()
308     {
309         $this->out->elementStart('a', array('class' => 'url',
310                                             'href' => $this->profile->profileurl,
311                                             'title' => $this->profile->getBestName()));
312         $avatar = $this->profile->getAvatar(AVATAR_MINI_SIZE);
313         $this->out->element('img', array('src' => (($avatar) ? $avatar->displayUrl() :
314                                          Avatar::defaultImage(AVATAR_MINI_SIZE)),
315                                          'width' => AVATAR_MINI_SIZE,
316                                          'height' => AVATAR_MINI_SIZE,
317                                          'class' => 'avatar photo',
318                                          'alt' => $this->profile->getBestName()));
319         $this->out->element('span', 'fn nickname', $this->profile->nickname);
320         $this->out->elementEnd('a');
321     }
322 }