summaryrefslogtreecommitdiff
path: root/actions/public.php
diff options
context:
space:
mode:
authorEvan Prodromou <git@evanprodromou.name>2009-01-13 23:48:05 -0500
committerEvan Prodromou <git@evanprodromou.name>2009-01-13 23:48:05 -0500
commit0093b035c12bf21c88f57e4f0931b0abce214f43 (patch)
treed267714dbf4adeb6bfda538cd8595544daf3f171 /actions/public.php
parent93e249de2a28775e3a40e63324371fec359fb93b (diff)
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.
Diffstat (limited to 'actions/public.php')
-rw-r--r--actions/public.php197
1 files changed, 144 insertions, 53 deletions
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 @@
<?php
-/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, Controlez-Vous, Inc.
+/**
+ * Laconica, the distributed open-source microblogging tool
*
- * This program is free software: you can redistribute it and/or modify
+ * Action for displaying the public stream
+ *
+ * PHP version 5
+ *
+ * LICENCE: This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
@@ -15,81 +18,146 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Public
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @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 <evan@controlyourself.ca>
+ * @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 <head> 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 <meta> 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')));
}
}