3 * StatusNet, the distributed open-source microblogging tool
5 * Widget to show a list of peopletags
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.
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.
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/>.
24 * @author Shashi Gowda <connect2shashi@gmail.com>
25 * @copyright 2008-2009 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://status.net/
30 if (!defined('STATUSNET') && !defined('LACONICA')) {
34 require_once INSTALLDIR.'/lib/widget.php';
36 define('PEOPLETAGS_PER_PAGE', 20);
39 * Widget to show a list of peopletags
43 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
44 * @link http://status.net/
46 class PeopletagList extends Widget
48 /** Current peopletag, peopletag query. */
49 var $peopletag = null;
53 function __construct($peopletag, $action=null)
55 parent::__construct($action);
57 $this->peopletag = $peopletag;
62 $this->user = common_current_user();
68 $this->out->elementStart('ul', 'peopletags xoxo hfeed');
72 while ($this->peopletag->fetch()) {
74 if($cnt > PEOPLETAGS_PER_PAGE) {
77 $this->showPeopletag();
80 $this->out->elementEnd('ul');
85 function showPeopletag()
87 $ptag = new PeopletagListItem($this->peopletag, $this->user, $this->out);
92 class PeopletagListItem extends Widget
94 var $peopletag = null;
101 * Also initializes the owner attribute.
103 * @param Notice $notice The notice we'll display
105 function __construct($peopletag, $current, $out=null)
107 parent::__construct($out);
108 $this->peopletag = $peopletag;
109 $this->current = $current;
110 $this->profile = Profile::getKV('id', $this->peopletag->tagger);
114 * recipe function for displaying a single peopletag.
116 * This uses all the other methods to correctly display a notice. Override
117 * it or one of the others to fine-tune the output.
123 return $this->peopletag->homeUrl();
128 if (empty($this->peopletag)) {
129 common_log(LOG_WARNING, "Trying to show missing peopletag; skipping.");
133 if (Event::handle('StartShowPeopletagItem', array($this))) {
135 $this->showPeopletag();
138 Event::handle('EndShowPeopletagItem', array($this));
144 $mode = ($this->peopletag->private) ? 'private' : 'public';
145 $this->out->elementStart('li', array('class' => 'h-entry peopletag mode-' . $mode,
146 'id' => 'peopletag-' . $this->peopletag->id));
151 $this->out->elementEnd('li');
154 function showPeopletag()
156 $this->showCreator();
158 $this->showPrivacy();
159 $this->showUpdated();
160 $this->showActions();
161 $this->showDescription();
166 $this->out->elementStart('div', 'entry-summary entity_statistics');
167 $this->out->elementStart('span', 'tagged-count');
168 $this->out->element('a',
169 array('href' => common_local_url('peopletagged',
170 array('tagger' => $this->profile->nickname,
171 'tag' => $this->peopletag->tag))),
172 // TRANS: Link description for link to list of users tagged with a tag (so part of a list).
174 $this->out->raw($this->peopletag->taggedCount());
175 $this->out->elementEnd('span');
177 $this->out->elementStart('span', 'subscriber-count');
178 $this->out->element('a',
179 array('href' => common_local_url('peopletagsubscribers',
180 array('tagger' => $this->profile->nickname,
181 'tag' => $this->peopletag->tag))),
182 // TRANS: Link description for link to list of users subscribed to a tag.
184 $this->out->raw($this->peopletag->subscriberCount());
185 $this->out->elementEnd('span');
186 $this->out->elementEnd('div');
189 function showOwnerOptions()
191 $this->out->elementStart('li', 'entity_edit');
192 $this->out->element('a', array('href' =>
193 common_local_url('editpeopletag', array('tagger' => $this->profile->nickname,
194 'tag' => $this->peopletag->tag)),
195 // TRANS: Title for link to edit list settings.
196 'title' => _('Edit list settings.')),
197 // TRANS: Text for link to edit list settings.
199 $this->out->elementEnd('li');
202 function showSubscribeForm()
204 $this->out->elementStart('li');
206 if (Event::handle('StartSubscribePeopletagForm', array($this->out, $this->peopletag))) {
207 if ($this->current) {
208 if ($this->peopletag->hasSubscriber($this->current->id)) {
209 $form = new UnsubscribePeopletagForm($this->out, $this->peopletag);
212 $form = new SubscribePeopletagForm($this->out, $this->peopletag);
216 Event::handle('EndSubscribePeopletagForm', array($this->out, $this->peopletag));
219 $this->out->elementEnd('li');
222 function showCreator()
225 $attrs['href'] = $this->profile->profileurl;
226 $attrs['class'] = 'h-card p-author nickname p-name';
227 $attrs['rel'] = 'contact';
228 $attrs['title'] = $this->profile->getFancyName();
230 $this->out->elementStart('a', $attrs);
231 $this->showAvatar($this->profile);
232 $this->out->text($this->profile->getNickname());
233 $this->out->elementEnd('a');
236 function showUpdated()
238 if (!empty($this->peopletag->modified)) {
239 $this->out->element('abbr',
240 array('title' => common_date_w3dtf($this->peopletag->modified),
241 'class' => 'updated'),
242 common_date_string($this->peopletag->modified));
246 function showPrivacy()
248 if ($this->peopletag->private) {
249 $this->out->elementStart('a',
250 array('href' => common_local_url('peopletagsbyuser',
251 array('nickname' => $this->profile->nickname, 'private' => 1))));
252 // TRANS: Privacy mode text in list list item for private list.
253 $this->out->element('span', 'privacy_mode', _m('MODE','Private'));
254 $this->out->elementEnd('a');
260 $this->out->elementStart('span', 'entry-title tag');
261 $this->out->element('a',
262 array('rel' => 'bookmark',
263 'href' => $this->url()),
264 htmlspecialchars($this->peopletag->tag));
265 $this->out->elementEnd('span');
268 function showActions()
270 $this->out->elementStart('div', 'entity_actions');
271 $this->out->elementStart('ul');
273 if (!$this->peopletag->private) {
274 $this->showSubscribeForm();
277 if (!empty($this->current) && $this->profile->id == $this->current->id) {
278 $this->showOwnerOptions();
280 $this->out->elementEnd('ul');
281 $this->out->elementEnd('div');
284 function showDescription()
286 $this->out->element('div', 'e-content description', $this->peopletag->description);