3 * Laconica - a distributed open-source microblogging tool
4 * Copyright (C) 2008, Controlez-Vous, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 if (!defined('LACONICA')) { exit(1); }
22 define('DEFAULT_RSS_LIMIT', 48);
24 class Rss10Action extends Action {
26 function handle($args) {
27 parent::handle($args);
28 $limit = (int) $this->trimmed('limit');
30 $limit = DEFAULT_RSS_LIMIT;
32 $this->show_rss($limit);
39 function get_notices() {
43 function get_channel() {
44 return array('url' => '',
50 function get_image() {
54 function show_rss($limit=0) {
60 $notices = $this->get_notices($limit);
63 $this->show_channel($notices);
66 foreach ($notices as $n) {
73 function show_channel($notices) {
76 $channel = $this->get_channel();
77 $image = $this->get_image();
79 common_element_start('channel', array('rdf:about' => $channel['url']));
80 common_element('title', NULL, $channel['title']);
81 common_element('link', NULL, $channel['link']);
82 common_element('description', NULL, $channel['description']);
83 common_element('cc:licence', array('rdf:resource' => $config['license']['url']));
86 common_element('image', array('rdf:resource' => $image));
89 common_element_start('items');
90 common_element_start('rdf:Seq');
92 foreach ($notices as $notice) {
93 common_element('rdf:li', array('rdf:resource' => $notice->uri));
96 common_element_end('rdf:Seq');
97 common_element_end('items');
99 common_element_end('channel');
102 function show_image() {
103 $image = $this->get_image();
105 $channel = $this->get_channel();
106 common_element_start('image', array('rdf:about' => $image));
107 common_element('title', NULL, $channel['title']);
108 common_element('link', NULL, $channel['link']);
109 common_element('url', NULL, $image);
110 common_element_end('image');
114 function show_item($notice) {
116 $profile = Profile::staticGet($notice->profile_id);
117 $nurl = common_local_url('shownotice', array('notice' => $notice->id));
118 common_element_start('item', array('rdf:about' => $notice->uri));
119 common_element('title', NULL, $profile->nickname."'s status on ".common_date_string($notice->created));
120 common_element('link', NULL, $nurl);
121 common_element('description', NULL, $notice->content);
122 common_element('dc:date', NULL, common_date_w3dtf($notice->created));
123 common_element('dc:creator', NULL, ($profile->fullname) ? $profile->fullname : $profile->nickname);
124 common_element('cc:licence', array('rdf:resource' => $config['license']['url']));
125 common_element_end('item');
128 function init_rss() {
129 header('Content-Type: application/rdf+xml');
132 common_element_start('rdf:RDF', array('xmlns:rdf' =>
133 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
135 'http://purl.org/dc/elements/1.1/',
137 'http://web.resource.org/cc/',
138 'xmlns' => 'http://purl.org/rss/1.0/'));
142 common_element_end('rdf:RDF');