* @link http://status.net/
*/
-if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
-}
-
-require_once INSTALLDIR.'/lib/widget.php';
-
-define('PEOPLETAGS_PER_PAGE', 20);
+if (!defined('GNUSOCIAL')) { exit(1); }
/**
* Widget to show a list of peopletags
$ptag->show();
}
}
-
-class PeopletagListItem extends Widget
-{
- var $peopletag = null;
- var $current = null;
- var $profile = null;
-
- /**
- * constructor
- *
- * Also initializes the owner attribute.
- *
- * @param Notice $notice The notice we'll display
- */
- function __construct($peopletag, $current, $out=null)
- {
- parent::__construct($out);
- $this->peopletag = $peopletag;
- $this->current = $current;
- $this->profile = Profile::staticGet('id', $this->peopletag->tagger);
- }
-
- /**
- * recipe function for displaying a single peopletag.
- *
- * This uses all the other methods to correctly display a notice. Override
- * it or one of the others to fine-tune the output.
- *
- * @return void
- */
- function url()
- {
- return $this->peopletag->homeUrl();
- }
-
- function show()
- {
- if (empty($this->peopletag)) {
- common_log(LOG_WARNING, "Trying to show missing peopletag; skipping.");
- return;
- }
-
- if (Event::handle('StartShowPeopletagItem', array($this))) {
- $this->showStart();
- $this->showPeopletag();
- $this->showStats();
- $this->showEnd();
- Event::handle('EndShowPeopletagItem', array($this));
- }
- }
-
- function showStart()
- {
- $mode = ($this->peopletag->private) ? 'private' : 'public';
- $this->out->elementStart('li', array('class' => 'hentry peopletag mode-' . $mode,
- 'id' => 'peopletag-' . $this->peopletag->id));
- }
-
- function showEnd()
- {
- $this->out->elementEnd('li');
- }
-
- function showPeopletag()
- {
- $this->showCreator();
- $this->showTag();
- $this->showPrivacy();
- $this->showUpdated();
- $this->showActions();
- $this->showDescription();
- }
-
- function showStats()
- {
- $this->out->elementStart('div', 'entry-summary entity_statistics');
- $this->out->elementStart('span', 'tagged-count');
- $this->out->element('a',
- array('href' => common_local_url('peopletagged',
- array('tagger' => $this->profile->nickname,
- 'tag' => $this->peopletag->tag))),
- // TRANS: Link description for link to list of users tagged with a tag.
- _('Tagged'));
- $this->out->raw($this->peopletag->taggedCount());
- $this->out->elementEnd('span');
-
- $this->out->elementStart('span', 'subscriber-count');
- $this->out->element('a',
- array('href' => common_local_url('peopletagsubscribers',
- array('tagger' => $this->profile->nickname,
- 'tag' => $this->peopletag->tag))),
- // TRANS: Link description for link to list of users subscribed to a tag.
- _('Subscribers'));
- $this->out->raw($this->peopletag->subscriberCount());
- $this->out->elementEnd('span');
- $this->out->elementEnd('div');
- }
-
- function showOwnerOptions()
- {
- $this->out->elementStart('li', 'entity_edit');
- $this->out->element('a', array('href' =>
- common_local_url('editpeopletag', array('tagger' => $this->profile->nickname,
- 'tag' => $this->peopletag->tag)),
- // TRANS: Title for link to edit people tag settings.
- 'title' => _('Edit list settings.')),
- // TRANS: Text for link to edit people tag settings.
- _('Edit'));
- $this->out->elementEnd('li');
- }
-
- function showSubscribeForm()
- {
- $this->out->elementStart('li');
-
- if (Event::handle('StartSubscribePeopletagForm', array($this->out, $this->peopletag))) {
- if ($this->current) {
- if ($this->peopletag->hasSubscriber($this->current->id)) {
- $form = new UnsubscribePeopletagForm($this->out, $this->peopletag);
- $form->show();
- } else {
- $form = new SubscribePeopletagForm($this->out, $this->peopletag);
- $form->show();
- }
- }
- Event::handle('EndSubscribePeopletagForm', array($this->out, $this->peopletag));
- }
-
- $this->out->elementEnd('li');
- }
-
- function showCreator()
- {
- $this->out->elementStart('span', 'author vcard');
- $attrs = array();
- $attrs['href'] = $this->profile->profileurl;
- $attrs['class'] = 'url';
- $attrs['rel'] = 'contact';
-
- if (!empty($this->profile->fullname)) {
- $attrs['title'] = $this->profile->fullname . ' (' . $this->profile->nickname . ')';
- }
- $this->out->elementStart('a', $attrs);
- $this->showAvatar();
- $this->out->text(' ');
- $this->out->element('span', 'nickname fn',
- htmlspecialchars($this->profile->nickname));
-
- $this->out->elementEnd('a');
- $this->out->elementEnd('span');
- }
-
- function showUpdated()
- {
- if (!empty($this->peopletag->modified)) {
- $this->out->element('abbr',
- array('title' => common_date_w3dtf($this->peopletag->modified),
- 'class' => 'updated'),
- common_date_string($this->peopletag->modified));
- }
- }
-
- function showPrivacy()
- {
- if ($this->peopletag->private) {
- $this->out->elementStart('a',
- array('href' => common_local_url('peopletagsbyuser',
- array('nickname' => $this->profile->nickname, 'private' => 1))));
- // TRANS: Privacy mode text in people tag list item for private tags.
- $this->out->element('span', 'privacy_mode', _m('MODE','Private'));
- $this->out->elementEnd('a');
- }
- }
-
- function showTag()
- {
- $this->out->elementStart('span', 'entry-title tag');
- $this->out->element('a',
- array('rel' => 'bookmark',
- 'href' => $this->url()),
- htmlspecialchars($this->peopletag->tag));
- $this->out->elementEnd('span');
- }
-
- /**
- * show the avatar of the peopletag's creator
- *
- * This will use the default avatar if no avatar is assigned for the author.
- * It makes a link to the author's profile.
- *
- * @return void
- */
-
- function showAvatar($size=AVATAR_STREAM_SIZE)
- {
- $avatar = $this->profile->getAvatar($size);
-
- $this->out->element('img', array('src' => ($avatar) ?
- $avatar->displayUrl() :
- Avatar::defaultImage($size),
- 'class' => 'avatar photo',
- 'width' => $size,
- 'height' => $size,
- 'alt' =>
- ($this->profile->fullname) ?
- $this->profile->fullname :
- $this->profile->nickname));
- }
-
- function showActions()
- {
- $this->out->elementStart('div', 'entity_actions');
- $this->out->elementStart('ul');
-
- if (!$this->peopletag->private) {
- $this->showSubscribeForm();
- }
-
- if (!empty($this->current) && $this->profile->id == $this->current->id) {
- $this->showOwnerOptions();
- }
- $this->out->elementEnd('ul');
- $this->out->elementEnd('div');
- }
-
- function showDescription()
- {
- $this->out->element('div', 'entry-content description',
- $this->peopletag->description);
- }
-}