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-2009 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/
48 class RepliesAction extends OwnerDesignAction
56 * Check the input values and initialize the object.
57 * Shows an error page on bad input.
59 * @param array $args $_REQUEST data
61 * @return boolean success flag
64 function prepare($args)
66 parent::prepare($args);
68 $nickname = common_canonical_nickname($this->arg('nickname'));
70 $this->user = User::staticGet('nickname', $nickname);
73 $this->clientError(_('No such user.'));
77 $profile = $this->user->getProfile();
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 $this->notice = $this->user->getReplies(($this->page-1) * NOTICES_PER_PAGE,
89 NOTICES_PER_PAGE + 1);
91 if($this->page > 1 && $this->notice->N == 0){
92 // TRANS: Server error when page not found (404)
93 $this->serverError(_('No such page.'),$code=404);
102 * Just show the page. All args already handled.
104 * @param array $args $_REQUEST data
109 function handle($args)
111 parent::handle($args);
118 * Includes name of user and page number.
120 * @return string title of page
125 if ($this->page == 1) {
126 return sprintf(_("Replies to %s"), $this->user->nickname);
128 return sprintf(_('Replies to %1$s, page %2$d'),
129 $this->user->nickname,
135 * Feeds for the <head> section
142 return array(new Feed(Feed::RSS1,
143 common_local_url('repliesrss',
144 array('nickname' => $this->user->nickname)),
145 sprintf(_('Replies feed for %s (RSS 1.0)'),
146 $this->user->nickname)),
148 common_local_url('ApiTimelineMentions',
150 'id' => $this->user->nickname,
152 sprintf(_('Replies feed for %s (RSS 2.0)'),
153 $this->user->nickname)),
155 common_local_url('ApiTimelineMentions',
157 'id' => $this->user->nickname,
158 'format' => 'atom')),
159 sprintf(_('Replies feed for %s (Atom)'),
160 $this->user->nickname)));
164 * show the personal group nav
169 function showLocalNav()
171 $nav = new PersonalGroupNav($this);
178 * A list of notices that are replies to the user, plus pagination.
183 function showContent()
185 $nl = new NoticeList($this->notice, $this);
189 $this->showEmptyListMessage();
192 $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
193 $this->page, 'replies',
194 array('nickname' => $this->user->nickname));
197 function showEmptyListMessage()
199 $message = sprintf(_('This is the timeline showing replies to %1$s but %2$s hasn\'t received a notice to them yet.'), $this->user->nickname, $this->user->nickname) . ' ';
201 if (common_logged_in()) {
202 $current_user = common_current_user();
203 if ($this->user->id === $current_user->id) {
204 $message .= _('You can engage other users in a conversation, subscribe to more people or [join groups](%%action.groups%%).');
206 $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);
210 $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to them.'), $this->user->nickname);
213 $this->elementStart('div', 'guide');
214 $this->raw(common_markup_to_html($message));
215 $this->elementEnd('div');
218 function isReadOnly($args)