]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/feed.php
*** Privacy Leak fixed: ***
[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     const JSON = 5; // Activity Streams
53
54     var $type = null;
55     var $url = null;
56     var $title = null;
57
58     function __construct($type, $url, $title)
59     {
60         $this->type  = $type;
61         $this->url   = $url;
62         $this->title = $title;
63     }
64
65     function getUrl()
66     {
67         return $this->url;
68     }
69
70     function mimeType()
71     {
72         switch ($this->type) {
73          case Feed::RSS1:
74             return 'application/rdf+xml';
75          case Feed::RSS2:
76             return 'application/rss+xml';
77          case Feed::ATOM:
78             return 'application/atom+xml';
79          case Feed::FOAF:
80             return 'application/rdf+xml';
81          case Feed::JSON:
82             return 'application/stream+json';
83          default:
84             return null;
85         }
86     }
87
88     function typeName()
89     {
90         switch ($this->type) {
91          case Feed::RSS1:
92             // TRANS: Feed type name.
93             return _('RSS 1.0');
94          case Feed::RSS2:
95             // TRANS: Feed type name.
96             return _('RSS 2.0');
97          case Feed::ATOM:
98             // TRANS: Feed type name.
99             return _('Atom');
100          case Feed::FOAF:
101             // TRANS: Feed type name. FOAF stands for Friend of a Friend.
102             return _('FOAF');
103          case Feed::JSON:
104             // TRANS: Feed type name. See http://activitystrea.ms/
105             return _('Activity Streams');
106          default:
107             return null;
108         }
109     }
110
111     function rel()
112     {
113         switch ($this->type) {
114          case Feed::RSS1:
115          case Feed::RSS2:
116          case Feed::ATOM:
117          case Feed::JSON:
118             return 'alternate';
119          case Feed::FOAF:
120             return 'meta';
121          default:
122             return null;
123         }
124     }
125 }