3 * Laconica, 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@controlyourself.ca>
25 * @copyright 2008-2009 Control Yourself, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://laconi.ca/
30 if (!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@controlyourself.ca>
44 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
45 * @link http://laconi.ca/
48 class ShowfavoritesAction extends Action
50 /** User we're getting the faves of */
52 /** Page of the faves we're on */
56 * Is this a read-only page?
58 * @return boolean true
69 * Includes name of user and page number.
71 * @return string title of page
76 if ($this->page == 1) {
77 return sprintf(_("%s favorite notices"), $this->user->nickname);
79 return sprintf(_("%s favorite notices, page %d"),
80 $this->user->nickname,
88 * Check the input values and initialize the object.
89 * Shows an error page on bad input.
91 * @param array $args $_REQUEST data
93 * @return boolean success flag
96 function prepare($args)
98 parent::prepare($args);
100 $nickname = common_canonical_nickname($this->arg('nickname'));
102 $this->user = User::staticGet('nickname', $nickname);
105 $this->clientError(_('No such user.'));
109 $this->page = $this->trimmed('page');
115 common_set_returnto($this->selfUrl());
123 * Just show the page. All args already handled.
125 * @param array $args $_REQUEST data
130 function handle($args)
132 parent::handle($args);
137 * Feeds for the <head> section
144 $feedurl = common_local_url('favoritesrss',
146 $this->user->nickname));
147 $feedtitle = sprintf(_('Feed for favorites of %s'),
148 $this->user->nickname);
150 $this->element('link', array('rel' => 'alternate',
152 'type' => 'application/rss+xml',
153 'title' => $feedtitle));
157 * Output document relationship links
161 function showRelationshipLinks()
163 // Machine-readable pagination
164 if ($this->page > 1) {
165 $this->element('link', array('rel' => 'next',
166 'href' => common_local_url('showfavorites',
167 array('nickname' => $this->user->nickname,
168 'page' => $this->page - 1)),
169 'title' => _('Next Favorite Notices')));
171 $this->element('link', array('rel' => 'prev',
172 'href' => common_local_url('showfavorites',
173 array('nickname' => $this->user->nickname,
174 'page' => $this->page + 1)),
175 'title' => _('Previous Favorite Notices')));
179 * show the personal group nav
184 function showLocalNav()
186 $nav = new PersonalGroupNav($this);
191 * Show the replies feed links
196 function showExportData()
198 $feedurl = common_local_url('favoritesrss',
200 $this->user->nickname));
202 $fl = new FeedList($this);
206 $fl->show(array(0=>array('href'=> $feedurl,
208 'version' => 'RSS 1.0',
209 'item' => 'Favorites')));
215 * A list of notices that this user has marked as a favorite
220 function showContent()
222 $notice = $this->user->favoriteNotices(($this->page-1)*NOTICES_PER_PAGE,
223 NOTICES_PER_PAGE + 1);
226 $this->serverError(_('Could not retrieve favorite notices.'));
230 $nl = new NoticeList($notice, $this);
234 $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
235 $this->page, 'showfavorites',
236 array('nickname' => $this->user->nickname));