Unify feeds definition in actions
I got a little sick of trying to keep the export data and <head> links synched in actions, so I made a common method, getFeeds(), which gets the feeds for both. It returns an array of Feed objects, which know about what their mime type is, title, location, all that jazz. I changed the FeedList class so it handles the new Feed objects instead of the old array of data. I changed all the actions that show feeds (I think...) so that they now use getFeeds() for all their feed needs.
This commit is contained in:
parent
ad65c447d5
commit
22b10399aa
@ -42,9 +42,9 @@ class AllAction extends Action
|
||||
if (!$this->page) {
|
||||
$this->page = 1;
|
||||
}
|
||||
|
||||
|
||||
common_set_returnto($this->selfUrl());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -69,13 +69,22 @@ class AllAction extends Action
|
||||
}
|
||||
}
|
||||
|
||||
function showFeeds()
|
||||
function getFeeds()
|
||||
{
|
||||
$this->element('link', array('rel' => 'alternate',
|
||||
'href' => common_local_url('allrss', array('nickname' =>
|
||||
$this->user->nickname)),
|
||||
'type' => 'application/rss+xml',
|
||||
'title' => sprintf(_('Feed for friends of %s'), $this->user->nickname)));
|
||||
return array(new Feed(Feed::RSS1,
|
||||
common_local_url('allrss', array('nickname' =>
|
||||
$this->user->nickname)),
|
||||
sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->user->nickname)),
|
||||
new Feed(Feed::RSS2,
|
||||
common_local_url('api', array('apiaction' => 'statuses',
|
||||
'method' => 'friends',
|
||||
'argument' => $this->user->nickname.'.rss')),
|
||||
sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->user->nickname)),
|
||||
new Feed(Feed::ATOM,
|
||||
common_local_url('api', array('apiaction' => 'statuses',
|
||||
'method' => 'friends',
|
||||
'argument' => $this->user->nickname.'.atom')),
|
||||
sprintf(_('Feed for friends of %s (Atom)'), $this->user->nickname)));
|
||||
}
|
||||
|
||||
function showLocalNav()
|
||||
@ -84,15 +93,6 @@ class AllAction extends Action
|
||||
$nav->show();
|
||||
}
|
||||
|
||||
function showExportData()
|
||||
{
|
||||
$fl = new FeedList($this);
|
||||
$fl->show(array(0=>array('href'=>common_local_url('allrss', array('nickname' => $this->user->nickname)),
|
||||
'type' => 'rss',
|
||||
'version' => 'RSS 1.0',
|
||||
'item' => 'allrss')));
|
||||
}
|
||||
|
||||
function showContent()
|
||||
{
|
||||
$notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
|
||||
@ -110,7 +110,7 @@ class AllAction extends Action
|
||||
$user =& common_current_user();
|
||||
if ($user && ($user->id == $this->user->id)) {
|
||||
$this->element('h1', NULL, _("You and friends"));
|
||||
} else {
|
||||
} else {
|
||||
$this->element('h1', NULL, sprintf(_('%s and friends'), $this->user->nickname));
|
||||
}
|
||||
}
|
||||
|
@ -57,11 +57,11 @@ class NoticesearchAction extends SearchAction
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get instructions
|
||||
*
|
||||
* @return string instruction text
|
||||
*
|
||||
* @return string instruction text
|
||||
*/
|
||||
function getInstructions()
|
||||
{
|
||||
@ -70,7 +70,7 @@ class NoticesearchAction extends SearchAction
|
||||
|
||||
/**
|
||||
* Get title
|
||||
*
|
||||
*
|
||||
* @return string title
|
||||
*/
|
||||
function title()
|
||||
@ -78,62 +78,20 @@ class NoticesearchAction extends SearchAction
|
||||
return _('Text search');
|
||||
}
|
||||
|
||||
|
||||
function showExportData()
|
||||
function getFeeds()
|
||||
{
|
||||
$q = $this->trimmed('q');
|
||||
|
||||
if (!$q) {
|
||||
return;
|
||||
}
|
||||
$fl = new FeedList($this);
|
||||
$fl->show(array(0 => array('href' => common_local_url('noticesearchrss', array('q' => $q)),
|
||||
'type' => 'rss',
|
||||
'version' => 'RSS 1.0',
|
||||
'item' => 'noticesearchrss')));
|
||||
}
|
||||
|
||||
|
||||
|
||||
function showFeeds()
|
||||
{
|
||||
$q = $this->trimmed('q');
|
||||
if (!$q) {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->element('link', array('rel' => 'alternate',
|
||||
'href' => common_local_url('noticesearchrss',
|
||||
array('q' => $q)),
|
||||
'type' => 'application/rss+xml',
|
||||
'title' => _('Search Stream Feed')));
|
||||
return array(new Feed(Feed::RSS1, common_local_url('noticesearchrss',
|
||||
array('q' => $q)),
|
||||
sprintf(_('Search results for "%s" on %s'),
|
||||
$q, common_config('site', 'name'))));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show header
|
||||
*
|
||||
* @param array $arr array containing the query
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function extraHead2()
|
||||
{
|
||||
$q = $this->trimmed('q');
|
||||
if ($q) {
|
||||
$this->element('link', array('rel' => 'alternate',
|
||||
'href' => common_local_url('noticesearchrss',
|
||||
array('q' => $q)),
|
||||
'type' => 'application/rss+xml',
|
||||
'title' => _('Search Stream Feed')));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Show results
|
||||
*
|
||||
|
@ -119,24 +119,20 @@ class PublicAction extends Action
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showFeeds()
|
||||
function getFeeds()
|
||||
{
|
||||
$this->element('link', array('rel' => 'alternate',
|
||||
'href' => common_local_url('publicrss'),
|
||||
'type' => 'application/rdf+xml',
|
||||
'title' => _('Public Stream Feed (RSS 1.0)')));
|
||||
$this->element('link', array('rel' => 'alternate',
|
||||
'href' => common_local_url('api',
|
||||
array('apiaction' => 'statuses',
|
||||
'method' => 'public_timeline.rss')),
|
||||
'type' => 'application/rss+xml',
|
||||
'title' => _('Public Stream Feed (RSS 2.0)')));
|
||||
$this->element('link', array('rel' => 'alternate',
|
||||
'href' => common_local_url('api',
|
||||
array('apiaction' => 'statuses',
|
||||
'method' => 'public_timeline.atom')),
|
||||
'type' => 'application/atom+xml',
|
||||
'title' => _('Public Stream Feed (Atom)')));
|
||||
return array(new Feed(Feed::RSS1, common_local_url('publicrss'),
|
||||
_('Public Stream Feed (RSS 1.0)')),
|
||||
new Feed(Feed::RSS2,
|
||||
common_local_url('api',
|
||||
array('apiaction' => 'statuses',
|
||||
'method' => 'public_timeline.rss')),
|
||||
_('Public Stream Feed (RSS 2.0)')),
|
||||
new Feed(Feed::ATOM,
|
||||
common_local_url('api',
|
||||
array('apiaction' => 'statuses',
|
||||
'method' => 'public_timeline.atom')),
|
||||
_('Public Stream Feed (Atom)')));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -197,29 +193,6 @@ class PublicAction extends Action
|
||||
$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('api',
|
||||
array('apiaction' => 'statuses',
|
||||
'method' => 'public_timeline.atom')),
|
||||
'type' => 'atom',
|
||||
'version' => 'Atom 1.0',
|
||||
'item' => 'publicatom')));
|
||||
}
|
||||
|
||||
function showSections()
|
||||
{
|
||||
// $top = new TopPostersSection($this);
|
||||
|
@ -84,7 +84,7 @@ class RepliesAction extends Action
|
||||
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
||||
|
||||
common_set_returnto($this->selfUrl());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -129,16 +129,13 @@ class RepliesAction extends Action
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showFeeds()
|
||||
function getFeeds()
|
||||
{
|
||||
$rssurl = common_local_url('repliesrss',
|
||||
array('nickname' => $this->user->nickname));
|
||||
$rsstitle = sprintf(_('Feed for replies to %s'), $this->user->nickname);
|
||||
|
||||
$this->element('link', array('rel' => 'alternate',
|
||||
'href' => $rssurl,
|
||||
'type' => 'application/rss+xml',
|
||||
'title' => $rsstitle));
|
||||
return array(new Feed(Feed::RSS1, $rssurl, $rsstitle));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -153,25 +150,6 @@ class RepliesAction extends Action
|
||||
$nav->show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the replies feed links
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showExportData()
|
||||
{
|
||||
$fl = new FeedList($this);
|
||||
|
||||
$rssurl = common_local_url('repliesrss',
|
||||
array('nickname' => $this->user->nickname));
|
||||
|
||||
$fl->show(array(0=>array('href'=> $rssurl,
|
||||
'type' => 'rss',
|
||||
'version' => 'RSS 1.0',
|
||||
'item' => 'repliesrss')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the content
|
||||
*
|
||||
|
@ -113,7 +113,7 @@ class ShowfavoritesAction extends Action
|
||||
}
|
||||
|
||||
common_set_returnto($this->selfUrl());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -136,10 +136,10 @@ class ShowfavoritesAction extends Action
|
||||
/**
|
||||
* Feeds for the <head> section
|
||||
*
|
||||
* @return void
|
||||
* @return array Feed objects to show
|
||||
*/
|
||||
|
||||
function showFeeds()
|
||||
function getFeeds()
|
||||
{
|
||||
$feedurl = common_local_url('favoritesrss',
|
||||
array('nickname' =>
|
||||
@ -147,10 +147,7 @@ class ShowfavoritesAction extends Action
|
||||
$feedtitle = sprintf(_('Feed for favorites of %s'),
|
||||
$this->user->nickname);
|
||||
|
||||
$this->element('link', array('rel' => 'alternate',
|
||||
'href' => $feedurl,
|
||||
'type' => 'application/rss+xml',
|
||||
'title' => $feedtitle));
|
||||
return array(new Feed(Feed::RSS1, $feedurl, $feedtitle));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,28 +162,6 @@ class ShowfavoritesAction extends Action
|
||||
$nav->show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the replies feed links
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showExportData()
|
||||
{
|
||||
$feedurl = common_local_url('favoritesrss',
|
||||
array('nickname' =>
|
||||
$this->user->nickname));
|
||||
|
||||
$fl = new FeedList($this);
|
||||
|
||||
// XXX: I18N
|
||||
|
||||
$fl->show(array(0=>array('href'=> $feedurl,
|
||||
'type' => 'rss',
|
||||
'version' => 'RSS 1.0',
|
||||
'item' => 'Favorites')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the content
|
||||
*
|
||||
|
@ -292,37 +292,18 @@ class ShowgroupAction extends Action
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a list of links to feeds this page produces
|
||||
* Get a list of the feeds for this page
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showExportData()
|
||||
{
|
||||
$fl = new FeedList($this);
|
||||
$fl->show(array(0=>array('href'=>common_local_url('grouprss',
|
||||
array('nickname' => $this->group->nickname)),
|
||||
'type' => 'rss',
|
||||
'version' => 'RSS 1.0',
|
||||
'item' => 'notices')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a list of links to feeds this page produces
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showFeeds()
|
||||
function getFeeds()
|
||||
{
|
||||
$url =
|
||||
common_local_url('grouprss',
|
||||
array('nickname' => $this->group->nickname));
|
||||
|
||||
$this->element('link', array('rel' => 'alternate',
|
||||
'href' => $url,
|
||||
'type' => 'application/rss+xml',
|
||||
'title' => sprintf(_('Notice feed for %s group'),
|
||||
return array(new Feed(Feed::RSS1, $url, sprintf(_('Notice feed for %s group'),
|
||||
$this->group->nickname)));
|
||||
}
|
||||
|
||||
|
@ -155,54 +155,35 @@ class ShowstreamAction extends Action
|
||||
return;
|
||||
}
|
||||
|
||||
function showExportData()
|
||||
function getFeeds()
|
||||
{
|
||||
$fl = new FeedList($this);
|
||||
$fl->show(array(0=>array('href'=>common_local_url('userrss',
|
||||
array('nickname' => $this->user->nickname)),
|
||||
'type' => 'rss',
|
||||
'version' => 'RSS 1.0',
|
||||
'item' => 'notices'),
|
||||
1=>array('href'=>common_local_url('usertimeline',
|
||||
array('nickname' => $this->user->nickname)),
|
||||
'type' => 'atom',
|
||||
'version' => 'Atom 1.0',
|
||||
'item' => 'usertimeline'),
|
||||
2=>array('href'=>common_local_url('foaf',
|
||||
array('nickname' => $this->user->nickname)),
|
||||
'type' => 'rdf',
|
||||
'version' => 'FOAF',
|
||||
'item' => 'foaf')));
|
||||
}
|
||||
|
||||
function showFeeds()
|
||||
{
|
||||
$this->element('link', array('rel' => 'alternate',
|
||||
'type' => 'application/rss+xml',
|
||||
'href' => common_local_url('userrss',
|
||||
array('nickname' => $this->user->nickname)),
|
||||
'title' => sprintf(_('Notice feed for %s (RSS)'),
|
||||
$this->user->nickname)));
|
||||
|
||||
$this->element('link',
|
||||
array('rel' => 'alternate',
|
||||
'href' => common_local_url('api',
|
||||
array('apiaction' => 'statuses',
|
||||
'method' => 'user_timeline.atom',
|
||||
'argument' => $this->user->nickname)),
|
||||
'type' => 'application/atom+xml',
|
||||
'title' => sprintf(_('Notice feed for %s (Atom)'),
|
||||
$this->user->nickname)));
|
||||
return array(new Feed(Feed::RSS1,
|
||||
common_local_url('userrss',
|
||||
array('nickname' => $this->user->nickname)),
|
||||
sprintf(_('Notice feed for %s (RSS 1.0)'),
|
||||
$this->user->nickname)),
|
||||
new Feed(Feed::RSS2,
|
||||
common_local_url('api',
|
||||
array('apiaction' => 'statuses',
|
||||
'method' => 'user_timeline',
|
||||
'argument' => $this->user->nickname.'.rss')),
|
||||
sprintf(_('Notice feed for %s (RSS 2.0)'),
|
||||
$this->user->nickname)),
|
||||
new Feed(Feed::ATOM,
|
||||
common_local_url('api',
|
||||
array('apiaction' => 'statuses',
|
||||
'method' => 'user_timeline',
|
||||
'argument' => $this->user->nickname.'.atom')),
|
||||
sprintf(_('Notice feed for %s (Atom)'),
|
||||
$this->user->nickname)),
|
||||
new Feed(Feed::FOAF,
|
||||
common_local_url('foaf', array('nickname' =>
|
||||
$this->user->nickname)),
|
||||
sprintf(_('FOAF for %s'), $this->user->nickname)));
|
||||
}
|
||||
|
||||
function extraHead()
|
||||
{
|
||||
// FOAF
|
||||
$this->element('link', array('rel' => 'meta',
|
||||
'href' => common_local_url('foaf', array('nickname' =>
|
||||
$this->user->nickname)),
|
||||
'type' => 'application/rdf+xml',
|
||||
'title' => 'FOAF'));
|
||||
// for remote subscriptions etc.
|
||||
$this->element('meta', array('http-equiv' => 'X-XRDS-Location',
|
||||
'content' => common_local_url('xrds', array('nickname' =>
|
||||
|
@ -37,9 +37,9 @@ class TagAction extends Action
|
||||
}
|
||||
|
||||
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
|
||||
|
||||
|
||||
common_set_returnto($this->selfUrl());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -61,12 +61,11 @@ class TagAction extends Action
|
||||
$this->showPage();
|
||||
}
|
||||
|
||||
function showFeeds()
|
||||
function getFeeds()
|
||||
{
|
||||
$this->element('link', array('rel' => 'alternate',
|
||||
'href' => common_local_url('tagrss', array('tag' => $this->tag)),
|
||||
'type' => 'application/rss+xml',
|
||||
'title' => sprintf(_('Feed for tag %s'), $this->tag)));
|
||||
return array(new Feed(Feed::RSS1,
|
||||
common_local_url('tagrss', array('tag' => $this->tag)),
|
||||
sprintf(_('Feed for tag %s'), $this->tag)));
|
||||
}
|
||||
|
||||
function showPageNotice()
|
||||
@ -74,15 +73,6 @@ class TagAction extends Action
|
||||
return sprintf(_('Messages tagged "%s", most recent first'), $this->tag);
|
||||
}
|
||||
|
||||
function showExportData()
|
||||
{
|
||||
$fl = new FeedList($this);
|
||||
$fl->show(array(0=>array('href'=>common_local_url('tagrss', array('tag' => $this->tag)),
|
||||
'type' => 'rss',
|
||||
'version' => 'RSS 1.0',
|
||||
'item' => 'tagrss')));
|
||||
}
|
||||
|
||||
function showContent()
|
||||
{
|
||||
$notice = Notice_tag::getStream($this->tag, (($this->page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
|
||||
|
@ -225,9 +225,19 @@ class Action extends HTMLOutputter // lawsuit
|
||||
*
|
||||
* @return nothing
|
||||
*/
|
||||
|
||||
function showFeeds()
|
||||
{
|
||||
// does nothing by default
|
||||
$feeds = $this->getFeeds();
|
||||
|
||||
if ($feeds) {
|
||||
foreach ($feeds as $feed) {
|
||||
$this->element('link', array('rel' => $feed->rel(),
|
||||
'href' => $feed->url,
|
||||
'type' => $feed->mimeType(),
|
||||
'title' => $feed->title));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -540,15 +550,16 @@ class Action extends HTMLOutputter // lawsuit
|
||||
/**
|
||||
* Show export data feeds.
|
||||
*
|
||||
* MAY overload if there are feeds
|
||||
*
|
||||
* @return nothing
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function showExportData()
|
||||
{
|
||||
// is there structure to this?
|
||||
// list of (visible!) feed links
|
||||
// can we reuse list of feeds from showFeeds() ?
|
||||
$feeds = $this->getFeeds();
|
||||
if ($feeds) {
|
||||
$fl = new FeedList($this);
|
||||
$fl->show($feeds);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -924,4 +935,17 @@ class Action extends HTMLOutputter // lawsuit
|
||||
$this->elementEnd('div');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An array of feeds for this action.
|
||||
*
|
||||
* Returns an array of potential feeds for this action.
|
||||
*
|
||||
* @return array Feed object to show in head and links
|
||||
*/
|
||||
|
||||
function getFeeds()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
110
lib/feed.php
Normal file
110
lib/feed.php
Normal file
@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/**
|
||||
* Laconica, the distributed open-source microblogging tool
|
||||
*
|
||||
* Data structure for info about syndication feeds (RSS 1.0, RSS 2.0, Atom)
|
||||
*
|
||||
* 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 Feed
|
||||
* @package Laconica
|
||||
* @author Evan Prodromou <evan@controlyourself.ca>
|
||||
* @copyright 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Data structure for feeds
|
||||
*
|
||||
* This structure is a helpful container for shipping around information about syndication feeds.
|
||||
*
|
||||
* @category Feed
|
||||
* @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/
|
||||
*/
|
||||
|
||||
class Feed
|
||||
{
|
||||
const RSS1 = 1;
|
||||
const RSS2 = 2;
|
||||
const ATOM = 3;
|
||||
const FOAF = 4;
|
||||
|
||||
var $type = null;
|
||||
var $url = null;
|
||||
var $title = null;
|
||||
|
||||
function __construct($type, $url, $title)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->url = $url;
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
function mimeType()
|
||||
{
|
||||
switch ($this->type) {
|
||||
case Feed::RSS1:
|
||||
return 'application/rdf+xml';
|
||||
case Feed::RSS2:
|
||||
return 'application/rss+xml';
|
||||
case Feed::ATOM:
|
||||
return 'application/atom+xml';
|
||||
case Feed::FOAF:
|
||||
return 'application/rdf+xml';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function typeName()
|
||||
{
|
||||
switch ($this->type) {
|
||||
case Feed::RSS1:
|
||||
return _('RSS 1.0');
|
||||
case Feed::RSS2:
|
||||
return _('RSS 2.0');
|
||||
case Feed::ATOM:
|
||||
return _('Atom');
|
||||
case Feed::FOAF:
|
||||
return _('FOAF');
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function rel()
|
||||
{
|
||||
switch ($this->type) {
|
||||
case Feed::RSS1:
|
||||
case Feed::RSS2:
|
||||
case Feed::ATOM:
|
||||
return 'alternate';
|
||||
case Feed::FOAF:
|
||||
return 'meta';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
101
lib/feedlist.php
101
lib/feedlist.php
@ -50,7 +50,7 @@ if (!defined('LACONICA')) {
|
||||
class FeedList extends Widget
|
||||
{
|
||||
var $action = null;
|
||||
|
||||
|
||||
function __construct($action=null)
|
||||
{
|
||||
parent::__construct($action);
|
||||
@ -64,8 +64,8 @@ class FeedList extends Widget
|
||||
$this->out->element('h2', null, _('Export data'));
|
||||
$this->out->elementStart('ul', array('class' => 'xoxo'));
|
||||
|
||||
foreach ($feeds as $key => $value) {
|
||||
$this->feedItem($feeds[$key]);
|
||||
foreach ($feeds as $feed) {
|
||||
$this->feedItem($feed);
|
||||
}
|
||||
|
||||
$this->out->elementEnd('ul');
|
||||
@ -74,92 +74,27 @@ class FeedList extends Widget
|
||||
|
||||
function feedItem($feed)
|
||||
{
|
||||
$nickname = $this->action->trimmed('nickname');
|
||||
$classname = null;
|
||||
|
||||
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";
|
||||
switch ($feed->type) {
|
||||
case Feed::RSS1:
|
||||
case Feed::RSS2:
|
||||
$classname = '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";
|
||||
case Feed::ATOM:
|
||||
$classname = 'atom';
|
||||
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 'noticesearchrss':
|
||||
$feed_classname = $feed['type'];
|
||||
$feed_mimetype = "application/".$feed['type']."+xml";
|
||||
$feed_title = $feed['version']." feed for this notice search";
|
||||
$feed['textContent'] = "RSS";
|
||||
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";
|
||||
case Feed::FOAF:
|
||||
$classname = 'foaf';
|
||||
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->element('a', array('href' => $feed->url,
|
||||
'class' => $classname,
|
||||
'type' => $feed->mimeType(),
|
||||
'title' => $feed->title),
|
||||
$feed->typeName());
|
||||
$this->out->elementEnd('li');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user