]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/replies.php
* L10n updates: consistent puctuation
[quix0rs-gnu-social.git] / actions / replies.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * List of replies
6  *
7  * PHP version 5
8  *
9  * LICENCE: This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU Affero General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU Affero General Public License for more details.
18  *
19  * You should have received a copy of the GNU Affero General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  * @category  Personal
23  * @package   StatusNet
24  * @author    Evan Prodromou <evan@status.net>
25  * @copyright 2008-2009 StatusNet, Inc.
26  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27  * @link      http://status.net/
28  */
29
30 if (!defined('STATUSNET') && !defined('LACONICA')) {
31     exit(1);
32 }
33
34 require_once INSTALLDIR.'/lib/personalgroupnav.php';
35 require_once INSTALLDIR.'/lib/noticelist.php';
36 require_once INSTALLDIR.'/lib/feedlist.php';
37
38 /**
39  * List of replies
40  *
41  * @category Personal
42  * @package  StatusNet
43  * @author   Evan Prodromou <evan@status.net>
44  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
45  * @link     http://status.net/
46  */
47
48 class RepliesAction extends OwnerDesignAction
49 {
50     var $page = null;
51     var $notice;
52
53     /**
54      * Prepare the object
55      *
56      * Check the input values and initialize the object.
57      * Shows an error page on bad input.
58      *
59      * @param array $args $_REQUEST data
60      *
61      * @return boolean success flag
62      */
63
64     function prepare($args)
65     {
66         parent::prepare($args);
67
68         $nickname = common_canonical_nickname($this->arg('nickname'));
69
70         $this->user = User::staticGet('nickname', $nickname);
71
72         if (!$this->user) {
73             $this->clientError(_('No such user.'));
74             return false;
75         }
76
77         $profile = $this->user->getProfile();
78
79         if (!$profile) {
80             $this->serverError(_('User has no profile.'));
81             return false;
82         }
83
84         $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
85
86         common_set_returnto($this->selfUrl());
87
88         $this->notice = $this->user->getReplies(($this->page-1) * NOTICES_PER_PAGE,
89              NOTICES_PER_PAGE + 1);
90
91         if($this->page > 1 && $this->notice->N == 0){
92             $this->serverError(_('No such page'),$code=404);
93         }
94
95         return true;
96     }
97
98     /**
99      * Handle a request
100      *
101      * Just show the page. All args already handled.
102      *
103      * @param array $args $_REQUEST data
104      *
105      * @return void
106      */
107
108     function handle($args)
109     {
110         parent::handle($args);
111         $this->showPage();
112     }
113
114     /**
115      * Title of the page
116      *
117      * Includes name of user and page number.
118      *
119      * @return string title of page
120      */
121
122     function title()
123     {
124         if ($this->page == 1) {
125             return sprintf(_("Replies to %s"), $this->user->nickname);
126         } else {
127             return sprintf(_("Replies to %1$s, page %2$d"),
128                            $this->user->nickname,
129                            $this->page);
130         }
131     }
132
133     /**
134      * Feeds for the <head> section
135      *
136      * @return void
137      */
138
139     function getFeeds()
140     {
141         return array(new Feed(Feed::RSS1,
142                               common_local_url('repliesrss',
143                                                array('nickname' => $this->user->nickname)),
144                               sprintf(_('Replies feed for %s (RSS 1.0)'),
145                                       $this->user->nickname)),
146                      new Feed(Feed::RSS2,
147                               common_local_url('ApiTimelineMentions',
148                                                array(
149                                                     'id' => $this->user->nickname,
150                                                     'format' => 'rss')),
151                               sprintf(_('Replies feed for %s (RSS 2.0)'),
152                                       $this->user->nickname)),
153                      new Feed(Feed::ATOM,
154                               common_local_url('ApiTimelineMentions',
155                                                array(
156                                                     'id' => $this->user->nickname,
157                                                     'format' => 'atom')),
158                               sprintf(_('Replies feed for %s (Atom)'),
159                                     $this->user->nickname)));
160     }
161
162     /**
163      * show the personal group nav
164      *
165      * @return void
166      */
167
168     function showLocalNav()
169     {
170         $nav = new PersonalGroupNav($this);
171         $nav->show();
172     }
173
174     /**
175      * Show the content
176      *
177      * A list of notices that are replies to the user, plus pagination.
178      *
179      * @return void
180      */
181
182     function showContent()
183     {
184         $nl = new NoticeList($this->notice, $this);
185
186         $cnt = $nl->show();
187         if (0 === $cnt) {
188             $this->showEmptyListMessage();
189         }
190
191         $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
192                           $this->page, 'replies',
193                           array('nickname' => $this->user->nickname));
194     }
195
196     function showEmptyListMessage()
197     {
198         $message = sprintf(_('This is the timeline showing replies to %1$s but %2$s hasn\'t received a notice to his attention yet.'), $this->user->nickname, $this->user->nickname) . ' ';
199
200         if (common_logged_in()) {
201             $current_user = common_current_user();
202             if ($this->user->id === $current_user->id) {
203                 $message .= _('You can engage other users in a conversation, subscribe to more people or [join groups](%%action.groups%%).');
204             } else {
205                 $message .= sprintf(_('You can try to [nudge %1$s](../%2$s) or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%3$s).'), $this->user->nickname, $this->user->nickname, '@' . $this->user->nickname);
206             }
207         }
208         else {
209             $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);
210         }
211
212         $this->elementStart('div', 'guide');
213         $this->raw(common_markup_to_html($message));
214         $this->elementEnd('div');
215     }
216
217     function isReadOnly($args)
218     {
219         return true;
220     }
221 }