]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/feedlist.php
Modify public stream to use new UI framework
[quix0rs-gnu-social.git] / lib / feedlist.php
1 <?php
2 /**
3  * Laconica, the distributed open-source microblogging tool
4  *
5  * Widget for showing a list of feeds
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  Widget
23  * @package   Laconica
24  * @author    Evan Prodromou <evan@controlyourself.ca>
25  * @author    Sarven Capadisli <csarven@controlyourself.ca>
26  * @copyright 2008 Control Yourself, Inc.
27  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28  * @link      http://laconi.ca/
29  */
30
31 if (!defined('LACONICA')) {
32     exit(1);
33 }
34
35 /**
36  * Widget for showing a list of feeds
37  *
38  * Typically used for Action::showExportList()
39  *
40  * @category Widget
41  * @package  Laconica
42  * @author   Evan Prodromou <evan@controlyourself.ca>
43  * @author   Sarven Capadisli <csarven@controlyourself.ca>
44  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
45  * @link     http://laconi.ca/
46  *
47  * @see      Action::showExportList()
48  */
49
50 class FeedList
51 {
52     var $out = null;
53
54     function __construct($out=null)
55     {
56         $this->out = $out;
57     }
58
59     function show($feeds)
60     {
61         $this->out->elementStart('div', array('class' => 'feeds'));
62         $this->out->element('p', null, 'Feeds:');
63         $this->out->elementStart('ul', array('class' => 'xoxo'));
64
65         foreach ($feeds as $key => $value) {
66             $this->feedItem($feeds[$key]);
67         }
68
69         $this->out->elementEnd('ul');
70         $this->out->elementEnd('div');
71     }
72
73     function feedItem($feed)
74     {
75         $nickname = $this->trimmed('nickname');
76
77         switch($feed['item']) {
78          case 'notices': default:
79             $feed_classname = $feed['type'];
80             $feed_mimetype = "application/".$feed['type']."+xml";
81             $feed_title = "$nickname's ".$feed['version']." notice feed";
82             $feed['textContent'] = "RSS";
83             break;
84
85          case 'allrss':
86             $feed_classname = $feed['type'];
87             $feed_mimetype = "application/".$feed['type']."+xml";
88             $feed_title = $feed['version']." feed for $nickname and friends";
89             $feed['textContent'] = "RSS";
90             break;
91
92          case 'repliesrss':
93             $feed_classname = $feed['type'];
94             $feed_mimetype = "application/".$feed['type']."+xml";
95             $feed_title = $feed['version']." feed for replies to $nickname";
96             $feed['textContent'] = "RSS";
97             break;
98
99          case 'publicrss':
100             $feed_classname = $feed['type'];
101             $feed_mimetype = "application/".$feed['type']."+xml";
102             $feed_title = "Public timeline ".$feed['version']." feed";
103             $feed['textContent'] = "RSS";
104             break;
105
106          case 'publicatom':
107             $feed_classname = "atom";
108             $feed_mimetype = "application/".$feed['type']."+xml";
109             $feed_title = "Public timeline ".$feed['version']." feed";
110             $feed['textContent'] = "Atom";
111             break;
112
113          case 'tagrss':
114             $feed_classname = $feed['type'];
115             $feed_mimetype = "application/".$feed['type']."+xml";
116             $feed_title = $feed['version']." feed for this tag";
117             $feed['textContent'] = "RSS";
118             break;
119
120          case 'favoritedrss':
121             $feed_classname = $feed['type'];
122             $feed_mimetype = "application/".$feed['type']."+xml";
123             $feed_title = "Favorited ".$feed['version']." feed";
124             $feed['textContent'] = "RSS";
125             break;
126
127          case 'foaf':
128             $feed_classname = "foaf";
129             $feed_mimetype = "application/".$feed['type']."+xml";
130             $feed_title = "$nickname's FOAF file";
131             $feed['textContent'] = "FOAF";
132             break;
133
134          case 'favoritesrss':
135             $feed_classname = "favorites";
136             $feed_mimetype = "application/".$feed['type']."+xml";
137             $feed_title = "Feed for favorites of $nickname";
138             $feed['textContent'] = "RSS";
139             break;
140
141          case 'usertimeline':
142             $feed_classname = "atom";
143             $feed_mimetype = "application/".$feed['type']."+xml";
144             $feed_title = "$nickname's ".$feed['version']." notice feed";
145             $feed['textContent'] = "Atom";
146             break;
147         }
148         $this->out->elementStart('li');
149         $this->out->element('a', array('href' => $feed['href'],
150                                   'class' => $feed_classname,
151                                   'type' => $feed_mimetype,
152                                   'title' => $feed_title),
153                        $feed['textContent']);
154         $this->out->elementEnd('li');
155     }
156 }