]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/all.php
Some work to make the all action work
[quix0rs-gnu-social.git] / actions / all.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 require_once INSTALLDIR.'/lib/personalgroupnav.php';
23 require_once INSTALLDIR.'/lib/noticelist.php';
24 require_once INSTALLDIR.'/lib/feedlist.php';
25
26 class AllAction extends Action
27 {
28     var $user = null;
29     var $page = null;
30     
31     function isReadOnly()
32     {
33         return true;
34     }
35     
36     function prepare($args)
37     {
38         parent::prepare($args);
39         $nickname = common_canonical_nickname($this->arg('nickname'));
40         $this->user = User::staticGet('nickname', $nickname);
41         $this->page = $this->trimmed('page');
42         if (!$this->page) {
43             $this->page = 1;
44         }
45         return true;
46     }
47     
48     function handle($args)
49     {
50         parent::handle($args);
51         
52         if (!$this->user) {
53             $this->clientError(_('No such user.'));
54             return;
55         }
56         
57         $this->showPage();
58     }
59     
60     function title()
61     {
62         if ($this->page > 1) {
63             return sprintf(_("%s and friends, page %d"), $this->user->nickname, $this->page);
64         } else {
65             return sprintf(_("%s and friends"), $this->user->nickname);
66         }
67     }
68     
69     function showFeeds()
70     {
71         $this->element('link', array('rel' => 'alternate',
72                                      'href' => common_local_url('allrss', array('nickname' =>
73                                                                                 $this->user->nickname)),
74                                      'type' => 'application/rss+xml',
75                                      'title' => sprintf(_('Feed for friends of %s'), $this->user->nickname)));
76     }
77     
78     function showLocalNav()
79     {
80         $nav = new PersonalGroupNav($this);
81         $nav->show();
82     }
83
84     function showExportData()
85     {
86         $fl = new FeedList($this);
87         $fl->show(array(0=>array('href'=>common_local_url('allrss', array('nickname' => $this->user->nickname)),
88                                  'type' => 'rss',
89                                  'version' => 'RSS 1.0',
90                                  'item' => 'allrss')));
91     }
92     
93     function showContent()
94     {
95         $notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
96         
97         $nl = new NoticeList($notice, $this);
98
99         $cnt = $nl->show();
100         
101         $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
102                           $this->page, 'all', array('nickname' => $this->user->nickname));
103     }
104 }