+class ShowfavoritesAction extends Action
+{
+ /** User we're getting the faves of */
+ var $user = null;
+ /** Page of the faves we're on */
+ var $page = null;
+
+ /**
+ * Is this a read-only page?
+ *
+ * @return boolean true
+ */
+
+ function isReadOnly()
+ {
+ return true;
+ }
+
+ /**
+ * Title of the page
+ *
+ * Includes name of user and page number.
+ *
+ * @return string title of page
+ */
+
+ function title()
+ {
+ if ($this->page == 1) {
+ return sprintf(_("%s favorite notices"), $this->user->nickname);
+ } else {
+ return sprintf(_("%s favorite notices, page %d"),
+ $this->user->nickname,
+ $this->page);
+ }
+ }
+
+ /**
+ * Prepare the object
+ *
+ * Check the input values and initialize the object.
+ * Shows an error page on bad input.
+ *
+ * @param array $args $_REQUEST data
+ *
+ * @return boolean success flag
+ */
+
+ function prepare($args)
+ {
+ parent::prepare($args);
+
+ $nickname = common_canonical_nickname($this->arg('nickname'));
+
+ $this->user = User::staticGet('nickname', $nickname);
+
+ if (!$this->user) {
+ $this->clientError(_('No such user.'));
+ return false;
+ }
+
+ $this->page = $this->trimmed('page');
+
+ if (!$this->page) {
+ $this->page = 1;
+ }
+
+ common_set_returnto($this->selfUrl());
+
+ return true;
+ }
+
+ /**
+ * Handle a request
+ *
+ * Just show the page. All args already handled.
+ *
+ * @param array $args $_REQUEST data
+ *
+ * @return void
+ */
+
+ function handle($args)
+ {
+ parent::handle($args);
+ $this->showPage();
+ }
+
+ /**
+ * Feeds for the <head> section
+ *
+ * @return void
+ */
+
+ function showFeeds()
+ {
+ $feedurl = common_local_url('favoritesrss',
+ array('nickname' =>
+ $this->user->nickname));
+ $feedtitle = sprintf(_('Feed for favorites of %s'),
+ $this->user->nickname);
+
+ $this->element('link', array('rel' => 'alternate',
+ 'href' => $feedurl,
+ 'type' => 'application/rss+xml',
+ 'title' => $feedtitle));
+ }
+
+ /**
+ * show the personal group nav
+ *
+ * @return void
+ */
+
+ function showLocalNav()
+ {
+ $nav = new PersonalGroupNav($this);
+ $nav->show();
+ }
+
+ /**
+ * Show the replies feed links
+ *
+ * @return void
+ */
+
+ function showExportData()
+ {
+ $feedurl = common_local_url('favoritesrss',
+ array('nickname' =>
+ $this->user->nickname));
+
+ $fl = new FeedList($this);
+
+ // XXX: I18N
+
+ $fl->show(array(0=>array('href'=> $feedurl,
+ 'type' => 'rss',
+ 'version' => 'RSS 1.0',
+ 'item' => 'Favorites')));
+ }
+
+ /**
+ * Show the content
+ *
+ * A list of notices that this user has marked as a favorite
+ *
+ * @return void
+ */
+
+ function showContent()
+ {
+ $notice = $this->user->favoriteNotices(($this->page-1)*NOTICES_PER_PAGE,
+ NOTICES_PER_PAGE + 1);
+
+ if (!$notice) {
+ $this->serverError(_('Could not retrieve favorite notices.'));
+ return;
+ }
+
+ $nl = new NoticeList($notice, $this);
+
+ $cnt = $nl->show();
+
+ $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
+ $this->page, 'showfavorites',
+ array('nickname' => $this->user->nickname));
+ }