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-2011 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('GNUSOCIAL')) { exit(1); }
37 * @author Evan Prodromou <evan@status.net>
38 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
39 * @link http://status.net/
41 class ShowfavoritesAction extends ShowstreamAction
45 if ($this->page == 1) {
46 // TRANS: Title for first page of favourite notices of a user.
47 // TRANS: %s is the user for whom the favourite notices are displayed.
48 return sprintf(_('%s\'s favorite notices'), $this->getTarget()->getNickname());
50 // TRANS: Title for all but the first page of favourite notices of a user.
51 // TRANS: %1$s is the user for whom the favourite notices are displayed, %2$d is the page number.
52 return sprintf(_('%1$s\'s favorite notices, page %2$d'),
53 $this->getTarget()->getNickname(),
58 public function getStream()
60 return new FaveNoticeStream($this->getTarget(), $this->scoped);
65 return array(new Feed(Feed::JSON,
66 common_local_url('ApiTimelineFavorites',
68 'id' => $this->getTarget()->getNickname(),
70 // TRANS: Feed link text. %s is a username.
71 sprintf(_('Feed for favorites of %s (Activity Streams JSON)'),
72 $this->getTarget()->getNickname())),
74 common_local_url('favoritesrss',
75 array('nickname' => $this->getTarget()->getNickname())),
76 // TRANS: Feed link text. %s is a username.
77 sprintf(_('Feed for favorites of %s (RSS 1.0)'),
78 $this->getTarget()->getNickname())),
80 common_local_url('ApiTimelineFavorites',
82 'id' => $this->getTarget()->getNickname(),
84 // TRANS: Feed link text. %s is a username.
85 sprintf(_('Feed for favorites of %s (RSS 2.0)'),
86 $this->getTarget()->getNickname())),
88 common_local_url('ApiTimelineFavorites',
90 'id' => $this->getTarget()->getNickname(),
92 // TRANS: Feed link text. %s is a username.
93 sprintf(_('Feed for favorites of %s (Atom)'),
94 $this->getTarget()->getNickname())));
97 function showEmptyListMessage()
99 if (common_logged_in()) {
100 if ($this->getTarget()->sameAs($this->getScoped())) {
101 // TRANS: Text displayed instead of favourite notices for the current logged in user that has no favourites.
102 $message = _('You haven\'t chosen any favorite notices yet. Click the fave button on notices you like to bookmark them for later or shed a spotlight on them.');
104 // TRANS: Text displayed instead of favourite notices for a user that has no favourites while logged in.
105 // TRANS: %s is a username.
106 $message = sprintf(_('%s hasn\'t added any favorite notices yet. Post something interesting they would add to their favorites :)'), $this->getTarget()->getNickname());
110 // TRANS: Text displayed instead of favourite notices for a user that has no favourites while not logged in.
111 // TRANS: %s is a username, %%%%action.register%%%% is a link to the user registration page.
112 // TRANS: (link text)[link] is a Mark Down link.
113 $message = sprintf(_('%s hasn\'t added any favorite notices yet. Why not [register an account](%%%%action.register%%%%) and then post something interesting they would add to their favorites :)'), $this->getTarget()->getNickname());
116 $this->elementStart('div', 'guide');
117 $this->raw(common_markup_to_html($message));
118 $this->elementEnd('div');
124 * A list of notices that this user has marked as a favorite
128 function showNotices()
130 $nl = new FavoritesNoticeList($this->notice, $this);
134 $this->showEmptyListMessage();
137 $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
138 $this->page, 'showfavorites',
139 array('nickname' => $this->getTarget()->getNickname()));
142 function showPageNotice() {
143 // TRANS: Page notice for show favourites page.
144 $this->element('p', 'instructions', _('This is a way to share what you like.'));
148 class FavoritesNoticeList extends NoticeList
150 function newListItem($notice)
152 return new FavoritesNoticeListItem($notice, $this->out);
156 // All handled by superclass
157 class FavoritesNoticeListItem extends DoFollowListItem