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::staticGet('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' => 'hentry 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()
224 $this->out->elementStart('span', 'author vcard');
226 $attrs['href'] = $this->profile->profileurl;
227 $attrs['class'] = 'url';
228 $attrs['rel'] = 'contact';
230 if (!empty($this->profile->fullname)) {
231 $attrs['title'] = $this->profile->fullname . ' (' . $this->profile->nickname . ')';
233 $this->out->elementStart('a', $attrs);
235 $this->out->text(' ');
236 $this->out->element('span', 'nickname fn',
237 htmlspecialchars($this->profile->nickname));
239 $this->out->elementEnd('a');
240 $this->out->elementEnd('span');
243 function showUpdated()
245 if (!empty($this->peopletag->modified)) {
246 $this->out->element('abbr',
247 array('title' => common_date_w3dtf($this->peopletag->modified),
248 'class' => 'updated'),
249 common_date_string($this->peopletag->modified));
253 function showPrivacy()
255 if ($this->peopletag->private) {
256 $this->out->elementStart('a',
257 array('href' => common_local_url('peopletagsbyuser',
258 array('nickname' => $this->profile->nickname, 'private' => 1))));
259 // TRANS: Privacy mode text in list list item for private list.
260 $this->out->element('span', 'privacy_mode', _m('MODE','Private'));
261 $this->out->elementEnd('a');
267 $this->out->elementStart('span', 'entry-title tag');
268 $this->out->element('a',
269 array('rel' => 'bookmark',
270 'href' => $this->url()),
271 htmlspecialchars($this->peopletag->tag));
272 $this->out->elementEnd('span');
276 * show the avatar of the peopletag's creator
278 * This will use the default avatar if no avatar is assigned for the author.
279 * It makes a link to the author's profile.
284 function showAvatar($size=AVATAR_STREAM_SIZE)
286 $avatar = $this->profile->getAvatar($size);
288 $this->out->element('img', array('src' => ($avatar) ?
289 $avatar->displayUrl() :
290 Avatar::defaultImage($size),
291 'class' => 'avatar photo',
295 ($this->profile->fullname) ?
296 $this->profile->fullname :
297 $this->profile->nickname));
300 function showActions()
302 $this->out->elementStart('div', 'entity_actions');
303 $this->out->elementStart('ul');
305 if (!$this->peopletag->private) {
306 $this->showSubscribeForm();
309 if (!empty($this->current) && $this->profile->id == $this->current->id) {
310 $this->showOwnerOptions();
312 $this->out->elementEnd('ul');
313 $this->out->elementEnd('div');
316 function showDescription()
318 $this->out->element('div', 'entry-content description',
319 $this->peopletag->description);