3 * StatusNet, the distributed open-source microblogging tool
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 * @copyright 2008-2011 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://status.net/
30 if (!defined('GNUSOCIAL')) { exit(1); }
37 * @author Evan Prodromou <evan@status.net>
38 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
39 * @link http://status.net/
41 class RepliesAction extends ManagedAction
46 protected function doPreparation()
48 $nickname = common_canonical_nickname($this->arg('nickname'));
50 $this->user = User::getKV('nickname', $nickname);
52 if (!$this->user instanceof User) {
53 // TRANS: Client error displayed when trying to reply to a non-exsting user.
54 $this->clientError(_('No such user.'));
57 $this->target = $this->user->getProfile();
59 if (!$this->target instanceof Profile) {
60 // TRANS: Error message displayed when referring to a user without a profile.
61 $this->serverError(_('User has no profile.'));
64 $this->page = $this->int('page') ?: 1;
66 common_set_returnto($this->selfUrl());
68 $stream = new ReplyNoticeStream($this->target->getID(), $this->scoped);
70 $this->notice = $stream->getNotices(($this->page-1) * NOTICES_PER_PAGE,
71 NOTICES_PER_PAGE + 1);
73 if ($this->page > 1 && $this->notice->N == 0) {
74 // TRANS: Client error when page not found (404)
75 $this->clientError(_('No such page.'), 404);
85 * Just show the page. All args already handled.
87 * @param array $args $_REQUEST data
91 function handle(array $args=array())
93 parent::handle($args);
96 >>>>>>> 1442ca16b410d327d7ec6269944144dfa075ff17
102 * Includes name of user and page number.
104 * @return string title of page
108 if ($this->page == 1) {
109 // TRANS: Title for first page of replies for a user.
110 // TRANS: %s is a user nickname.
111 return sprintf(_("Replies to %s"), $this->target->getNickname());
113 // TRANS: Title for all but the first page of replies for a user.
114 // TRANS: %1$s is a user nickname, %2$d is a page number.
115 return sprintf(_('Replies to %1$s, page %2$d'),
116 $this->target->getNickname(),
122 * Feeds for the <head> section
128 return array(new Feed(Feed::JSON,
129 common_local_url('ApiTimelineMentions',
131 'id' => $this->target->getNickname(),
133 // TRANS: Link for feed with replies for a user.
134 // TRANS: %s is a user nickname.
135 sprintf(_('Replies feed for %s (Activity Streams JSON)'),
136 $this->user->nickname)),
138 common_local_url('repliesrss',
139 array('nickname' => $this->target->getNickname())),
140 // TRANS: Link for feed with replies for a user.
141 // TRANS: %s is a user nickname.
142 sprintf(_('Replies feed for %s (RSS 1.0)'),
143 $this->target->getNickname())),
145 common_local_url('ApiTimelineMentions',
147 'id' => $this->target->getNickname(),
149 // TRANS: Link for feed with replies for a user.
150 // TRANS: %s is a user nickname.
151 sprintf(_('Replies feed for %s (RSS 2.0)'),
152 $this->target->getNickname())),
154 common_local_url('ApiTimelineMentions',
156 'id' => $this->target->getNickname(),
157 'format' => 'atom')),
158 // TRANS: Link for feed with replies for a user.
159 // TRANS: %s is a user nickname.
160 sprintf(_('Replies feed for %s (Atom)'),
161 $this->target->getNickname())));
164 function showContent()
166 $nl = new PrimaryNoticeList($this->notice, $this, array('show_n'=>NOTICES_PER_PAGE));
170 $this->showEmptyListMessage();
173 $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
174 $this->page, 'replies',
175 array('nickname' => $this->target->getNickname()));
178 function showEmptyListMessage()
180 // TRANS: Empty list message for page with replies for a user.
181 // TRANS: %1$s is the user nickname.
182 $message = sprintf(_('This is the timeline showing replies to %1$s but no notices have arrived yet.'), $this->target->getNickname());
183 $message .= ' '; // Spacing between this sentence and the next.
185 if (common_logged_in()) {
186 if ($this->target->getID() === $this->scoped->getID()) {
187 // TRANS: Empty list message for page with replies for a user for the logged in user.
188 // TRANS: This message contains a Markdown link in the form [link text](link).
189 $message .= _('You can engage other users in a conversation, subscribe to more people or [join groups](%%action.groups%%).');
191 // TRANS: Empty list message for page with replies for a user for all logged in users but the user themselves.
192 // TRANS: %1$s is a user nickname and %2$s is the same but with a prepended '@' character. This message contains a Markdown link in the form [link text](link).
193 $message .= sprintf(_('You can try to [nudge %1$s](../%1$s) or [post something to them](%%%%action.newnotice%%%%?content=%2$s).'), $this->target->getNickname(), '@' . $this->target->getNickname());
196 // TRANS: Empty list message for page with replies for a user for not logged in users.
197 // TRANS: %1$s is a user nickname. This message contains a Markdown link in the form [link text](link).
198 $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to them.'), $this->target->getNickname());
201 $this->elementStart('div', 'guide');
202 $this->raw(common_markup_to_html($message));
203 $this->elementEnd('div');
207 function isReadOnly(array $args=array())
209 public function isReadOnly($args)
210 >>>>>>> 1442ca16b410d327d7ec6269944144dfa075ff17