]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/feed.php
Merge branch '0.9.x' into twitstream
[quix0rs-gnu-social.git] / lib / feed.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * Data structure for info about syndication feeds (RSS 1.0, RSS 2.0, Atom)
6  *
7  * PHP version 5
8  *
9  * LICENCE: This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Affero General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Affero General Public License for more details.
18  *
19  * You should have received a copy of the GNU Affero General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  * @category  Feed
23  * @package   StatusNet
24  * @author    Evan Prodromou <evan@status.net>
25  * @copyright 2009 StatusNet, Inc.
26  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27  * @link      http://status.net/
28  */
29
30 if (!defined('STATUSNET') && !defined('LACONICA')) {
31     exit(1);
32 }
33
34 /**
35  * Data structure for feeds
36  *
37  * This structure is a helpful container for shipping around information about syndication feeds.
38  *
39  * @category Feed
40  * @package  StatusNet
41  * @author   Evan Prodromou <evan@status.net>
42  * @author   Sarven Capadisli <csarven@status.net>
43  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
44  * @link     http://status.net/
45  */
46 class Feed
47 {
48     const RSS1 = 1;
49     const RSS2 = 2;
50     const ATOM = 3;
51     const FOAF = 4;
52
53     var $type = null;
54     var $url = null;
55     var $title = null;
56
57     function __construct($type, $url, $title)
58     {
59         $this->type  = $type;
60         $this->url   = $url;
61         $this->title = $title;
62     }
63
64     function mimeType()
65     {
66         switch ($this->type) {
67          case Feed::RSS1:
68             return 'application/rdf+xml';
69          case Feed::RSS2:
70             return 'application/rss+xml';
71          case Feed::ATOM:
72             return 'application/atom+xml';
73          case Feed::FOAF:
74             return 'application/rdf+xml';
75          default:
76             return null;
77         }
78     }
79
80     function typeName()
81     {
82         switch ($this->type) {
83          case Feed::RSS1:
84             return _('RSS 1.0');
85          case Feed::RSS2:
86             return _('RSS 2.0');
87          case Feed::ATOM:
88             return _('Atom');
89          case Feed::FOAF:
90             return _('FOAF');
91          default:
92             return null;
93         }
94     }
95
96     function rel()
97     {
98         switch ($this->type) {
99          case Feed::RSS1:
100          case Feed::RSS2:
101          case Feed::ATOM:
102             return 'alternate';
103          case Feed::FOAF:
104             return 'meta';
105          default:
106             return null;
107         }
108     }
109 }