summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/action.php34
-rw-r--r--lib/feedlist.php156
-rw-r--r--lib/personal.php108
-rw-r--r--lib/publicgroupnav.php83
-rw-r--r--lib/stream.php26
-rw-r--r--lib/util.php35
6 files changed, 278 insertions, 164 deletions
diff --git a/lib/action.php b/lib/action.php
index 59cc173e7..95178c65e 100644
--- a/lib/action.php
+++ b/lib/action.php
@@ -553,4 +553,38 @@ class Action extends HTMLOutputter // lawsuit
common_element('a', $attrs, $text);
common_element_end('li');
}
+
+ // Does a little before-after block for next/prev page
+
+ function pagination($have_before, $have_after, $page, $action, $args=null)
+ {
+ if ($have_before || $have_after) {
+ $this->elementStart('div', array('id' => 'pagination'));
+ $this->elementStart('ul', array('id' => 'nav_pagination'));
+ }
+
+ if ($have_before) {
+ $pargs = array('page' => $page-1);
+ $newargs = ($args) ? array_merge($args,$pargs) : $pargs;
+
+ $this->elementStart('li', 'before');
+ $this->element('a', array('href' => common_local_url($action, $newargs), 'rel' => 'prev'),
+ _('« After'));
+ $this->elementEnd('li');
+ }
+
+ if ($have_after) {
+ $pargs = array('page' => $page+1);
+ $newargs = ($args) ? array_merge($args,$pargs) : $pargs;
+ $this->elementStart('li', 'after');
+ $this->element('a', array('href' => common_local_url($action, $newargs), 'rel' => 'next'),
+ _('Before »'));
+ $this->elementEnd('li');
+ }
+
+ if ($have_before || $have_after) {
+ $this->elementEnd('ul');
+ $this->elementEnd('div');
+ }
+ }
}
diff --git a/lib/feedlist.php b/lib/feedlist.php
new file mode 100644
index 000000000..0ff88cb25
--- /dev/null
+++ b/lib/feedlist.php
@@ -0,0 +1,156 @@
+<?php
+/**
+ * Laconica, the distributed open-source microblogging tool
+ *
+ * Widget for showing a list of feeds
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * 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 Widget
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @author Sarven Capadisli <csarven@controlyourself.ca>
+ * @copyright 2008 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);
+}
+
+/**
+ * Widget for showing a list of feeds
+ *
+ * Typically used for Action::showExportList()
+ *
+ * @category Widget
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @author Sarven Capadisli <csarven@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 Action::showExportList()
+ */
+
+class FeedList
+{
+ var $out = null;
+
+ function __construct($out=null)
+ {
+ $this->out = $out;
+ }
+
+ function show($feeds)
+ {
+ $this->out->elementStart('div', array('class' => 'feeds'));
+ $this->out->element('p', null, 'Feeds:');
+ $this->out->elementStart('ul', array('class' => 'xoxo'));
+
+ foreach ($feeds as $key => $value) {
+ $this->feedItem($feeds[$key]);
+ }
+
+ $this->out->elementEnd('ul');
+ $this->out->elementEnd('div');
+ }
+
+ function feedItem($feed)
+ {
+ $nickname = $this->trimmed('nickname');
+
+ switch($feed['item']) {
+ case 'notices': default:
+ $feed_classname = $feed['type'];
+ $feed_mimetype = "application/".$feed['type']."+xml";
+ $feed_title = "$nickname's ".$feed['version']." notice feed";
+ $feed['textContent'] = "RSS";
+ break;
+
+ case 'allrss':
+ $feed_classname = $feed['type'];
+ $feed_mimetype = "application/".$feed['type']."+xml";
+ $feed_title = $feed['version']." feed for $nickname and friends";
+ $feed['textContent'] = "RSS";
+ break;
+
+ case 'repliesrss':
+ $feed_classname = $feed['type'];
+ $feed_mimetype = "application/".$feed['type']."+xml";
+ $feed_title = $feed['version']." feed for replies to $nickname";
+ $feed['textContent'] = "RSS";
+ break;
+
+ case 'publicrss':
+ $feed_classname = $feed['type'];
+ $feed_mimetype = "application/".$feed['type']."+xml";
+ $feed_title = "Public timeline ".$feed['version']." feed";
+ $feed['textContent'] = "RSS";
+ break;
+
+ case 'publicatom':
+ $feed_classname = "atom";
+ $feed_mimetype = "application/".$feed['type']."+xml";
+ $feed_title = "Public timeline ".$feed['version']." feed";
+ $feed['textContent'] = "Atom";
+ break;
+
+ case 'tagrss':
+ $feed_classname = $feed['type'];
+ $feed_mimetype = "application/".$feed['type']."+xml";
+ $feed_title = $feed['version']." feed for this tag";
+ $feed['textContent'] = "RSS";
+ break;
+
+ case 'favoritedrss':
+ $feed_classname = $feed['type'];
+ $feed_mimetype = "application/".$feed['type']."+xml";
+ $feed_title = "Favorited ".$feed['version']." feed";
+ $feed['textContent'] = "RSS";
+ break;
+
+ case 'foaf':
+ $feed_classname = "foaf";
+ $feed_mimetype = "application/".$feed['type']."+xml";
+ $feed_title = "$nickname's FOAF file";
+ $feed['textContent'] = "FOAF";
+ break;
+
+ case 'favoritesrss':
+ $feed_classname = "favorites";
+ $feed_mimetype = "application/".$feed['type']."+xml";
+ $feed_title = "Feed for favorites of $nickname";
+ $feed['textContent'] = "RSS";
+ break;
+
+ case 'usertimeline':
+ $feed_classname = "atom";
+ $feed_mimetype = "application/".$feed['type']."+xml";
+ $feed_title = "$nickname's ".$feed['version']." notice feed";
+ $feed['textContent'] = "Atom";
+ break;
+ }
+ $this->out->elementStart('li');
+ $this->out->element('a', array('href' => $feed['href'],
+ 'class' => $feed_classname,
+ 'type' => $feed_mimetype,
+ 'title' => $feed_title),
+ $feed['textContent']);
+ $this->out->elementEnd('li');
+ }
+}
diff --git a/lib/personal.php b/lib/personal.php
index 02b01fece..4e56c9566 100644
--- a/lib/personal.php
+++ b/lib/personal.php
@@ -21,12 +21,12 @@ if (!defined('LACONICA')) { exit(1); }
class PersonalAction extends Action
{
-
+
function is_readonly()
{
return true;
}
-
+
function handle($args)
{
parent::handle($args);
@@ -69,11 +69,11 @@ class PersonalAction extends Action
_('Favorites'),
sprintf(_('%s\'s favorite notices'), ($user_profile) ? $user_profile->getBestName() : _('User')),
$action == 'showfavorites');
-
+
$cur = common_current_user();
-
+
if ($cur && $cur->id == $user->id) {
-
+
common_menu_item(common_local_url('inbox', array('nickname' =>
$nickname)),
_('Inbox'),
@@ -85,108 +85,10 @@ class PersonalAction extends Action
_('Your sent messages'),
$action == 'outbox');
}
-
- common_element_end('ul');
- }
- function show_feeds_list($feeds)
- {
- common_element_start('div', array('class' => 'feeds'));
- common_element('p', null, 'Feeds:');
- common_element_start('ul', array('class' => 'xoxo'));
-
- foreach ($feeds as $key => $value) {
- $this->common_feed_item($feeds[$key]);
- }
common_element_end('ul');
- common_element_end('div');
- }
-
- function common_feed_item($feed)
- {
- $nickname = $this->trimmed('nickname');
-
- switch($feed['item']) {
- case 'notices': default:
- $feed_classname = $feed['type'];
- $feed_mimetype = "application/".$feed['type']."+xml";
- $feed_title = "$nickname's ".$feed['version']." notice feed";
- $feed['textContent'] = "RSS";
- break;
-
- case 'allrss':
- $feed_classname = $feed['type'];
- $feed_mimetype = "application/".$feed['type']."+xml";
- $feed_title = $feed['version']." feed for $nickname and friends";
- $feed['textContent'] = "RSS";
- break;
-
- case 'repliesrss':
- $feed_classname = $feed['type'];
- $feed_mimetype = "application/".$feed['type']."+xml";
- $feed_title = $feed['version']." feed for replies to $nickname";
- $feed['textContent'] = "RSS";
- break;
-
- case 'publicrss':
- $feed_classname = $feed['type'];
- $feed_mimetype = "application/".$feed['type']."+xml";
- $feed_title = "Public timeline ".$feed['version']." feed";
- $feed['textContent'] = "RSS";
- break;
-
- case 'publicatom':
- $feed_classname = "atom";
- $feed_mimetype = "application/".$feed['type']."+xml";
- $feed_title = "Public timeline ".$feed['version']." feed";
- $feed['textContent'] = "Atom";
- break;
-
- case 'tagrss':
- $feed_classname = $feed['type'];
- $feed_mimetype = "application/".$feed['type']."+xml";
- $feed_title = $feed['version']." feed for this tag";
- $feed['textContent'] = "RSS";
- break;
-
- case 'favoritedrss':
- $feed_classname = $feed['type'];
- $feed_mimetype = "application/".$feed['type']."+xml";
- $feed_title = "Favorited ".$feed['version']." feed";
- $feed['textContent'] = "RSS";
- break;
-
- case 'foaf':
- $feed_classname = "foaf";
- $feed_mimetype = "application/".$feed['type']."+xml";
- $feed_title = "$nickname's FOAF file";
- $feed['textContent'] = "FOAF";
- break;
-
- case 'favoritesrss':
- $feed_classname = "favorites";
- $feed_mimetype = "application/".$feed['type']."+xml";
- $feed_title = "Feed for favorites of $nickname";
- $feed['textContent'] = "RSS";
- break;
-
- case 'usertimeline':
- $feed_classname = "atom";
- $feed_mimetype = "application/".$feed['type']."+xml";
- $feed_title = "$nickname's ".$feed['version']." notice feed";
- $feed['textContent'] = "Atom";
- break;
- }
- common_element_start('li');
- common_element('a', array('href' => $feed['href'],
- 'class' => $feed_classname,
- 'type' => $feed_mimetype,
- 'title' => $feed_title),
- $feed['textContent']);
- common_element_end('li');
}
-
function source_link($source)
{
$source_name = _($source);
diff --git a/lib/publicgroupnav.php b/lib/publicgroupnav.php
new file mode 100644
index 000000000..d21d0a458
--- /dev/null
+++ b/lib/publicgroupnav.php
@@ -0,0 +1,83 @@
+<?php
+/**
+ * Laconica, the distributed open-source microblogging tool
+ *
+ * Base class for all actions (~views)
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * 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 Action
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @author Sarven Capadisli <csarven@controlyourself.ca>
+ * @copyright 2008 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);
+}
+
+/**
+ * Base class for all actions
+ *
+ * This is the base class for all actions in the package. An action is
+ * more or less a "view" in an MVC framework.
+ *
+ * Actions are responsible for extracting and validating parameters; using
+ * model classes to read and write to the database; and doing ouput.
+ *
+ * @category Output
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @author Sarven Capadisli <csarven@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 HTMLOutputter
+ */
+
+class PublicGroupNav
+{
+ var $action = null;
+
+ function __construct($action=null)
+ {
+ $this->action = $action;
+ }
+
+ function show()
+ {
+ $this->action->elementStart('ul', array('id' => 'nav_views'));
+
+ common_menu_item(common_local_url('public'), _('Public'),
+ _('Public timeline'), $this->action == 'public');
+
+ common_menu_item(common_local_url('tag'), _('Recent tags'),
+ _('Recent tags'), $this->action == 'tag');
+
+ if (count(common_config('nickname', 'featured')) > 0) {
+ common_menu_item(common_local_url('featured'), _('Featured'),
+ _('Featured users'), $this->action == 'featured');
+ }
+
+ common_menu_item(common_local_url('favorited'), _('Popular'),
+ _("Popular notices"), $this->action == 'favorited');
+
+ common_element_end('ul');
+ }
+}
diff --git a/lib/stream.php b/lib/stream.php
index 73758adee..0cb9e0bf4 100644
--- a/lib/stream.php
+++ b/lib/stream.php
@@ -24,32 +24,6 @@ require_once(INSTALLDIR.'/lib/noticelist.php');
class StreamAction extends PersonalAction
{
-
- function public_views_menu()
- {
-
- $action = $this->trimmed('action');
-
- common_element_start('ul', array('id' => 'nav_views'));
-
- common_menu_item(common_local_url('public'), _('Public'),
- _('Public timeline'), $action == 'public');
-
- common_menu_item(common_local_url('tag'), _('Recent tags'),
- _('Recent tags'), $action == 'tag');
-
- if (count(common_config('nickname', 'featured')) > 0) {
- common_menu_item(common_local_url('featured'), _('Featured'),
- _('Featured users'), $action == 'featured');
- }
-
- common_menu_item(common_local_url('favorited'), _('Popular'),
- _("Popular notices"), $action == 'favorited');
-
- common_element_end('ul');
-
- }
-
function show_notice_list($notice)
{
$nl = new NoticeList($notice);
diff --git a/lib/util.php b/lib/util.php
index 009a0457c..a1e325204 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -1459,41 +1459,6 @@ function common_valid_tag($tag)
return false;
}
-// Does a little before-after block for next/prev page
-
-function common_pagination($have_before, $have_after, $page, $action, $args=null)
-{
-
- if ($have_before || $have_after) {
- common_element_start('div', array('id' => 'pagination'));
- common_element_start('ul', array('id' => 'nav_pagination'));
- }
-
- if ($have_before) {
- $pargs = array('page' => $page-1);
- $newargs = ($args) ? array_merge($args,$pargs) : $pargs;
-
- common_element_start('li', 'before');
- common_element('a', array('href' => common_local_url($action, $newargs), 'rel' => 'prev'),
- _('« After'));
- common_element_end('li');
- }
-
- if ($have_after) {
- $pargs = array('page' => $page+1);
- $newargs = ($args) ? array_merge($args,$pargs) : $pargs;
- common_element_start('li', 'after');
- common_element('a', array('href' => common_local_url($action, $newargs), 'rel' => 'next'),
- _('Before »'));
- common_element_end('li');
- }
-
- if ($have_before || $have_after) {
- common_element_end('ul');
- common_element_end('div');
- }
-}
-
/* Following functions are copied from MediaWiki GlobalFunctions.php
* and written by Evan Prodromou. */