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('STATUSNET') && !defined('LACONICA')) {
35 require_once INSTALLDIR.'/lib/publicgroupnav.php';
36 require_once INSTALLDIR.'/lib/noticelist.php';
39 * List of popular notices
41 * We provide a list of the most popular notices. Popularity
46 * @author Zach Copley <zach@status.net>
47 * @author Evan Prodromou <evan@status.net>
48 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
49 * @link http://status.net/
51 class FavoritedAction extends Action
58 * @return string Title of the page
63 if ($this->page == 1) {
64 // TRANS: Page title for first page of favorited notices.
65 return _('Popular notices');
67 // TRANS: Page title for all but first page of favorited notices.
68 // TRANS: %d is the page number being displayed.
69 return sprintf(_('Popular notices, page %d'), $this->page);
74 * Instructions for use
76 * @return instructions for use
78 function getInstructions()
80 // TRANS: Description on page displaying favorited notices.
81 return _('The most popular notices on the site right now.');
85 * Is this page read-only?
87 * @return boolean true
89 function isReadOnly($args)
95 * Take arguments for running
97 * @param array $args $_REQUEST args
99 * @return boolean success flag
101 * @todo move queries from showContent() to here
103 function prepare($args)
105 parent::prepare($args);
106 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
108 common_set_returnto($this->selfUrl());
116 * Shows a page with list of favorite notices
118 * @param array $args $_REQUEST args; handled in prepare()
122 function handle($args)
124 parent::handle($args);
130 * Show the page notice
132 * Shows instructions for the page
136 function showPageNotice()
138 $instr = $this->getInstructions();
139 $output = common_markup_to_html($instr);
141 $this->elementStart('div', 'instructions');
143 $this->elementEnd('div');
146 function showEmptyList()
148 // TRANS: Text displayed instead of a list when a site does not yet have any favourited notices.
149 $message = _('Favorite notices appear on this page but no one has favorited one yet.') . ' ';
151 if (common_logged_in()) {
152 // TRANS: Additional text displayed instead of a list when a site does not yet have any favourited notices for logged in users.
153 $message .= _('Be the first to add a notice to your favorites by clicking the fave button next to any notice you like.');
156 // TRANS: Additional text displayed instead of a list when a site does not yet have any favourited notices for not logged in users.
157 // TRANS: %%action.register%% is a registration link. "[link text](link)" is Mark Down. Do not change the formatting.
158 $message .= _('Why not [register an account](%%action.register%%) and be the first to add a notice to your favorites!');
161 $this->elementStart('div', 'guide');
162 $this->raw(common_markup_to_html($message));
163 $this->elementEnd('div');
169 * Shows the list of popular notices
173 function showContent()
175 $pop = new Popularity();
176 $pop->offset = ($this->page - 1) * NOTICES_PER_PAGE;
177 $pop->limit = NOTICES_PER_PAGE;
179 $notice = $pop->getNotices();
181 $nl = new NoticeList($notice, $this);
186 $this->showEmptyList();
189 $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
190 $this->page, 'favorited');