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('STATUSNET') && !defined('LACONICA')) {
34 require_once INSTALLDIR.'/lib/personalgroupnav.php';
35 require_once INSTALLDIR.'/lib/noticelist.php';
36 require_once INSTALLDIR.'/lib/feedlist.php';
43 * @author Evan Prodromou <evan@status.net>
44 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
45 * @link http://status.net/
47 class RepliesAction extends Action
55 * Check the input values and initialize the object.
56 * Shows an error page on bad input.
58 * @param array $args $_REQUEST data
60 * @return boolean success flag
62 function prepare($args)
64 parent::prepare($args);
66 $nickname = common_canonical_nickname($this->arg('nickname'));
68 $this->user = User::staticGet('nickname', $nickname);
71 // TRANS: Client error displayed when trying to reply to a non-exsting user.
72 $this->clientError(_('No such user.'));
76 $profile = $this->user->getProfile();
79 // TRANS: Error message displayed when referring to a user without a profile.
80 $this->serverError(_('User has no profile.'));
84 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
86 common_set_returnto($this->selfUrl());
88 $stream = new ReplyNoticeStream($this->user->id,
91 $this->notice = $stream->getNotices(($this->page-1) * NOTICES_PER_PAGE,
92 NOTICES_PER_PAGE + 1);
94 if($this->page > 1 && $this->notice->N == 0){
95 // TRANS: Server error when page not found (404)
96 $this->serverError(_('No such page.'),$code=404);
105 * Just show the page. All args already handled.
107 * @param array $args $_REQUEST data
111 function handle($args)
113 parent::handle($args);
120 * Includes name of user and page number.
122 * @return string title of page
126 if ($this->page == 1) {
127 // TRANS: Title for first page of replies for a user.
128 // TRANS: %s is a user nickname.
129 return sprintf(_("Replies to %s"), $this->user->nickname);
131 // TRANS: Title for all but the first page of replies for a user.
132 // TRANS: %1$s is a user nickname, %2$d is a page number.
133 return sprintf(_('Replies to %1$s, page %2$d'),
134 $this->user->nickname,
140 * Feeds for the <head> section
146 return array(new Feed(Feed::JSON,
147 common_local_url('ApiTimelineMentions',
149 'id' => $this->user->nickname,
151 // TRANS: Link for feed with replies for a user.
152 // TRANS: %s is a user nickname.
153 sprintf(_('Replies feed for %s (Activity Streams JSON)'),
154 $this->user->nickname)),
156 common_local_url('repliesrss',
157 array('nickname' => $this->user->nickname)),
158 // TRANS: Link for feed with replies for a user.
159 // TRANS: %s is a user nickname.
160 sprintf(_('Replies feed for %s (RSS 1.0)'),
161 $this->user->nickname)),
163 common_local_url('ApiTimelineMentions',
165 'id' => $this->user->nickname,
167 // TRANS: Link for feed with replies for a user.
168 // TRANS: %s is a user nickname.
169 sprintf(_('Replies feed for %s (RSS 2.0)'),
170 $this->user->nickname)),
172 common_local_url('ApiTimelineMentions',
174 'id' => $this->user->nickname,
175 'format' => 'atom')),
176 // TRANS: Link for feed with replies for a user.
177 // TRANS: %s is a user nickname.
178 sprintf(_('Replies feed for %s (Atom)'),
179 $this->user->nickname)));
185 * A list of notices that are replies to the user, plus pagination.
189 function showContent()
191 $nl = new NoticeList($this->notice, $this);
195 $this->showEmptyListMessage();
198 $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
199 $this->page, 'replies',
200 array('nickname' => $this->user->nickname));
203 function showEmptyListMessage()
205 // TRANS: Empty list message for page with replies for a user.
206 // TRANS: %1$s and %s$s are the user nickname.
207 $message = sprintf(_('This is the timeline showing replies to %1$s but %2$s hasn\'t received a notice to them yet.'),
208 $this->user->nickname,
209 $this->user->nickname) . ' ';
211 if (common_logged_in()) {
212 $current_user = common_current_user();
213 if ($this->user->id === $current_user->id) {
214 // TRANS: Empty list message for page with replies for a user for the logged in user.
215 // TRANS: This message contains a Markdown link in the form [link text](link).
216 $message .= _('You can engage other users in a conversation, subscribe to more people or [join groups](%%action.groups%%).');
218 // TRANS: Empty list message for page with replies for a user for all logged in users but the user themselves.
219 // TRANS: %1$s, %2$s and %3$s are a user nickname. This message contains a Markdown link in the form [link text](link).
220 $message .= sprintf(_('You can try to [nudge %1$s](../%2$s) or [post something to them](%%%%action.newnotice%%%%?status_textarea=%3$s).'), $this->user->nickname, $this->user->nickname, '@' . $this->user->nickname);
224 // TRANS: Empty list message for page with replies for a user for not logged in users.
225 // TRANS: %1$s is a user nickname. This message contains a Markdown link in the form [link text](link).
226 $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to them.'), $this->user->nickname);
229 $this->elementStart('div', 'guide');
230 $this->raw(common_markup_to_html($message));
231 $this->elementEnd('div');
234 function isReadOnly($args)