3 * StatusNet, the distributed open-source microblogging tool
5 * List a user's subscribers
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 Evan Prodromou <evan@status.net>
25 * @author Sarven Capadisli <csarven@status.net>
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')) {
36 * List a user's subscribers
40 * @author Evan Prodromou <evan@status.net>
41 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
42 * @link http://status.net/
44 class SubscribersAction extends GalleryAction
48 if ($this->page == 1) {
49 // TRANS: Header for list of subscribers for a user (first page).
50 // TRANS: %s is the user's nickname.
51 return sprintf(_('%s subscribers'), $this->target->getNickname());
53 // TRANS: Header for list of subscribers for a user (not first page).
54 // TRANS: %1$s is the user's nickname, $2$d is the page number.
55 return sprintf(_('%1$s subscribers, page %2$d'),
56 $this->target->getNickname(),
61 function showPageNotice()
63 if ($this->scoped instanceof Profile && $this->scoped->id === $this->target->id) {
64 $this->element('p', null,
65 // TRANS: Page notice for page with an overview of all subscribers
66 // TRANS: of the logged in user's own profile.
67 _('These are the people who listen to '.
70 $this->element('p', null,
71 // TRANS: Page notice for page with an overview of all subscribers of a user other
72 // TRANS: than the logged in user. %s is the user nickname.
73 sprintf(_('These are the people who '.
74 'listen to %s\'s notices.'),
75 $this->target->getNickname()));
79 function showContent()
81 parent::showContent();
83 $offset = ($this->page-1) * PROFILES_PER_PAGE;
84 $limit = PROFILES_PER_PAGE + 1;
89 $subscribers = $this->target->getTaggedSubscribers($this->tag, $offset, $limit);
91 $subscribers = $this->target->getSubscribers($offset, $limit);
95 $subscribers_list = new SubscribersList($subscribers, $this->target, $this);
96 $cnt = $subscribers_list->show();
98 $this->showEmptyListMessage();
102 $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
103 $this->page, 'subscribers',
104 array('nickname' => $this->target->getNickname()));
107 function showEmptyListMessage()
109 if ($this->scoped instanceof Profile && $this->target->id === $this->scoped->id) {
110 // TRANS: Subscriber list text when the logged in user has no subscribers.
111 $message = _('You have no subscribers. Try subscribing to people you know and they might return the favor.');
112 } elseif ($this->scoped instanceof Profile) {
113 // TRANS: Subscriber list text when looking at the subscribers for a of a user other
114 // TRANS: than the logged in user that has no subscribers. %s is the user nickname.
115 $message = sprintf(_('%s has no subscribers. Want to be the first?'), $this->target->getNickname());
117 // TRANS: Subscriber list text when looking at the subscribers for a of a user that has none
118 // TRANS: as an anonymous user. %s is the user nickname.
119 // TRANS: This message contains a Markdown URL. The link description is between
120 // TRANS: square brackets, and the link between parentheses. Do not separate "]("
121 // TRANS: and do not change the URL part.
122 $message = sprintf(_('%s has no subscribers. Why not [register an account](%%%%action.register%%%%) and be the first?'), $this->target->getNickname());
125 $this->elementStart('div', 'guide');
126 $this->raw(common_markup_to_html($message));
127 $this->elementEnd('div');
130 function showSections()
132 parent::showSections();
136 class SubscribersList extends SubscriptionList
138 function newListItem($profile)
140 return new SubscribersListItem($profile, $this->owner, $this->action);
144 class SubscribersListItem extends SubscriptionListItem
146 function showActions()
148 $this->startActions();
149 if (Event::handle('StartProfileListItemActionElements', array($this))) {
150 $this->showSubscribeButton();
152 $this->showBlockForm();
153 Event::handle('EndProfileListItemActionElements', array($this));
158 function showBlockForm()
160 $user = common_current_user();
162 if (!empty($user) && $this->owner->id == $user->id) {
163 $returnto = array('action' => 'subscribers',
164 'nickname' => $this->owner->getNickname());
165 $page = $this->out->arg('page');
167 $returnto['param-page'] = $page;
169 $bf = new BlockForm($this->out, $this->profile, $returnto);
174 function linkAttributes()
176 $aAttrs = parent::linkAttributes();
178 if (common_config('nofollow', 'subscribers')) {
179 $aAttrs['rel'] .= ' nofollow';
185 function homepageAttributes()
187 $aAttrs = parent::linkAttributes();
189 if (common_config('nofollow', 'subscribers')) {
190 $aAttrs['rel'] = 'nofollow';