git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

replies.php 7 KB
Newer Older
1
<?php
2
/**
3
 * StatusNet, the distributed open-source microblogging tool
4
 *
5 6 7 8 9
 * List of replies
 *
 * PHP version 5
 *
 * LICENCE: This program is free software: you can redistribute it and/or modify
10 11 12 13 14 15 16 17 18 19 20
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * 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-2011 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('GNUSOCIAL')) { exit(1); }
31

32 33 34 35
/**
 * List of replies
 *
 * @category Personal
36
 * @package  StatusNet
37
 * @author   Evan Prodromou <evan@status.net>
38
 * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
39
 * @link     http://status.net/
40
 */
41
class RepliesAction extends ShowstreamAction
42
{
43
    public function getStream()
44
    {
45
        return new ReplyNoticeStream($this->target->getID(), $this->scoped);
46
    }
47

48 49 50 51 52 53 54 55
    /**
     * Title of the page
     *
     * Includes name of user and page number.
     *
     * @return string title of page
     */
    function title()
56
    {
57
        if ($this->page == 1) {
58 59
            // TRANS: Title for first page of replies for a user.
            // TRANS: %s is a user nickname.
60
            return sprintf(_("Replies to %s"), $this->target->getNickname());
61
        } else {
62 63
            // TRANS: Title for all but the first page of replies for a user.
            // TRANS: %1$s is a user nickname, %2$d is a page number.
64
            return sprintf(_('Replies to %1$s, page %2$d'),
65
                           $this->target->getNickname(),
66 67
                           $this->page);
        }
68
    }
69

70 71 72 73 74
    /**
     * Feeds for the <head> section
     *
     * @return void
     */
75
    function getFeeds()
76
    {
77 78 79
        return array(new Feed(Feed::JSON,
                              common_local_url('ApiTimelineMentions',
                                               array(
80
                                                    'id' => $this->target->getNickname(),
81 82 83 84
                                                    'format' => 'as')),
                              // TRANS: Link for feed with replies for a user.
                              // TRANS: %s is a user nickname.
                              sprintf(_('Replies feed for %s (Activity Streams JSON)'),
85
                                      $this->target->getNickname())),
86
                     new Feed(Feed::RSS1,
87
                              common_local_url('repliesrss',
88
                                               array('nickname' => $this->target->getNickname())),
89 90
                              // TRANS: Link for feed with replies for a user.
                              // TRANS: %s is a user nickname.
91
                              sprintf(_('Replies feed for %s (RSS 1.0)'),
92
                                      $this->target->getNickname())),
93 94 95
                     new Feed(Feed::RSS2,
                              common_local_url('ApiTimelineMentions',
                                               array(
96
                                                    'id' => $this->target->getNickname(),
97
                                                    'format' => 'rss')),
98 99
                              // TRANS: Link for feed with replies for a user.
                              // TRANS: %s is a user nickname.
100
                              sprintf(_('Replies feed for %s (RSS 2.0)'),
101
                                      $this->target->getNickname())),
102 103 104
                     new Feed(Feed::ATOM,
                              common_local_url('ApiTimelineMentions',
                                               array(
105
                                                    'id' => $this->target->getNickname(),
106
                                                    'format' => 'atom')),
107 108
                              // TRANS: Link for feed with replies for a user.
                              // TRANS: %s is a user nickname.
109
                              sprintf(_('Replies feed for %s (Atom)'),
110
                                    $this->target->getNickname())));
111
    }
112

113 114
    function showContent()
    {
115
        $nl = new PrimaryNoticeList($this->notice, $this, array('show_n'=>NOTICES_PER_PAGE));
116

117
        $cnt = $nl->show();
118 119 120
        if (0 === $cnt) {
            $this->showEmptyListMessage();
        }
121

122 123
        $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
                          $this->page, 'replies',
124
                          array('nickname' => $this->target->getNickname()));
125
    }
126

127 128
    function showEmptyListMessage()
    {
129
        // TRANS: Empty list message for page with replies for a user.
130 131 132
        // TRANS: %1$s is the user nickname.
        $message = sprintf(_('This is the timeline showing replies to %1$s but no notices have arrived yet.'), $this->target->getNickname());
        $message .= ' ';    // Spacing between this sentence and the next.
133 134

        if (common_logged_in()) {
135
            if ($this->target->getID() === $this->scoped->getID()) {
136 137
                // TRANS: Empty list message for page with replies for a user for the logged in user.
                // TRANS: This message contains a Markdown link in the form [link text](link).
138 139
                $message .= _('You can engage other users in a conversation, subscribe to more people or [join groups](%%action.groups%%).');
            } else {
140
                // TRANS: Empty list message for page with replies for a user for all logged in users but the user themselves.
141 142
                // TRANS: %1$s is a user nickname and %2$s is the same but with a prepended '@' character. This message contains a Markdown link in the form [link text](link).
                $message .= sprintf(_('You can try to [nudge %1$s](../%1$s) or [post something to them](%%%%action.newnotice%%%%?content=%2$s).'), $this->target->getNickname(), '@' . $this->target->getNickname());
143
            }
144
        } else {
145 146
            // TRANS: Empty list message for page with replies for a user for not logged in users.
            // TRANS: %1$s is a user nickname. This message contains a Markdown link in the form [link text](link).
147
            $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to them.'), $this->target->getNickname());
148 149 150 151 152 153 154
        }

        $this->elementStart('div', 'guide');
        $this->raw(common_markup_to_html($message));
        $this->elementEnd('div');
    }

155
    public function isReadOnly($args)
156 157 158
    {
        return true;
    }
159
}