]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/feed.php
8660c75ed3af2e3230af98b6e873bfe5567a7c76
[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')) {
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
47 class Feed
48 {
49     const RSS1 = 1;
50     const RSS2 = 2;
51     const ATOM = 3;
52     const FOAF = 4;
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          default:
77             return null;
78         }
79     }
80
81     function typeName()
82     {
83         switch ($this->type) {
84          case Feed::RSS1:
85             return _('RSS 1.0');
86          case Feed::RSS2:
87             return _('RSS 2.0');
88          case Feed::ATOM:
89             return _('Atom');
90          case Feed::FOAF:
91             return _('FOAF');
92          default:
93             return null;
94         }
95     }
96
97     function rel()
98     {
99         switch ($this->type) {
100          case Feed::RSS1:
101          case Feed::RSS2:
102          case Feed::ATOM:
103             return 'alternate';
104          case Feed::FOAF:
105             return 'meta';
106          default:
107             return null;
108         }
109     }
110 }