]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/all.php
a distributed -> the distributed
[quix0rs-gnu-social.git] / actions / all.php
1 <?php
2 /*
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2008, 2009, StatusNet, 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 ProfileAction
27 {
28     var $notice;
29
30     function isReadOnly($args)
31     {
32         return true;
33     }
34
35     function prepare($args)
36     {
37         parent::prepare($args);
38         $cur = common_current_user();
39
40         if (!empty($cur) && $cur->id == $this->user->id) {
41             $this->notice = $this->user->noticeInbox(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
42         } else {
43             $this->notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
44         }
45
46         if($this->page > 1 && $this->notice->N == 0){
47             $this->serverError(_('No such page'),$code=404);
48         }
49
50         return true;
51     }
52
53     function handle($args)
54     {
55         parent::handle($args);
56
57         if (!$this->user) {
58             $this->clientError(_('No such user.'));
59             return;
60         }
61
62         $this->showPage();
63     }
64
65     function title()
66     {
67         if ($this->page > 1) {
68             return sprintf(_("%s and friends, page %d"), $this->user->nickname, $this->page);
69         } else {
70             return sprintf(_("%s and friends"), $this->user->nickname);
71         }
72     }
73
74     function getFeeds()
75     {
76         return array(new Feed(Feed::RSS1,
77                               common_local_url('allrss', array('nickname' =>
78                                                                $this->user->nickname)),
79                               sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->user->nickname)),
80                      new Feed(Feed::RSS2,
81                               common_local_url('api', array('apiaction' => 'statuses',
82                                                             'method' => 'friends_timeline',
83                                                             'argument' => $this->user->nickname.'.rss')),
84                               sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->user->nickname)),
85                      new Feed(Feed::ATOM,
86                               common_local_url('api', array('apiaction' => 'statuses',
87                                                             'method' => 'friends_timeline',
88                                                             'argument' => $this->user->nickname.'.atom')),
89                               sprintf(_('Feed for friends of %s (Atom)'), $this->user->nickname)));
90     }
91
92     function showLocalNav()
93     {
94         $nav = new PersonalGroupNav($this);
95         $nav->show();
96     }
97
98     function showEmptyListMessage()
99     {
100         $message = sprintf(_('This is the timeline for %s and friends but no one has posted anything yet.'), $this->user->nickname) . ' ';
101
102         if (common_logged_in()) {
103             $current_user = common_current_user();
104             if ($this->user->id === $current_user->id) {
105                 $message .= _('Try subscribing to more people, [join a group](%%action.groups%%) or post something yourself.');
106             } else {
107                 $message .= sprintf(_('You can try to [nudge %s](../%s) from his profile or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%s).'), $this->user->nickname, $this->user->nickname, '@' . $this->user->nickname);
108             }
109         }
110         else {
111             $message .= sprintf(_('Why not [register an account](%%%%action.%s%%%%) and then nudge %s or post a notice to his or her attention.'),
112                                 (!common_config('site','openidonly')) ? 'register' : 'openidlogin',
113                                 $this->user->nickname);
114         }
115
116         $this->elementStart('div', 'guide');
117         $this->raw(common_markup_to_html($message));
118         $this->elementEnd('div');
119     }
120
121     function showContent()
122     {
123         $nl = new NoticeList($this->notice, $this);
124
125         $cnt = $nl->show();
126
127         if (0 == $cnt) {
128             $this->showEmptyListMessage();
129         }
130
131         $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
132                           $this->page, 'all', array('nickname' => $this->user->nickname));
133     }
134
135     function showPageTitle()
136     {
137         $user =& common_current_user();
138         if ($user && ($user->id == $this->user->id)) {
139             $this->element('h1', NULL, _("You and friends"));
140         } else {
141             $this->element('h1', NULL, sprintf(_('%s and friends'), $this->user->nickname));
142         }
143     }
144
145 }