123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class BookmarksAction extends Action
- {
- var $user = null;
- var $gc = null;
-
- function prepare(array $args = array())
- {
- parent::prepare($args);
- if (common_config('singleuser', 'enabled')) {
- $nickname = User::singleUserNickname();
- } else {
-
-
-
- $nickname = $this->returnToArgs();
- $nickname = $nickname[1]['nickname'];
- }
-
- $this->user = User::getKV('nickname', $nickname);
- if (!$this->user) {
-
- $this->clientError(_('No such user.'));
- }
- $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
- $stream = new BookmarksNoticeStream($this->user->id, true);
- $this->notices = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
- NOTICES_PER_PAGE + 1);
- if($this->page > 1 && $this->notices->N == 0) {
- throw new ClientException(_('No such page.'), 404);
- }
- return true;
- }
-
- function handle()
- {
- parent::handle();
- $this->showPage();
- }
-
- function title()
- {
- if (empty($this->user)) {
-
- return _m('Log in');
- } else {
-
- return sprintf(_m('%s\'s bookmarks'), $this->user->nickname);
- }
- }
-
- function getFeeds()
- {
- return array(new Feed(Feed::JSON,
- common_local_url('ApiTimelineBookmarks',
- array(
- 'id' => $this->user->nickname,
- 'format' => 'as')),
-
- sprintf(_('Feed for bookmarks of %s (Activity Streams JSON)'),
- $this->user->nickname)),
- new Feed(Feed::RSS1,
- common_local_url('bookmarksrss',
- array('nickname' => $this->user->nickname)),
-
- sprintf(_('Feed for bookmarks of %s (RSS 1.0)'),
- $this->user->nickname)),
- new Feed(Feed::RSS2,
- common_local_url('ApiTimelineBookmarks',
- array(
- 'id' => $this->user->nickname,
- 'format' => 'rss')),
-
- sprintf(_('Feed for bookmarks of %s (RSS 2.0)'),
- $this->user->nickname)),
- new Feed(Feed::ATOM,
- common_local_url('ApiTimelineBookmarks',
- array(
- 'id' => $this->user->nickname,
- 'format' => 'atom')),
-
- sprintf(_('Feed for bookmarks of %s (Atom)'),
- $this->user->nickname)));
- }
-
- function showContent()
- {
- $nl = new NoticeList($this->notices, $this);
- $cnt = $nl->show();
- if ($cnt == 0) {
- $this->showEmptyList();
- }
- $this->pagination($this->page > 1,
- $cnt > NOTICES_PER_PAGE,
- $this->page, 'bookmarks',
- array('nickname' => $this->user->nickname));
- }
- function showEmptyList() {
- $message = sprintf(_('This is %1$s\'s bookmark stream, but %1$s hasn\'t bookmarked anything yet.'), $this->user->nickname) . ' ';
- $this->elementStart('div', 'guide');
- $this->raw(common_markup_to_html($message));
- $this->elementEnd('div');
- }
-
- function isReadOnly($args)
- {
- return true;
- }
- }
|