]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/feed.php
Merge branch '1.0.x' into testing
[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             // TRANS: Feed type name.
85             return _('RSS 1.0');
86          case Feed::RSS2:
87             // TRANS: Feed type name.
88             return _('RSS 2.0');
89          case Feed::ATOM:
90             // TRANS: Feed type name.
91             return _('Atom');
92          case Feed::FOAF:
93             // TRANS: Feed type name. FOAF stands for Friend of a Friend.
94             return _('FOAF');
95          default:
96             return null;
97         }
98     }
99
100     function rel()
101     {
102         switch ($this->type) {
103          case Feed::RSS1:
104          case Feed::RSS2:
105          case Feed::ATOM:
106             return 'alternate';
107          case Feed::FOAF:
108             return 'meta';
109          default:
110             return null;
111         }
112     }
113 }