]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/tagprofileform.php
Opps, PEAR sucks. Need to call find() before fetch() ... :-(
[quix0rs-gnu-social.git] / lib / tagprofileform.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * Form for tagging a profile with 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    Evan Prodromou <evan@status.net>
25  * @author    Sarven Capadisli <csarven@status.net>
26  * @copyright 2009 StatusNet, Inc.
27  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28  * @link      http://status.net/
29  */
30
31 if (!defined('GNUSOCIAL')) { exit(1); }
32
33 /**
34  * Form for tagging a profile with a peopletag
35  *
36  * @category Form
37  * @package  StatusNet
38  * @author   Evan Prodromou <evan@status.net>
39  * @author   Sarven Capadisli <csarven@status.net>
40  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
41  * @link     http://status.net/
42  *
43  * @see      HTMLOutputter
44  */
45 class TagProfileForm extends Form
46 {
47     protected $target = null;
48
49     /**
50      * Constructor
51      *
52      * @param Action $action  Action we're being embedded into
53      * @param array  $options Array of optional parameters
54      *                        'user' a user instead of current
55      *                        'content' notice content
56      *                        'inreplyto' ID of notice to reply to
57      *                        'lat' Latitude
58      *                        'lon' Longitude
59      *                        'location_id' ID of location
60      *                        'location_ns' Namespace of location
61      */
62     function __construct(Action $action, Profile $target)
63     {
64         parent::__construct($action);
65
66         $this->target = $target;
67     }
68
69     /**
70      * ID of the form
71      *
72      * @return string ID of the form
73      */
74
75     function id()
76     {
77         return 'form_tagprofile_'.$target->id;
78     }
79
80    /**
81      * Class of the form
82      *
83      * @return string class of the form
84      */
85
86     function formClass()
87     {
88         return 'form_tagprofile form_settings';
89     }
90
91     /**
92      * Action of the form
93      *
94      * @return string URL of the action
95      */
96
97     function action()
98     {
99         return common_local_url('tagprofile', array('id' => $this->target->id));
100     }
101
102     /**
103      * Legend of the Form
104      *
105      * @return void
106      */
107     function formLegend()
108     {
109         // TRANS: Form legend for notice form.
110         $this->out->element('legend', null, sprintf(_m('ADDTOLIST', 'List %s'), $this->target->getNickname()));
111
112     }
113
114     /**
115      * Data elements
116      *
117      * @return void
118      */
119     function formData()
120     {
121         if (Event::handle('StartShowTagProfileFormData', array($this))) {
122             $this->hidden('token', common_session_token());  
123             $this->hidden('id', $this->target->id);
124
125             $this->elementStart('ul', 'form_data');
126             $this->elementStart('li');
127
128             $tags = Profile_tag::getTagsArray($this->out->getScoped()->id, $this->target->id, $this->out->getScoped()->id);
129             // TRANS: Field label on list form.
130             $this->input('tags', _m('LABEL','Lists'),
131                          ($this->arg('tags')) ? $this->arg('tags') : implode(' ', $tags),
132                          // TRANS: Field title on list form.
133                          _('Lists for this user (letters, numbers, -, ., and _), comma- or space- separated.'));
134             $this->elementEnd('li');
135             $this->elementEnd('ul');
136             Event::handle('EndShowTagProfileFormData', array($this));
137         }
138     }
139
140     function formActions()
141     {
142         // TRANS: Button text to save lists.
143         $this->out->submit('save', _m('BUTTON', 'Save'));
144     }
145 }