]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/all.php
* L10n updates: consistent puctuation
[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  * @category Actions
20  * @package  Actions
21  * @author   Evan Prodromou <evan@status.net>
22  * @author   Mike Cochrane <mikec@mikenz.geek.nz>
23  * @author   Robin Millette <millette@controlyourself.ca>
24  * @author   Adrian Lang <mail@adrianlang.de>
25  * @author   Meitar Moscovitz <meitarm@gmail.com>
26  * @author   Sarven Capadisli <csarven@status.net>
27  * @author   Craig Andrews <candrews@integralblue.com>
28  * @author   Jeffery To <jeffery.to@gmail.com>
29  * @author   Zach Copley <zach@controlyourself.ca>
30  * @license  GNU Affero General Public License http://www.gnu.org/licenses/
31  * @link     http://status.net
32  */
33
34 if (!defined('STATUSNET') && !defined('LACONICA')) {
35     exit(1);
36 }
37
38 require_once INSTALLDIR.'/lib/personalgroupnav.php';
39 require_once INSTALLDIR.'/lib/noticelist.php';
40 require_once INSTALLDIR.'/lib/feedlist.php';
41
42 class AllAction extends ProfileAction
43 {
44     var $notice;
45
46     function isReadOnly($args)
47     {
48         return true;
49     }
50
51     function prepare($args)
52     {
53         parent::prepare($args);
54         $cur = common_current_user();
55
56         if (!empty($cur) && $cur->id == $this->user->id) {
57             $this->notice = $this->user->noticeInbox(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
58         } else {
59             $this->notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
60         }
61
62         if ($this->page > 1 && $this->notice->N == 0) {
63             $this->serverError(_('No such page'), $code = 404);
64         }
65
66         return true;
67     }
68
69     function handle($args)
70     {
71         parent::handle($args);
72
73         if (!$this->user) {
74             $this->clientError(_('No such user.'));
75             return;
76         }
77
78         $this->showPage();
79     }
80
81     function title()
82     {
83         if ($this->page > 1) {
84             return sprintf(_("%1$s and friends, page %2$d"), $this->user->nickname, $this->page);
85         } else {
86             return sprintf(_("%s and friends"), $this->user->nickname);
87         }
88     }
89
90     function getFeeds()
91     {
92         return array(
93             new Feed(Feed::RSS1,
94                 common_local_url(
95                     'allrss', array(
96                         'nickname' =>
97                         $this->user->nickname)
98                 ),
99                 sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->user->nickname)),
100             new Feed(Feed::RSS2,
101                 common_local_url(
102                     'ApiTimelineFriends', array(
103                         'format' => 'rss',
104                         'id' => $this->user->nickname
105                     )
106                 ),
107                 sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->user->nickname)),
108             new Feed(Feed::ATOM,
109                 common_local_url(
110                     'ApiTimelineFriends', array(
111                         'format' => 'atom',
112                         'id' => $this->user->nickname
113                     )
114                 ),
115                 sprintf(_('Feed for friends of %s (Atom)'), $this->user->nickname))
116         );
117     }
118
119     function showLocalNav()
120     {
121         $nav = new PersonalGroupNav($this);
122         $nav->show();
123     }
124
125     function showEmptyListMessage()
126     {
127         $message = sprintf(_('This is the timeline for %s and friends but no one has posted anything yet.'), $this->user->nickname) . ' ';
128
129         if (common_logged_in()) {
130             $current_user = common_current_user();
131             if ($this->user->id === $current_user->id) {
132                 $message .= _('Try subscribing to more people, [join a group](%%action.groups%%) or post something yourself.');
133             } else {
134                 $message .= sprintf(_('You can try to [nudge %1$s](../%2$s) from his profile or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%3$s).'), $this->user->nickname, $this->user->nickname, '@' . $this->user->nickname);
135             }
136         } else {
137             $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to his or her attention.'), $this->user->nickname);
138         }
139
140         $this->elementStart('div', 'guide');
141         $this->raw(common_markup_to_html($message));
142         $this->elementEnd('div');
143     }
144
145     function showContent()
146     {
147         $nl = new NoticeList($this->notice, $this);
148
149         $cnt = $nl->show();
150
151         if (0 == $cnt) {
152             $this->showEmptyListMessage();
153         }
154
155         $this->pagination(
156             $this->page > 1, $cnt > NOTICES_PER_PAGE,
157             $this->page, 'all', array('nickname' => $this->user->nickname)
158         );
159     }
160
161     function showPageTitle()
162     {
163         $user = common_current_user();
164         if ($user && ($user->id == $this->user->id)) {
165             $this->element('h1', null, _("You and friends"));
166         } else {
167             $this->element('h1', null, sprintf(_('%s and friends'), $this->user->nickname));
168         }
169     }
170 }