subscribers.php 5.33 KB
Newer Older
1
<?php
Evan Prodromou's avatar
Evan Prodromou committed
2
/**
3
 * StatusNet, the distributed open-source microblogging tool
4
 *
Evan Prodromou's avatar
Evan Prodromou committed
5 6 7 8 9
 * List a user's subscribers
 *
 * 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/>.
Evan Prodromou's avatar
Evan Prodromou committed
21 22
 *
 * @category  Social
23
 * @package   StatusNet
24 25
 * @author    Evan Prodromou <evan@status.net>
 * @author    Sarven Capadisli <csarven@status.net>
26
 * @copyright 2008-2009 StatusNet, Inc.
Evan Prodromou's avatar
Evan Prodromou committed
27
 * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28
 * @link      http://status.net/
29 30
 */

31
if (!defined('STATUSNET') && !defined('LACONICA')) {
Evan Prodromou's avatar
Evan Prodromou committed
32 33
    exit(1);
}
34

Evan Prodromou's avatar
Evan Prodromou committed
35 36 37 38
/**
 * List a user's subscribers
 *
 * @category Social
39
 * @package  StatusNet
40
 * @author   Evan Prodromou <evan@status.net>
Evan Prodromou's avatar
Evan Prodromou committed
41
 * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
42
 * @link     http://status.net/
Evan Prodromou's avatar
Evan Prodromou committed
43
 */
44 45
class SubscribersAction extends GalleryAction
{
Evan Prodromou's avatar
Evan Prodromou committed
46
    function title()
47
    {
Evan Prodromou's avatar
Evan Prodromou committed
48
        if ($this->page == 1) {
49 50
            // TRANS: Header for list of subscribers for a user (first page).
            // TRANS: %s is the user's nickname.
51
            return sprintf(_('%s subscribers'), $this->target->getNickname());
Evan Prodromou's avatar
Evan Prodromou committed
52
        } else {
53 54
            // TRANS: Header for list of subscribers for a user (not first page).
            // TRANS: %1$s is the user's nickname, $2$d is the page number.
55
            return sprintf(_('%1$s subscribers, page %2$d'),
56
                           $this->target->getNickname(),
Evan Prodromou's avatar
Evan Prodromou committed
57 58
                           $this->page);
        }
59 60
    }

Evan Prodromou's avatar
Evan Prodromou committed
61
    function showPageNotice()
62
    {
63
        if ($this->scoped instanceof Profile && $this->scoped->id === $this->target->id) {
Evan Prodromou's avatar
Evan Prodromou committed
64
            $this->element('p', null,
65 66
                           // TRANS: Page notice for page with an overview of all subscribers
                           // TRANS: of the logged in user's own profile.
Evan Prodromou's avatar
Evan Prodromou committed
67 68
                           _('These are the people who listen to '.
                             'your notices.'));
69
        } else {
Evan Prodromou's avatar
Evan Prodromou committed
70
            $this->element('p', null,
71 72
                           // TRANS: Page notice for page with an overview of all subscribers of a user other
                           // TRANS: than the logged in user. %s is the user nickname.
Evan Prodromou's avatar
Evan Prodromou committed
73 74
                           sprintf(_('These are the people who '.
                                     'listen to %s\'s notices.'),
75
                                   $this->target->getNickname()));
76 77 78
        }
    }

Evan Prodromou's avatar
Evan Prodromou committed
79
    function showContent()
80
    {
81 82
        parent::showContent();

Evan Prodromou's avatar
Evan Prodromou committed
83 84
        $offset = ($this->page-1) * PROFILES_PER_PAGE;
        $limit =  PROFILES_PER_PAGE + 1;
85

86 87
        $cnt = 0;

88
        if ($this->tag) {
89
            $subscribers = $this->target->getTaggedSubscribers($this->tag, $offset, $limit);
90
        } else {
91
            $subscribers = $this->target->getSubscribers($offset, $limit);
92
        }
93

Evan Prodromou's avatar
Evan Prodromou committed
94
        if ($subscribers) {
95
            $subscribers_list = new SubscribersList($subscribers, $this->target, $this);
96
            $cnt = $subscribers_list->show();
97 98 99
            if (0 == $cnt) {
                $this->showEmptyListMessage();
            }
Evan Prodromou's avatar
Evan Prodromou committed
100
        }
101

Evan Prodromou's avatar
Evan Prodromou committed
102 103
        $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
                          $this->page, 'subscribers',
104
                          array('nickname' => $this->target->getNickname()));
105
    }
106 107 108

    function showEmptyListMessage()
    {
109 110 111 112 113 114 115 116
        if ($this->scoped instanceof Profile && $this->target->id === $this->scoped->id) {
            // TRANS: Subscriber list text when the logged in user has no subscribers.
            $message = _('You have no subscribers. Try subscribing to people you know and they might return the favor.');
        } elseif ($this->scoped instanceof Profile) {
            // TRANS: Subscriber list text when looking at the subscribers for a of a user other
            // TRANS: than the logged in user that has no subscribers. %s is the user nickname.
            $message = sprintf(_('%s has no subscribers. Want to be the first?'), $this->target->getNickname());
        } else {
117 118 119 120 121
            // TRANS: Subscriber list text when looking at the subscribers for a of a user that has none
            // TRANS: as an anonymous user. %s is the user nickname.
            // TRANS: This message contains a Markdown URL. The link description is between
            // TRANS: square brackets, and the link between parentheses. Do not separate "]("
            // TRANS: and do not change the URL part.
122
            $message = sprintf(_('%s has no subscribers. Why not [register an account](%%%%action.register%%%%) and be the first?'), $this->target->getNickname());
123 124 125 126 127 128
        }

        $this->elementStart('div', 'guide');
        $this->raw(common_markup_to_html($message));
        $this->elementEnd('div');
    }
129 130 131 132 133

    function showSections()
    {
        parent::showSections();
    }
134
}