3 * StatusNet, the distributed open-source microblogging tool
5 * List of popular notices
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 Zach Copley <zach@status.net>
25 * @author Evan Prodromou <evan@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('GNUSOCIAL')) { exit(1); }
34 * List of popular notices
36 * We provide a list of the most popular notices. Popularity
41 * @author Zach Copley <zach@status.net>
42 * @author Evan Prodromou <evan@status.net>
43 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
44 * @link http://status.net/
46 class FavoritedAction extends Action
53 * @return string Title of the page
58 if ($this->page == 1) {
59 // TRANS: Page title for first page of favorited notices.
60 return _('Popular notices');
62 // TRANS: Page title for all but first page of favorited notices.
63 // TRANS: %d is the page number being displayed.
64 return sprintf(_('Popular notices, page %d'), $this->page);
69 * Instructions for use
71 * @return instructions for use
73 function getInstructions()
75 // TRANS: Description on page displaying favorited notices.
76 return _('The most popular notices on the site right now.');
80 * Is this page read-only?
82 * @return boolean true
84 function isReadOnly($args)
90 * Take arguments for running
92 * @param array $args $_REQUEST args
94 * @return boolean success flag
96 * @todo move queries from showContent() to here
98 function prepare($args)
100 parent::prepare($args);
101 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
103 common_set_returnto($this->selfUrl());
111 * Shows a page with list of favorite notices
113 * @param array $args $_REQUEST args; handled in prepare()
117 function handle($args)
119 parent::handle($args);
125 * Show the page notice
127 * Shows instructions for the page
131 function showPageNotice()
133 $instr = $this->getInstructions();
134 $output = common_markup_to_html($instr);
136 $this->elementStart('div', 'instructions');
138 $this->elementEnd('div');
141 function showEmptyList()
143 // TRANS: Text displayed instead of a list when a site does not yet have any favourited notices.
144 $message = _('Favorite notices appear on this page but no one has favorited one yet.') . ' ';
146 if (common_logged_in()) {
147 // TRANS: Additional text displayed instead of a list when a site does not yet have any favourited notices for logged in users.
148 $message .= _('Be the first to add a notice to your favorites by clicking the fave button next to any notice you like.');
151 // TRANS: Additional text displayed instead of a list when a site does not yet have any favourited notices for not logged in users.
152 // TRANS: %%action.register%% is a registration link. "[link text](link)" is Mark Down. Do not change the formatting.
153 $message .= _('Why not [register an account](%%action.register%%) and be the first to add a notice to your favorites!');
156 $this->elementStart('div', 'guide');
157 $this->raw(common_markup_to_html($message));
158 $this->elementEnd('div');
164 * Shows the list of popular notices
168 function showContent()
170 $stream = new PopularNoticeStream($this->scoped);
171 $notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE+1);
173 $nl = new NoticeList($notice, $this);
178 $this->showEmptyList();
181 $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
182 $this->page, 'favorited');