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('GNUSOCIAL')) { exit(1); }
32 class PeopletagListItem extends Widget
34 var $peopletag = null;
41 * Also initializes the owner attribute.
43 * @param Notice $notice The notice we'll display
45 function __construct($peopletag, $current, $out=null)
47 parent::__construct($out);
48 $this->peopletag = $peopletag;
49 $this->current = $current;
50 $this->profile = Profile::getKV('id', $this->peopletag->tagger);
54 * recipe function for displaying a single peopletag.
56 * This uses all the other methods to correctly display a notice. Override
57 * it or one of the others to fine-tune the output.
63 return $this->peopletag->homeUrl();
68 if (empty($this->peopletag)) {
69 common_log(LOG_WARNING, "Trying to show missing peopletag; skipping.");
73 if (Event::handle('StartShowPeopletagItem', array($this))) {
75 $this->showPeopletag();
78 Event::handle('EndShowPeopletagItem', array($this));
84 $mode = ($this->peopletag->private) ? 'private' : 'public';
85 $this->out->elementStart('li', array('class' => 'h-entry peopletag mode-' . $mode,
86 'id' => 'peopletag-' . $this->peopletag->id));
91 $this->out->elementEnd('li');
94 function showPeopletag()
100 $this->showActions();
101 $this->showDescription();
106 $this->out->elementStart('div', 'entry-summary entity_statistics');
107 $this->out->elementStart('span', 'tagged-count');
108 $this->out->element('a',
109 array('href' => common_local_url('peopletagged',
110 array('tagger' => $this->profile->nickname,
111 'tag' => $this->peopletag->tag))),
112 // TRANS: Link description for link to list of users tagged with a tag (so part of a list).
114 $this->out->raw($this->peopletag->taggedCount());
115 $this->out->elementEnd('span');
117 $this->out->elementStart('span', 'subscriber-count');
118 $this->out->element('a',
119 array('href' => common_local_url('peopletagsubscribers',
120 array('tagger' => $this->profile->nickname,
121 'tag' => $this->peopletag->tag))),
122 // TRANS: Link description for link to list of users subscribed to a tag.
124 $this->out->raw($this->peopletag->subscriberCount());
125 $this->out->elementEnd('span');
126 $this->out->elementEnd('div');
129 function showOwnerOptions()
131 $this->out->elementStart('li', 'entity_edit');
132 $this->out->element('a', array('href' =>
133 common_local_url('editpeopletag', array('tagger' => $this->profile->nickname,
134 'tag' => $this->peopletag->tag)),
135 // TRANS: Title for link to edit list settings.
136 'title' => _('Edit list settings.')),
137 // TRANS: Text for link to edit list settings.
139 $this->out->elementEnd('li');
142 function showSubscribeForm()
144 $this->out->elementStart('li');
146 if (Event::handle('StartSubscribePeopletagForm', array($this->out, $this->peopletag))) {
147 if ($this->current) {
148 if ($this->peopletag->hasSubscriber($this->current->id)) {
149 $form = new UnsubscribePeopletagForm($this->out, $this->peopletag);
152 $form = new SubscribePeopletagForm($this->out, $this->peopletag);
156 Event::handle('EndSubscribePeopletagForm', array($this->out, $this->peopletag));
159 $this->out->elementEnd('li');
162 function showCreator()
165 $attrs['href'] = $this->profile->profileurl;
166 $attrs['class'] = 'h-card p-author nickname p-name';
167 $attrs['rel'] = 'contact';
168 $attrs['title'] = $this->profile->getFancyName();
170 $this->out->elementStart('a', $attrs);
171 $this->showAvatar($this->profile);
172 $this->out->text($this->profile->getNickname());
173 $this->out->elementEnd('a');
176 function showUpdated()
178 if (!empty($this->peopletag->modified)) {
179 $this->out->element('abbr',
180 array('title' => common_date_w3dtf($this->peopletag->modified),
181 'class' => 'updated'),
182 common_date_string($this->peopletag->modified));
186 function showPrivacy()
188 if ($this->peopletag->private) {
189 $this->out->elementStart('a',
190 array('href' => common_local_url('peopletagsbyuser',
191 array('nickname' => $this->profile->nickname, 'private' => 1))));
192 // TRANS: Privacy mode text in list list item for private list.
193 $this->out->element('span', 'privacy_mode', _m('MODE','Private'));
194 $this->out->elementEnd('a');
200 $this->out->elementStart('span', 'entry-title tag');
201 $this->out->element('a',
202 array('rel' => 'bookmark',
203 'href' => $this->url()),
204 htmlspecialchars($this->peopletag->tag));
205 $this->out->elementEnd('span');
208 function showActions()
210 $this->out->elementStart('div', 'entity_actions');
211 $this->out->elementStart('ul');
213 if (!$this->peopletag->private) {
214 $this->showSubscribeForm();
217 if (!empty($this->current) && $this->profile->id == $this->current->id) {
218 $this->showOwnerOptions();
220 $this->out->elementEnd('ul');
221 $this->out->elementEnd('div');
224 function showDescription()
226 $this->out->element('div', 'e-content description', $this->peopletag->description);