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->user->nickname);
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->user->nickname,
61 function showPageNotice()
63 $user = common_current_user();
64 if ($user && ($user->id == $this->profile->id)) {
65 $this->element('p', null,
66 // TRANS: Page notice for page with an overview of all subscribers
67 // TRANS: of the logged in user's own profile.
68 _('These are the people who listen to '.
71 $this->element('p', null,
72 // TRANS: Page notice for page with an overview of all subscribers of a user other
73 // TRANS: than the logged in user. %s is the user nickname.
74 sprintf(_('These are the people who '.
75 'listen to %s\'s notices.'),
76 $this->profile->nickname));
80 function showContent()
82 parent::showContent();
84 $offset = ($this->page-1) * PROFILES_PER_PAGE;
85 $limit = PROFILES_PER_PAGE + 1;
90 $subscribers = $this->user->getTaggedSubscribers($this->tag, $offset, $limit);
92 $subscribers = $this->user->getSubscribers($offset, $limit);
96 $subscribers_list = new SubscribersList($subscribers, $this->user, $this);
97 $cnt = $subscribers_list->show();
99 $this->showEmptyListMessage();
103 $subscribers->free();
105 $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
106 $this->page, 'subscribers',
107 array('nickname' => $this->user->nickname));
110 function showEmptyListMessage()
112 if (common_logged_in()) {
113 $current_user = common_current_user();
114 if ($this->user->id === $current_user->id) {
115 // TRANS: Subscriber list text when the logged in user has no subscribers.
116 $message = _('You have no subscribers. Try subscribing to people you know and they might return the favor.');
118 // TRANS: Subscriber list text when looking at the subscribers for a of a user other
119 // TRANS: than the logged in user that has no subscribers. %s is the user nickname.
120 $message = sprintf(_('%s has no subscribers. Want to be the first?'), $this->user->nickname);
124 // TRANS: Subscriber list text when looking at the subscribers for a of a user that has none
125 // TRANS: as an anonymous user. %s is the user nickname.
126 // TRANS: This message contains a Markdown URL. The link description is between
127 // TRANS: square brackets, and the link between parentheses. Do not separate "]("
128 // TRANS: and do not change the URL part.
129 $message = sprintf(_('%s has no subscribers. Why not [register an account](%%%%action.register%%%%) and be the first?'), $this->user->nickname);
132 $this->elementStart('div', 'guide');
133 $this->raw(common_markup_to_html($message));
134 $this->elementEnd('div');
137 function showSections()
139 parent::showSections();
140 $cloud = new SubscribersPeopleTagCloudSection($this);
143 $cloud2 = new SubscribersPeopleSelfTagCloudSection($this);
148 class SubscribersList extends SubscriptionList
150 function newListItem($profile)
152 return new SubscribersListItem($profile, $this->owner, $this->action);
156 class SubscribersListItem extends SubscriptionListItem
158 function showActions()
160 $this->startActions();
161 if (Event::handle('StartProfileListItemActionElements', array($this))) {
162 $this->showSubscribeButton();
164 $this->showBlockForm();
165 Event::handle('EndProfileListItemActionElements', array($this));
170 function showBlockForm()
172 $user = common_current_user();
174 if (!empty($user) && $this->owner->id == $user->id) {
175 $returnto = array('action' => 'subscribers',
176 'nickname' => $this->owner->nickname);
177 $page = $this->out->arg('page');
179 $returnto['param-page'] = $page;
181 $bf = new BlockForm($this->out, $this->profile, $returnto);
186 function linkAttributes()
188 $aAttrs = parent::linkAttributes();
190 if (common_config('nofollow', 'subscribers')) {
191 $aAttrs['rel'] .= ' nofollow';
197 function homepageAttributes()
199 $aAttrs = parent::linkAttributes();
201 if (common_config('nofollow', 'subscribers')) {
202 $aAttrs['rel'] = 'nofollow';