]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/feed.php
Misses this file to merge. I like the comments.
[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 mimeType()
66     {
67         switch ($this->type) {
68          case Feed::RSS1:
69             return 'application/rdf+xml';
70          case Feed::RSS2:
71             return 'application/rss+xml';
72          case Feed::ATOM:
73             return 'application/atom+xml';
74          case Feed::FOAF:
75             return 'application/rdf+xml';
76          case Feed::JSON:
77             return 'application/stream+json';
78          default:
79             return null;
80         }
81     }
82
83     function typeName()
84     {
85         switch ($this->type) {
86          case Feed::RSS1:
87             // TRANS: Feed type name.
88             return _('RSS 1.0');
89          case Feed::RSS2:
90             // TRANS: Feed type name.
91             return _('RSS 2.0');
92          case Feed::ATOM:
93             // TRANS: Feed type name.
94             return _('Atom');
95          case Feed::FOAF:
96             // TRANS: Feed type name. FOAF stands for Friend of a Friend.
97             return _('FOAF');
98          case Feed::JSON:
99             // TRANS: Feed type name. See http://activitystrea.ms/
100             return _('Activity Streams');
101          default:
102             return null;
103         }
104     }
105
106     function rel()
107     {
108         switch ($this->type) {
109          case Feed::RSS1:
110          case Feed::RSS2:
111          case Feed::ATOM:
112          case Feed::JSON:
113             return 'alternate';
114          case Feed::FOAF:
115             return 'meta';
116          default:
117             return null;
118         }
119     }
120 }