X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fall.php;h=44e3fd2394be28d1ff6dfc1e5edf3b8b71dcf514;hb=4aedce6864eb27a0c37b3dcae22fee0aa16ae537;hp=038572ba80f12132013a6e44fadab25bbefed310;hpb=52600ce0b063e68e622b19699841e41b5ddbf2d1;p=quix0rs-gnu-social.git diff --git a/actions/all.php b/actions/all.php index 038572ba80..44e3fd2394 100644 --- a/actions/all.php +++ b/actions/all.php @@ -21,10 +21,56 @@ if (!defined('LACONICA')) { exit(1); } require_once(INSTALLDIR.'/actions/showstream.php'); -class AllAction extends ShowstreamAction { +class AllAction extends StreamAction { - // XXX: push this up to a common function. + function handle($args) { + parent::handle($args); + + $nickname = common_canonical_nickname($this->arg('nickname')); + $user = User::staticGet('nickname', $nickname); + + if (!$user) { + $this->no_such_user(); + return; + } + + $profile = $user->getProfile(); + + if (!$profile) { + common_server_error(_t('User record exists without profile.')); + return; + } + + # Looks like we're good; show the header + + common_show_header($profile->nickname . _t(" and friends"), + array($this, 'show_header'), $user, + array($this, 'show_top')); + + $this->show_notices($profile); + + common_show_footer(); + } + + function show_header($user) { + common_element('link', array('rel' => 'alternate', + 'href' => common_local_url('allrss', array('nickname' => + $user->nickname)), + 'type' => 'application/rss+xml', + 'title' => _t('Feed for friends of ') . $user->nickname)); + } + + function show_top($user) { + $cur = common_current_user(); + + if ($cur && $cur->id == $user->id) { + common_notice_form(); + } + + $this->views_menu(); + } + function show_notices($profile) { $notice = DB_DataObject::factory('notice'); @@ -36,20 +82,26 @@ class AllAction extends ShowstreamAction { $notice->orderBy('created DESC'); - $page = $this->arg('page') || 1; - - $notice->limit((($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE); + $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; - $notice->find(); + $notice->limit((($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1); - common_element_start('div', 'notices'); - common_element('h2', 'notices', _t('Notices')); + $cnt = $notice->find(); - while ($notice->fetch()) { - $this->show_notice($notice); + if ($cnt > 0) { + common_element_start('ul', array('id' => 'notices')); + for ($i = 0; $i < min($cnt, NOTICES_PER_PAGE); $i++) { + if ($notice->fetch()) { + $this->show_notice($notice); + } else { + // shouldn't happen! + break; + } + } + common_element_end('ul'); } - - # XXX: show a link for the next page - common_element_end('div'); + + common_pagination($page > 1, $cnt > NOTICES_PER_PAGE, + $page, 'all', array('nickname' => $profile->nickname)); } }