4 * StatusNet, the distributed open-source microblogging tool
6 * Widget to show a list of peopletags
10 * LICENCE: This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Affero General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Affero General Public License for more details.
20 * You should have received a copy of the GNU Affero General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 * @author Shashi Gowda <connect2shashi@gmail.com>
26 * @copyright 2008-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/
31 if (!defined('STATUSNET') && !defined('LACONICA')) {
35 require_once INSTALLDIR.'/lib/widget.php';
37 define('PEOPLETAGS_PER_PAGE', 20);
40 * Widget to show a list of peopletags
44 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
45 * @link http://status.net/
48 class PeopletagList extends Widget
50 /** Current peopletag, peopletag query. */
51 var $peopletag = null;
55 function __construct($peopletag, $action=null)
57 parent::__construct($action);
59 $this->peopletag = $peopletag;
64 $this->user = common_current_user();
70 $this->out->elementStart('ul', 'peopletags xoxo hfeed');
74 while ($this->peopletag->fetch()) {
76 if($cnt > PEOPLETAGS_PER_PAGE) {
79 $this->showPeopletag();
82 $this->out->elementEnd('ul');
87 function showPeopletag()
89 $ptag = new PeopletagListItem($this->peopletag, $this->user, $this->out);
94 class PeopletagListItem extends Widget
96 var $peopletag = null;
103 * Also initializes the owner attribute.
105 * @param Notice $notice The notice we'll display
108 function __construct($peopletag, $current, $out=null)
110 parent::__construct($out);
111 $this->peopletag = $peopletag;
112 $this->current = $current;
113 $this->profile = Profile::staticGet('id', $this->peopletag->tagger);
117 * recipe function for displaying a single peopletag.
119 * This uses all the other methods to correctly display a notice. Override
120 * it or one of the others to fine-tune the output.
127 return $this->peopletag->homeUrl();
132 if (empty($this->peopletag)) {
133 common_log(LOG_WARNING, "Trying to show missing peopletag; skipping.");
137 if (Event::handle('StartShowPeopletagItem', array($this))) {
139 $this->showPeopletag();
142 Event::handle('EndShowPeopletagItem', array($this));
148 $mode = ($this->peopletag->private) ? 'private' : 'public';
149 $this->out->elementStart('li', array('class' => 'hentry peopletag mode-' . $mode,
150 'id' => 'peopletag-' . $this->peopletag->id));
155 $this->out->elementEnd('li');
158 function showPeopletag()
160 $this->showCreator();
162 $this->showPrivacy();
163 $this->showUpdated();
164 $this->showActions();
165 $this->showDescription();
170 $this->out->elementStart('div', 'entry-summary entity_statistics');
171 $this->out->elementStart('span', 'tagged-count');
172 $this->out->element('a',
173 array('href' => common_local_url('peopletagged',
174 array('tagger' => $this->profile->nickname,
175 'tag' => $this->peopletag->tag))),
177 $this->out->raw($this->peopletag->taggedCount());
178 $this->out->elementEnd('span');
180 $this->out->elementStart('span', 'subscriber-count');
181 $this->out->element('a',
182 array('href' => common_local_url('peopletagsubscribers',
183 array('tagger' => $this->profile->nickname,
184 'tag' => $this->peopletag->tag))),
186 $this->out->raw($this->peopletag->subscriberCount());
187 $this->out->elementEnd('span');
188 $this->out->elementEnd('div');
191 function showOwnerOptions()
193 $this->out->elementStart('li', 'entity_edit');
194 $this->out->element('a', array('href' =>
195 common_local_url('editpeopletag', array('tagger' => $this->profile->nickname,
196 'tag' => $this->peopletag->tag)),
197 'title' => _('Edit peopletag 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 $this->out->element('span', 'privacy_mode', _('Private'));
260 $this->out->elementEnd('a');
266 $this->out->elementStart('span', 'entry-title tag');
267 $this->out->element('a',
268 array('rel' => 'bookmark',
269 'href' => $this->url()),
270 htmlspecialchars($this->peopletag->tag));
271 $this->out->elementEnd('span');
275 * show the avatar of the peopletag's creator
277 * This will use the default avatar if no avatar is assigned for the author.
278 * It makes a link to the author's profile.
283 function showAvatar($size=AVATAR_STREAM_SIZE)
285 $avatar = $this->profile->getAvatar($size);
287 $this->out->element('img', array('src' => ($avatar) ?
288 $avatar->displayUrl() :
289 Avatar::defaultImage($size),
290 'class' => 'avatar photo',
294 ($this->profile->fullname) ?
295 $this->profile->fullname :
296 $this->profile->nickname));
299 function showActions()
301 $this->out->elementStart('div', 'entity_actions');
302 $this->out->elementStart('ul');
304 if (!$this->peopletag->private) {
305 $this->showSubscribeForm();
308 if (!empty($this->current) && $this->profile->id == $this->current->id) {
309 $this->showOwnerOptions();
311 $this->out->elementEnd('ul');
312 $this->out->elementEnd('div');
315 function showDescription()
317 $this->out->element('div', 'entry-content description',
318 $this->peopletag->description);