]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - _darcs/pristine/lib/personal.php
move opening brace of class declaration to next line
[quix0rs-gnu-social.git] / _darcs / pristine / lib / personal.php
1 <?php
2 /*
3  * Laconica - a distributed open-source microblogging tool
4  * Copyright (C) 2008, Controlez-Vous, Inc.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 if (!defined('LACONICA')) { exit(1); }
21
22 class PersonalAction extends Action
23 {
24     
25     function is_readonly()
26     {
27         return true;
28     }
29     
30     function handle($args)
31     {
32         parent::handle($args);
33         common_set_returnto($this->self_url());
34     }
35
36     function views_menu()
37     {
38
39         $user = null;
40         $action = $this->trimmed('action');
41         $nickname = $this->trimmed('nickname');
42
43         if ($nickname) {
44             $user = User::staticGet('nickname', $nickname);
45             $user_profile = $user->getProfile();
46         } else {
47             $user_profile = false;
48         }
49
50         common_element_start('ul', array('id' => 'nav_views'));
51
52         common_menu_item(common_local_url('all', array('nickname' =>
53                                                        $nickname)),
54                          _('Personal'),
55                          sprintf(_('%s and friends'), (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
56                          $action == 'all');
57         common_menu_item(common_local_url('replies', array('nickname' =>
58                                                               $nickname)),
59                          _('Replies'),
60                          sprintf(_('Replies to %s'), (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
61                          $action == 'replies');
62         common_menu_item(common_local_url('showstream', array('nickname' =>
63                                                               $nickname)),
64                          _('Profile'),
65                          ($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname,
66                          $action == 'showstream');
67         common_menu_item(common_local_url('showfavorites', array('nickname' =>
68                                                               $nickname)),
69                          _('Favorites'),
70                          sprintf(_('%s\'s favorite notices'), ($user_profile) ? $user_profile->getBestName() : _('User')),
71                          $action == 'showfavorites');
72         
73         $cur = common_current_user();
74         
75         if ($cur && $cur->id == $user->id) {
76             
77             common_menu_item(common_local_url('inbox', array('nickname' =>
78                                                                      $nickname)),
79                              _('Inbox'),
80                              _('Your incoming messages'),
81                              $action == 'inbox');
82             common_menu_item(common_local_url('outbox', array('nickname' =>
83                                                                      $nickname)),
84                              _('Outbox'),
85                              _('Your sent messages'),
86                              $action == 'outbox');
87         }
88         
89         common_element_end('ul');
90     }
91
92     function show_feeds_list($feeds)
93     {
94         common_element_start('div', array('class' => 'feeds'));
95         common_element('p', null, 'Feeds:');
96         common_element_start('ul', array('class' => 'xoxo'));
97
98         foreach ($feeds as $key => $value) {
99             $this->common_feed_item($feeds[$key]);
100         }
101         common_element_end('ul');
102         common_element_end('div');
103     }
104
105     function common_feed_item($feed)
106     {
107         $nickname = $this->trimmed('nickname');
108
109         switch($feed['item']) {
110             case 'notices': default:
111                 $feed_classname = $feed['type'];
112                 $feed_mimetype = "application/".$feed['type']."+xml";
113                 $feed_title = "$nickname's ".$feed['version']." notice feed";
114                 $feed['textContent'] = "RSS";
115                 break;
116
117             case 'allrss':
118                 $feed_classname = $feed['type'];
119                 $feed_mimetype = "application/".$feed['type']."+xml";
120                 $feed_title = $feed['version']." feed for $nickname and friends";
121                 $feed['textContent'] = "RSS";
122                 break;
123
124             case 'repliesrss':
125                 $feed_classname = $feed['type'];
126                 $feed_mimetype = "application/".$feed['type']."+xml";
127                 $feed_title = $feed['version']." feed for replies to $nickname";
128                 $feed['textContent'] = "RSS";
129                 break;
130
131             case 'publicrss':
132                 $feed_classname = $feed['type'];
133                 $feed_mimetype = "application/".$feed['type']."+xml";
134                 $feed_title = "Public timeline ".$feed['version']." feed";
135                 $feed['textContent'] = "RSS";
136                 break;
137
138             case 'publicatom':
139                 $feed_classname = "atom";
140                 $feed_mimetype = "application/".$feed['type']."+xml";
141                 $feed_title = "Public timeline ".$feed['version']." feed";
142                 $feed['textContent'] = "Atom";
143                 break;
144
145             case 'tagrss':
146                 $feed_classname = $feed['type'];
147                 $feed_mimetype = "application/".$feed['type']."+xml";
148                 $feed_title = $feed['version']." feed for this tag";
149                 $feed['textContent'] = "RSS";
150                 break;
151
152             case 'favoritedrss':
153                 $feed_classname = $feed['type'];
154                 $feed_mimetype = "application/".$feed['type']."+xml";
155                 $feed_title = "Favorited ".$feed['version']." feed";
156                 $feed['textContent'] = "RSS";
157                 break;
158
159             case 'foaf':
160                 $feed_classname = "foaf";
161                 $feed_mimetype = "application/".$feed['type']."+xml";
162                 $feed_title = "$nickname's FOAF file";
163                 $feed['textContent'] = "FOAF";
164                 break;
165
166             case 'favoritesrss':
167                 $feed_classname = "favorites";
168                 $feed_mimetype = "application/".$feed['type']."+xml";
169                 $feed_title = "Feed for favorites of $nickname";
170                 $feed['textContent'] = "RSS";
171                 break;
172
173             case 'usertimeline':
174                 $feed_classname = "atom";
175                 $feed_mimetype = "application/".$feed['type']."+xml";
176                 $feed_title = "$nickname's ".$feed['version']." notice feed";
177                 $feed['textContent'] = "Atom";
178                 break;
179         }
180         common_element_start('li');
181         common_element('a', array('href' => $feed['href'],
182                                   'class' => $feed_classname,
183                                   'type' => $feed_mimetype,
184                                   'title' => $feed_title),
185                             $feed['textContent']);
186         common_element_end('li');
187     }
188
189     
190     function source_link($source)
191     {
192         $source_name = _($source);
193         switch ($source) {
194          case 'web':
195          case 'xmpp':
196          case 'mail':
197          case 'omb':
198          case 'api':
199             common_element('span', 'noticesource', $source_name);
200             break;
201          default:
202             $ns = Notice_source::staticGet($source);
203             if ($ns) {
204                 common_element('a', array('href' => $ns->url),
205                                $ns->name);
206             } else {
207                 common_element('span', 'noticesource', $source_name);
208             }
209             break;
210         }
211         return;
212     }
213 }