From 0093b035c12bf21c88f57e4f0931b0abce214f43 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 13 Jan 2009 23:48:05 -0500 Subject: Modify public stream to use new UI framework I modified public.php to use the new UI framework. Since the Action class isn't functional yet, I don't know if it works. I took some of the functionality, like the public tabs nav and the feeds list, and made them widgets. I also moved the navigation from common_navigation() to a method of Action. --- actions/public.php | 197 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 144 insertions(+), 53 deletions(-) (limited to 'actions/public.php') diff --git a/actions/public.php b/actions/public.php index 039e885e6..e00f8efba 100644 --- a/actions/public.php +++ b/actions/public.php @@ -1,9 +1,12 @@ . + * + * @category Public + * @package Laconica + * @author Evan Prodromou + * @copyright 2008-2009 Control Yourself, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} -require_once(INSTALLDIR.'/lib/stream.php'); +/** + * Action for displaying the public stream + * + * @category Public + * @package Laconica + * @author Evan Prodromou + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + * + * @see PublicrssAction + * @see PublicxrdsAction + */ -class PublicAction extends StreamAction +class PublicAction extends Action { + /** + * page of the stream we're on; default = 1 + */ - function handle($args) - { - parent::handle($args); + var $page = null; - $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; + /** + * Read and validate arguments + * + * @param array $args URL parameters + * + * @return boolean success value + */ - header('X-XRDS-Location: '. common_local_url('publicxrds')); + function prepare($args) + { + parent::prepare($args); + $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; + return true; + } - common_show_header(_('Public timeline'), - array($this, 'show_header'), null, - array($this, 'show_top')); + /** + * handle request + * + * Show the public stream, using recipe method showPage() + * + * @param array $args arguments, mostly unused + * + * @return void + */ - # XXX: Public sidebar here? + function handle($args) + { + parent::handle($args); - $this->show_notices($page); + header('X-XRDS-Location: '. common_local_url('publicxrds')); - common_show_footer(); + $this->showPage(); } - function show_top() + /** + * Title of the page + * + * @return page title, including page number if over 1 + */ + + function title() { - if (common_logged_in()) { - common_notice_form('public'); + if ($this->page > 1) { + return sprintf(_('Public timeline, page %d'), $this->page); } else { - $instr = $this->get_instructions(); - $output = common_markup_to_html($instr); - common_element_start('div', 'instructions'); - common_raw($output); - common_element_end('div'); + return _('Public timeline'); } - - $this->public_views_menu(); - - $this->show_feeds_list(array(0=>array('href'=>common_local_url('publicrss'), - 'type' => 'rss', - 'version' => 'RSS 1.0', - 'item' => 'publicrss'), - 1=>array('href'=>common_local_url('publicatom'), - 'type' => 'atom', - 'version' => 'Atom 1.0', - 'item' => 'publicatom'))); } - function get_instructions() - { - return _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' . - 'based on the Free Software [Laconica](http://laconi.ca/) tool. ' . - '[Join now](%%action.register%%) to share notices about yourself with friends, family, and colleagues! ([Read more](%%doc.help%%))'); - } + /** + * Output elements for RSS and Atom feeds + * + * @return void + */ - function show_header() + function showFeeds() { - common_element('link', array('rel' => 'alternate', + $this->element('link', array('rel' => 'alternate', 'href' => common_local_url('publicrss'), 'type' => 'application/rss+xml', 'title' => _('Public Stream Feed'))); - # for client side of OpenID authentication - common_element('meta', array('http-equiv' => 'X-XRDS-Location', + } + + /** + * Extra head elements + * + * We include a element linking to the publicxrds page, for OpenID + * client-side authentication. + * + * @return void + */ + + function extraHead() + { + // for client side of OpenID authentication + $this->element('meta', array('http-equiv' => 'X-XRDS-Location', 'content' => common_local_url('publicxrds'))); } - function show_notices($page) + /** + * Show tabset for this page + * + * Uses the PublicGroupNav widget + * + * @return void + * @see PublicGroupNav + */ + + function showLocalNav() { + $nav = new PublicGroupNav($this); + $nav->show(); + } + + /** + * Fill the content area + * + * Shows a list of the notices in the public stream, with some pagination + * controls. + * + * @return void + */ - $cnt = 0; - $notice = Notice::publicStream(($page-1)*NOTICES_PER_PAGE, + function showContent() + { + $notice = Notice::publicStream(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); if (!$notice) { @@ -97,9 +165,32 @@ class PublicAction extends StreamAction return; } - $cnt = $this->show_notice_list($notice); + $nl = new NoticeList($notice); + + $cnt = $nl->show(); - common_pagination($page > 1, $cnt > NOTICES_PER_PAGE, - $page, 'public'); + $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, + $this->page, 'public'); + } + + /** + * Makes a list of exported feeds for this page + * + * @return void + * + * @todo I18N + */ + + function showExportData() + { + $fl = new FeedList($this); + $fl->show(array(0 => array('href' => common_local_url('publicrss'), + 'type' => 'rss', + 'version' => 'RSS 1.0', + 'item' => 'publicrss'), + 1 => array('href' => common_local_url('publicatom'), + 'type' => 'atom', + 'version' => 'Atom 1.0', + 'item' => 'publicatom'))); } } -- cgit v1.2.3-54-g00ecf