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 class Rss10Action extends Action {
24 function handle($args) {
25 parent::handle($args);
27 $limit = (int) $this->trimmed('limit');
29 $this->show_rss($limit);
36 function get_notices() {
40 function get_channel() {
41 return array('url' => '',
47 function get_image() {
51 function show_rss($limit=0) {
57 $notices = $this->get_notices($limit);
60 $this->show_channel($notices);
63 foreach ($notices as $n) {
70 function show_channel($notices) {
73 $channel = $this->get_channel();
74 $image = $this->get_image();
76 common_element_start('channel', array('rdf:about' => $channel['url']));
77 common_element('title', NULL, $channel['title']);
78 common_element('link', NULL, $channel['link']);
79 common_element('description', NULL, $channel['description']);
80 common_element('cc:licence', array('rdf:resource' => $config['license']['url']));
83 common_element('image', array('rdf:resource' => $image));
86 common_element_start('items');
87 common_element_start('rdf:Seq');
89 foreach ($notices as $notice) {
90 common_element('rdf:li', array('rdf:resource' => $notice->uri));
93 common_element_end('rdf:Seq');
94 common_element_end('items');
96 common_element_end('channel');
99 function show_image() {
100 $image = $this->get_image();
102 $channel = $this->get_channel();
103 common_element_start('image', array('rdf:about' => $image));
104 common_element('title', NULL, $channel['title']);
105 common_element('link', NULL, $channel['link']);
106 common_element('url', NULL, $image);
107 common_element_end('image');
111 function show_item($notice) {
113 $profile = Profile::staticGet($notice->profile_id);
114 $nurl = common_local_url('shownotice', array('notice' => $notice->id));
115 common_element_start('item', array('rdf:about' => $notice->uri));
116 common_element('title', NULL, $profile->nickname."'s status on ".common_date_string($notice->created));
117 common_element('link', NULL, $nurl);
118 common_element('description', NULL, $notice->content);
119 common_element('dc:date', NULL, common_date_w3dtf($notice->created));
120 common_element('dc:creator', NULL, ($profile->fullname) ? $profile->fullname : $profile->nickname);
121 common_element('cc:licence', array('rdf:resource' => $config['license']['url']));
122 common_element_end('item');
125 function init_rss() {
126 header('Content-Type: application/rdf+xml');
129 common_element_start('rdf:RDF', array('xmlns:rdf' =>
130 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
132 'http://purl.org/dc/elements/1.1/',
134 'http://web.resource.org/cc/',
135 'xmlns' => 'http://purl.org/rss/1.0/'));
139 common_element_end('rdf:RDF');