]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/subscriptions.php
shortenLinks with a capital L
[quix0rs-gnu-social.git] / actions / subscriptions.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * List of a user's subscriptions
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  Social
23  * @package   StatusNet
24  * @author    Evan Prodromou <evan@status.net>
25  * @author    Sarven Capadisli <csarven@status.net>
26  * @copyright 2008-2009 StatusNet, Inc.
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('GNUSOCIAL')) { exit(1); }
32
33 /**
34  * A list of the user's subscriptions
35  *
36  * @category Social
37  * @package  StatusNet
38  * @author   Evan Prodromou <evan@status.net>
39  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
40  * @link     http://status.net/
41  */
42 class SubscriptionsAction extends GalleryAction
43 {
44     function title()
45     {
46         if ($this->page == 1) {
47             // TRANS: Header for subscriptions overview for a user (first page).
48             // TRANS: %s is a user nickname.
49             return sprintf(_('%s subscriptions'), $this->target->getNickname());
50         } else {
51             // TRANS: Header for subscriptions overview for a user (not first page).
52             // TRANS: %1$s is a user nickname, %2$d is the page number.
53             return sprintf(_('%1$s subscriptions, page %2$d'),
54                            $this->target->getNickname(),
55                            $this->page);
56         }
57     }
58
59     function showPageNotice()
60     {
61         if ($this->scoped instanceof Profile && $this->scoped->sameAs($this->getTarget())) {
62             $this->element('p', null,
63                            // TRANS: Page notice for page with an overview of all subscriptions
64                            // TRANS: of the logged in user's own profile.
65                            _('These are the people whose notices '.
66                              'you listen to.'));
67         } else {
68             $this->element('p', null,
69                            // TRANS: Page notice for page with an overview of all subscriptions of a user other
70                            // TRANS: than the logged in user. %s is the user nickname.
71                            sprintf(_('These are the people whose '.
72                                      'notices %s listens to.'),
73                                    $this->target->getNickname()));
74         }
75     }
76
77     function getAllTags()
78     {
79         return $this->getTags('subscribed', 'subscriber');
80     }
81
82     function showContent()
83     {
84         if (Event::handle('StartShowSubscriptionsContent', array($this))) {
85             parent::showContent();
86
87             $offset = ($this->page-1) * PROFILES_PER_PAGE;
88             $limit =  PROFILES_PER_PAGE + 1;
89
90             $cnt = 0;
91
92             if ($this->tag) {
93                 $subscriptions = $this->target->getTaggedSubscriptions($this->tag, $offset, $limit);
94             } else {
95                 $subscriptions = $this->target->getSubscribed($offset, $limit);
96             }
97
98             if ($subscriptions) {
99                 $subscriptions_list = new SubscriptionsList($subscriptions, $this->target, $this);
100                 $cnt = $subscriptions_list->show();
101                 if (0 == $cnt) {
102                     $this->showEmptyListMessage();
103                 }
104             }
105
106             $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE,
107                               $this->page, 'subscriptions',
108                               array('nickname' => $this->target->getNickname()));
109
110
111             Event::handle('EndShowSubscriptionsContent', array($this));
112         }
113     }
114
115     function showScripts()
116     {
117         parent::showScripts();
118         $this->autofocus('tag');
119     }
120
121     function showEmptyListMessage()
122     {
123         if ($this->scoped instanceof Profile && $this->target->id === $this->scoped->id) {
124                 // TRANS: Subscription list text when the logged in user has no subscriptions.
125                 // TRANS: This message contains Markdown URLs. The link description is between
126                 // TRANS: square brackets, and the link between parentheses. Do not separate "]("
127                 // TRANS: and do not change the URL part.
128                 $message = _('You\'re not listening to anyone\'s notices right now, try subscribing to people you know. '.
129                              'Try [people search](%%action.peoplesearch%%), look for members in groups you\'re interested '.
130                              'in and in our [featured users](%%action.featured%%).');
131         } else {
132             // TRANS: Subscription list text when looking at the subscriptions for a of a user that has none
133             // TRANS: as an anonymous user. %s is the user nickname.
134             $message = sprintf(_('%s is not listening to anyone.'), $this->target->getNickname());
135         }
136
137         $this->elementStart('div', 'guide');
138         $this->raw(common_markup_to_html($message));
139         $this->elementEnd('div');
140     }
141
142     /**
143      * Link to feeds of subscriptions
144      *
145      * @return array of Feed objects
146      */
147     function getFeeds()
148     {
149         return array(new Feed(Feed::ATOM,
150                               common_local_url('AtomPubSubscriptionFeed',
151                                                array('subscriber' => $this->target->id)),
152                               // TRANS: Atom feed title. %s is a profile nickname.
153                               sprintf(_('Subscription feed for %s (Atom)'),
154                                       $this->target->getNickname())));
155     }
156 }