]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/feedlist.php
Merge branch 'dev-0.7.x' into link-rel-paginate
[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 extends Widget
51 {
52     var $action = null;
53     
54     function __construct($action=null)
55     {
56         parent::__construct($action);
57         $this->action = $action;
58     }
59
60     function show($feeds)
61     {
62         $this->out->elementStart('div', array('id' => 'export_data',
63                                               'class' => 'section'));
64         $this->out->element('h2', null, _('Export data'));
65         $this->out->elementStart('ul', array('class' => 'xoxo'));
66
67         foreach ($feeds as $key => $value) {
68             $this->feedItem($feeds[$key]);
69         }
70
71         $this->out->elementEnd('ul');
72         $this->out->elementEnd('div');
73     }
74
75     function feedItem($feed)
76     {
77         $nickname = $this->action->trimmed('nickname');
78
79         switch($feed['item']) {
80          case 'notices': default:
81             $feed_classname = $feed['type'];
82             $feed_mimetype = "application/".$feed['type']."+xml";
83             $feed_title = "$nickname's ".$feed['version']." notice feed";
84             $feed['textContent'] = "RSS";
85             break;
86
87          case 'allrss':
88             $feed_classname = $feed['type'];
89             $feed_mimetype = "application/".$feed['type']."+xml";
90             $feed_title = $feed['version']." feed for $nickname and friends";
91             $feed['textContent'] = "RSS";
92             break;
93
94          case 'repliesrss':
95             $feed_classname = $feed['type'];
96             $feed_mimetype = "application/".$feed['type']."+xml";
97             $feed_title = $feed['version']." feed for replies to $nickname";
98             $feed['textContent'] = "RSS";
99             break;
100
101          case 'publicrss':
102             $feed_classname = $feed['type'];
103             $feed_mimetype = "application/".$feed['type']."+xml";
104             $feed_title = "Public timeline ".$feed['version']." feed";
105             $feed['textContent'] = "RSS";
106             break;
107
108          case 'publicatom':
109             $feed_classname = "atom";
110             $feed_mimetype = "application/".$feed['type']."+xml";
111             $feed_title = "Public timeline ".$feed['version']." feed";
112             $feed['textContent'] = "Atom";
113             break;
114
115          case 'noticesearchrss':
116             $feed_classname = $feed['type'];
117             $feed_mimetype = "application/".$feed['type']."+xml";
118             $feed_title = $feed['version']." feed for this notice search";
119             $feed['textContent'] = "RSS";
120             break;
121
122          case 'tagrss':
123             $feed_classname = $feed['type'];
124             $feed_mimetype = "application/".$feed['type']."+xml";
125             $feed_title = $feed['version']." feed for this tag";
126             $feed['textContent'] = "RSS";
127             break;
128
129          case 'favoritedrss':
130             $feed_classname = $feed['type'];
131             $feed_mimetype = "application/".$feed['type']."+xml";
132             $feed_title = "Favorited ".$feed['version']." feed";
133             $feed['textContent'] = "RSS";
134             break;
135
136          case 'foaf':
137             $feed_classname = "foaf";
138             $feed_mimetype = "application/".$feed['type']."+xml";
139             $feed_title = "$nickname's FOAF file";
140             $feed['textContent'] = "FOAF";
141             break;
142
143          case 'favoritesrss':
144             $feed_classname = "favorites";
145             $feed_mimetype = "application/".$feed['type']."+xml";
146             $feed_title = "Feed for favorites of $nickname";
147             $feed['textContent'] = "RSS";
148             break;
149
150          case 'usertimeline':
151             $feed_classname = "atom";
152             $feed_mimetype = "application/".$feed['type']."+xml";
153             $feed_title = "$nickname's ".$feed['version']." notice feed";
154             $feed['textContent'] = "Atom";
155             break;
156         }
157         $this->out->elementStart('li');
158         $this->out->element('a', array('href' => $feed['href'],
159                                   'class' => $feed_classname,
160                                   'type' => $feed_mimetype,
161                                   'title' => $feed_title),
162                        $feed['textContent']);
163         $this->out->elementEnd('li');
164     }
165 }