]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/all.php
Merge branch '0.7.x' of git@gitorious.org:laconica/dev into 0.7.x
[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
46         common_set_returnto($this->selfUrl());
47
48         return true;
49     }
50
51     function handle($args)
52     {
53         parent::handle($args);
54
55         if (!$this->user) {
56             $this->clientError(_('No such user.'));
57             return;
58         }
59
60         $this->showPage();
61     }
62
63     function title()
64     {
65         if ($this->page > 1) {
66             return sprintf(_("%s and friends, page %d"), $this->user->nickname, $this->page);
67         } else {
68             return sprintf(_("%s and friends"), $this->user->nickname);
69         }
70     }
71
72     function getFeeds()
73     {
74         return array(new Feed(Feed::RSS1,
75                               common_local_url('allrss', array('nickname' =>
76                                                                $this->user->nickname)),
77                               sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->user->nickname)),
78                      new Feed(Feed::RSS2,
79                               common_local_url('api', array('apiaction' => 'statuses',
80                                                             'method' => 'friends_timeline',
81                                                             'argument' => $this->user->nickname.'.rss')),
82                               sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->user->nickname)),
83                      new Feed(Feed::ATOM,
84                               common_local_url('api', array('apiaction' => 'statuses',
85                                                             'method' => 'friends_timeline',
86                                                             'argument' => $this->user->nickname.'.atom')),
87                               sprintf(_('Feed for friends of %s (Atom)'), $this->user->nickname)));
88     }
89
90     function showLocalNav()
91     {
92         $nav = new PersonalGroupNav($this);
93         $nav->show();
94     }
95
96     function showPageNotice()
97     {
98         $notice = $this->user->noticesWithFriends(0, 1);
99         if ($notice->count()) {
100             return;
101         }
102
103         $message = sprintf(_('This is the timeline for %s and friends but noone has posted anything yet.'), $this->user->nickname) . ' ';
104
105         if (common_logged_in()) {
106             $current_user = common_current_user();
107             if ($this->user->id === $current_user->id) {
108                 $message .= _('Try subscribing to more people, [join a group](%%action.groups) or post something yourself.');
109             } else {
110                 $message .= sprintf(_('You can try to [nudge %s](./) from his profile or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%s).'), $this->user->nickname, '@' . $this->user->nickname);
111             }
112         }
113         else {
114             $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);
115         }
116
117         $this->elementStart('div', 'blankfiller');
118         $this->raw(common_markup_to_html($message));
119         $this->elementEnd('div');
120     }
121
122     function showContent()
123     {
124         $notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
125
126         $nl = new NoticeList($notice, $this);
127
128         $cnt = $nl->show();
129
130         $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
131                           $this->page, 'all', array('nickname' => $this->user->nickname));
132     }
133
134     function showPageTitle()
135     {
136         $user =& common_current_user();
137         if ($user && ($user->id == $this->user->id)) {
138             $this->element('h1', NULL, _("You and friends"));
139         } else {
140             $this->element('h1', NULL, sprintf(_('%s and friends'), $this->user->nickname));
141         }
142     }
143
144 }