]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/personal.php
replace all tabs with four spaces
[quix0rs-gnu-social.git] / 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     function is_readonly() {
25         return true;
26     }
27     
28     function handle($args) {
29         parent::handle($args);
30         common_set_returnto($this->self_url());
31     }
32
33     function views_menu() {
34
35         $user = NULL;
36         $action = $this->trimmed('action');
37         $nickname = $this->trimmed('nickname');
38
39         if ($nickname) {
40             $user = User::staticGet('nickname', $nickname);
41             $user_profile = $user->getProfile();
42         } else {
43             $user_profile = false;
44         }
45
46         common_element_start('ul', array('id' => 'nav_views'));
47
48         common_menu_item(common_local_url('all', array('nickname' =>
49                                                        $nickname)),
50                          _('Personal'),
51                          sprintf(_('%s and friends'), (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
52                          $action == 'all');
53         common_menu_item(common_local_url('replies', array('nickname' =>
54                                                               $nickname)),
55                          _('Replies'),
56                          sprintf(_('Replies to %s'), (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
57                          $action == 'replies');
58         common_menu_item(common_local_url('showstream', array('nickname' =>
59                                                               $nickname)),
60                          _('Profile'),
61                          ($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname,
62                          $action == 'showstream');
63         common_menu_item(common_local_url('showfavorites', array('nickname' =>
64                                                               $nickname)),
65                          _('Favorites'),
66                          sprintf(_('%s\'s favorite notices'), ($user_profile) ? $user_profile->getBestName() : _('User')),
67                          $action == 'showfavorites');
68         
69         $cur = common_current_user();
70         
71         if ($cur && $cur->id == $user->id) {
72             
73             common_menu_item(common_local_url('inbox', array('nickname' =>
74                                                                      $nickname)),
75                              _('Inbox'),
76                              _('Your incoming messages'),
77                              $action == 'inbox');
78             common_menu_item(common_local_url('outbox', array('nickname' =>
79                                                                      $nickname)),
80                              _('Outbox'),
81                              _('Your sent messages'),
82                              $action == 'outbox');
83         }
84         
85         common_element_end('ul');
86     }
87
88     function show_feeds_list($feeds) {
89         common_element_start('div', array('class' => 'feeds'));
90         common_element('p', null, 'Feeds:');
91         common_element_start('ul', array('class' => 'xoxo'));
92
93         foreach ($feeds as $key => $value) {
94             $this->common_feed_item($feeds[$key]);
95         }
96         common_element_end('ul');
97         common_element_end('div');
98     }
99
100     function common_feed_item($feed) {
101         $nickname = $this->trimmed('nickname');
102
103         switch($feed['item']) {
104             case 'notices': default:
105                 $feed_classname = $feed['type'];
106                 $feed_mimetype = "application/".$feed['type']."+xml";
107                 $feed_title = "$nickname's ".$feed['version']." notice feed";
108                 $feed['textContent'] = "RSS";
109                 break;
110
111             case 'allrss':
112                 $feed_classname = $feed['type'];
113                 $feed_mimetype = "application/".$feed['type']."+xml";
114                 $feed_title = $feed['version']." feed for $nickname and friends";
115                 $feed['textContent'] = "RSS";
116                 break;
117
118             case 'repliesrss':
119                 $feed_classname = $feed['type'];
120                 $feed_mimetype = "application/".$feed['type']."+xml";
121                 $feed_title = $feed['version']." feed for replies to $nickname";
122                 $feed['textContent'] = "RSS";
123                 break;
124
125             case 'publicrss':
126                 $feed_classname = $feed['type'];
127                 $feed_mimetype = "application/".$feed['type']."+xml";
128                 $feed_title = "Public timeline ".$feed['version']." feed";
129                 $feed['textContent'] = "RSS";
130                 break;
131
132             case 'publicatom':
133                 $feed_classname = "atom";
134                 $feed_mimetype = "application/".$feed['type']."+xml";
135                 $feed_title = "Public timeline ".$feed['version']." feed";
136                 $feed['textContent'] = "Atom";
137                 break;
138
139             case 'tagrss':
140                 $feed_classname = $feed['type'];
141                 $feed_mimetype = "application/".$feed['type']."+xml";
142                 $feed_title = $feed['version']." feed for this tag";
143                 $feed['textContent'] = "RSS";
144                 break;
145
146             case 'favoritedrss':
147                 $feed_classname = $feed['type'];
148                 $feed_mimetype = "application/".$feed['type']."+xml";
149                 $feed_title = "Favorited ".$feed['version']." feed";
150                 $feed['textContent'] = "RSS";
151                 break;
152
153             case 'foaf':
154                 $feed_classname = "foaf";
155                 $feed_mimetype = "application/".$feed['type']."+xml";
156                 $feed_title = "$nickname's FOAF file";
157                 $feed['textContent'] = "FOAF";
158                 break;
159
160             case 'favoritesrss':
161                 $feed_classname = "favorites";
162                 $feed_mimetype = "application/".$feed['type']."+xml";
163                 $feed_title = "Feed for favorites of $nickname";
164                 $feed['textContent'] = "RSS";
165                 break;
166
167             case 'usertimeline':
168                 $feed_classname = "atom";
169                 $feed_mimetype = "application/".$feed['type']."+xml";
170                 $feed_title = "$nickname's ".$feed['version']." notice feed";
171                 $feed['textContent'] = "Atom";
172                 break;
173         }
174         common_element_start('li');
175         common_element('a', array('href' => $feed['href'],
176                                   'class' => $feed_classname,
177                                   'type' => $feed_mimetype,
178                                   'title' => $feed_title),
179                             $feed['textContent']);
180         common_element_end('li');
181     }
182
183     
184     function source_link($source) {
185         $source_name = _($source);
186         switch ($source) {
187          case 'web':
188          case 'xmpp':
189          case 'mail':
190          case 'omb':
191          case 'api':
192             common_element('span', 'noticesource', $source_name);
193             break;
194          default:
195             $ns = Notice_source::staticGet($source);
196             if ($ns) {
197                 common_element('a', array('href' => $ns->url),
198                                $ns->name);
199             } else {
200                 common_element('span', 'noticesource', $source_name);
201             }
202             break;
203         }
204         return;
205     }
206 }