123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- <?php
- if (!defined('STATUSNET') && !defined('LACONICA')) {
- exit(1);
- }
- class SubscribersAction extends GalleryAction
- {
- function title()
- {
- if ($this->page == 1) {
-
-
- return sprintf(_('%s subscribers'), $this->target->getNickname());
- } else {
-
-
- return sprintf(_('%1$s subscribers, page %2$d'),
- $this->target->getNickname(),
- $this->page);
- }
- }
- function showPageNotice()
- {
- if ($this->scoped instanceof Profile && $this->scoped->id === $this->target->id) {
- $this->element('p', null,
-
-
- _('These are the people who listen to '.
- 'your notices.'));
- } else {
- $this->element('p', null,
-
-
- sprintf(_('These are the people who '.
- 'listen to %s\'s notices.'),
- $this->target->getNickname()));
- }
- }
- function showContent()
- {
- parent::showContent();
- $offset = ($this->page-1) * PROFILES_PER_PAGE;
- $limit = PROFILES_PER_PAGE + 1;
- $cnt = 0;
- if ($this->tag) {
- $subscribers = $this->target->getTaggedSubscribers($this->tag, $offset, $limit);
- } else {
- $subscribers = $this->target->getSubscribers($offset, $limit);
- }
- if ($subscribers) {
- $subscribers_list = new SubscribersList($subscribers, $this->target, $this);
- $cnt = $subscribers_list->show();
- if (0 == $cnt) {
- $this->showEmptyListMessage();
- }
- }
- $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
- $this->page, 'subscribers',
- array('nickname' => $this->target->getNickname()));
- }
- function showEmptyListMessage()
- {
- if ($this->scoped instanceof Profile && $this->target->id === $this->scoped->id) {
-
- $message = _('You have no subscribers. Try subscribing to people you know and they might return the favor.');
- } elseif ($this->scoped instanceof Profile) {
-
-
- $message = sprintf(_('%s has no subscribers. Want to be the first?'), $this->target->getNickname());
- } else {
-
-
-
-
-
- $message = sprintf(_('%s has no subscribers. Why not [register an account](%%%%action.register%%%%) and be the first?'), $this->target->getNickname());
- }
- $this->elementStart('div', 'guide');
- $this->raw(common_markup_to_html($message));
- $this->elementEnd('div');
- }
- function showSections()
- {
- parent::showSections();
- }
- }
- class SubscribersList extends SubscriptionList
- {
- function newListItem($profile)
- {
- return new SubscribersListItem($profile, $this->owner, $this->action);
- }
- }
- class SubscribersListItem extends SubscriptionListItem
- {
- function showActions()
- {
- $this->startActions();
- if (Event::handle('StartProfileListItemActionElements', array($this))) {
- $this->showSubscribeButton();
-
- $this->showBlockForm();
- Event::handle('EndProfileListItemActionElements', array($this));
- }
- $this->endActions();
- }
- function showBlockForm()
- {
- $user = common_current_user();
- if (!empty($user) && $this->owner->id == $user->id) {
- $returnto = array('action' => 'subscribers',
- 'nickname' => $this->owner->getNickname());
- $page = $this->out->arg('page');
- if ($page) {
- $returnto['param-page'] = $page;
- }
- $bf = new BlockForm($this->out, $this->profile, $returnto);
- $bf->show();
- }
- }
- function linkAttributes()
- {
- $aAttrs = parent::linkAttributes();
- if (common_config('nofollow', 'subscribers')) {
- $aAttrs['rel'] .= ' nofollow';
- }
- return $aAttrs;
- }
- function homepageAttributes()
- {
- $aAttrs = parent::linkAttributes();
- if (common_config('nofollow', 'subscribers')) {
- $aAttrs['rel'] = 'nofollow';
- }
- return $aAttrs;
- }
- }
|