]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/all.php
Merge branch 'link-rel-paginate' of git://gitorious.org/laconica/meitar. Fixed wrong...
[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 ProfileAction
27 {
28     function isReadOnly()
29     {
30         return true;
31     }
32
33     function handle($args)
34     {
35         parent::handle($args);
36
37         if (!$this->user) {
38             $this->clientError(_('No such user.'));
39             return;
40         }
41
42         $this->showPage();
43     }
44
45     function title()
46     {
47         if ($this->page > 1) {
48             return sprintf(_("%s and friends, page %d"), $this->user->nickname, $this->page);
49         } else {
50             return sprintf(_("%s and friends"), $this->user->nickname);
51         }
52     }
53
54     function getFeeds()
55     {
56         return array(new Feed(Feed::RSS1,
57                               common_local_url('allrss', array('nickname' =>
58                                                                $this->user->nickname)),
59                               sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->user->nickname)),
60                      new Feed(Feed::RSS2,
61                               common_local_url('api', array('apiaction' => 'statuses',
62                                                             'method' => 'friends_timeline',
63                                                             'argument' => $this->user->nickname.'.rss')),
64                               sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->user->nickname)),
65                      new Feed(Feed::ATOM,
66                               common_local_url('api', array('apiaction' => 'statuses',
67                                                             'method' => 'friends_timeline',
68                                                             'argument' => $this->user->nickname.'.atom')),
69                               sprintf(_('Feed for friends of %s (Atom)'), $this->user->nickname)));
70     }
71
72     /**
73      * Output document relationship links
74      *
75      * @return void
76      */
77     function showRelationshipLinks()
78     {
79         $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
80                                      $this->page, 'all', array('nickname' => $this->user->nickname));
81     }
82
83     function showLocalNav()
84     {
85         $nav = new PersonalGroupNav($this);
86         $nav->show();
87     }
88
89     function showEmptyListMessage()
90     {
91         $message = sprintf(_('This is the timeline for %s and friends but no one has posted anything yet.'), $this->user->nickname) . ' ';
92
93         if (common_logged_in()) {
94             $current_user = common_current_user();
95             if ($this->user->id === $current_user->id) {
96                 $message .= _('Try subscribing to more people, [join a group](%%action.groups) or post something yourself.');
97             } else {
98                 $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);
99             }
100         }
101         else {
102             $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);
103         }
104
105         $this->elementStart('div', 'guide');
106         $this->raw(common_markup_to_html($message));
107         $this->elementEnd('div');
108     }
109
110     function showContent()
111     {
112         $notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
113
114         $nl = new NoticeList($notice, $this);
115
116         $cnt = $nl->show();
117
118         if (0 == $cnt) {
119             $this->showEmptyListMessage();
120         }
121
122         $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
123                           $this->page, 'all', array('nickname' => $this->user->nickname));
124     }
125
126     function showPageTitle()
127     {
128         $user =& common_current_user();
129         if ($user && ($user->id == $this->user->id)) {
130             $this->element('h1', NULL, _("You and friends"));
131         } else {
132             $this->element('h1', NULL, sprintf(_('%s and friends'), $this->user->nickname));
133         }
134     }
135
136 }