]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/peopletagsubscriptions.php
Merge branch 'compound-keys-fix' into 1.0.x
[quix0rs-gnu-social.git] / actions / peopletagsubscriptions.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * People tags subscribed to by a user
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    Shashi Gowda <connect2shashi@gmail.com>
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('STATUSNET') && !defined('LACONICA')) {
31     exit(1);
32 }
33
34 require_once INSTALLDIR.'/lib/peopletaglist.php';
35
36 class PeopletagsubscriptionsAction extends Action
37 {
38     var $page = null;
39     var $profile = null;
40
41     function isReadOnly($args)
42     {
43         return true;
44     }
45
46     function title()
47     {
48         if ($this->page == 1) {
49             // TRANS: Title for page that displays lists subscribed to by a user.
50             // TRANS: %s is a profile nickname.
51             return sprintf(_('Lists subscribed to by %s'), $this->profile->nickname);
52         } else {
53             // TRANS: Title for page that displays lists subscribed to by a user.
54             // TRANS: %1$s is a profile nickname, %2$d is a page number.
55             return sprintf(_('Lists subscribed to by %1$s, page %2$d'), $this->profile->nickname, $this->page);
56         }
57     }
58
59     function prepare($args)
60     {
61         parent::prepare($args);
62
63         if (common_config('singleuser', 'enabled')) {
64             $nickname_arg = User::singleUserNickname();
65         } else {
66             $nickname_arg = $this->arg('nickname');
67         }
68
69         $nickname = common_canonical_nickname($nickname_arg);
70
71         // Permanent redirect on non-canonical nickname
72
73         if ($nickname_arg != $nickname) {
74             $args = array('nickname' => $nickname);
75             if ($this->arg('page') && $this->arg('page') != 1) {
76                 $args['page'] = $this->arg['page'];
77             }
78             common_redirect(common_local_url('peopletagsbyuser', $args), 301);
79             return false;
80         }
81
82         $user = User::staticGet('nickname', $nickname);
83
84         if (!$user) {
85             // TRANS: Client error displayed trying to perform an action related to a non-existing user.
86             $this->clientError(_('No such user.'), 404);
87             return false;
88         }
89
90         $this->profile = $user->getProfile();
91
92         if (!$this->profile) {
93             // TRANS: Error message displayed when referring to a user without a profile.
94             $this->serverError(_('User has no profile.'));
95             return false;
96         }
97
98         $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
99
100         return true;
101     }
102
103     function handle($args)
104     {
105         parent::handle($args);
106         $this->showPage();
107     }
108
109     function showAnonymousMessage()
110     {
111         $notice =
112           // TRANS: Message displayed for anonymous users on page that displays lists subscribed to by a user.
113           // TRANS: This message contains Markdown links in the form [description](links).
114           // TRANS: %s is a profile nickname.
115           sprintf(_('These are lists subscribed to by **%s**. ' .
116                     'Lists are how you sort similar ' .
117                     'people on %%%%site.name%%%%, a [micro-blogging]' .
118                     '(http://en.wikipedia.org/wiki/Micro-blogging) service ' .
119                     'based on the Free Software [StatusNet](http://status.net/) tool. ' .
120                     'You can easily keep track of what they ' .
121                     'are doing by subscribing to the list\'s timeline.' ), $this->profile->nickname);
122         $this->elementStart('div', array('id' => 'anon_notice'));
123         $this->raw(common_markup_to_html($notice));
124         $this->elementEnd('div');
125     }
126
127     function showContent()
128     {
129         $offset = ($this->page-1) * PEOPLETAGS_PER_PAGE;
130         $limit  = PEOPLETAGS_PER_PAGE + 1;
131
132         $ptags = $this->profile->getTagSubscriptions($offset, $limit);
133
134         $pl = new PeopletagList($ptags, $this);
135         $cnt = $pl->show();
136
137         $this->pagination($this->page > 1, $cnt > PEOPLETAGS_PER_PAGE,
138                           $this->page, 'peopletagsubscriptions', array('nickname' => $this->profile->id));
139     }
140
141     function showObjectNav()
142     {
143         $nav = new PeopletagNav($this, $this->profile);
144         $nav->show();
145     }
146
147     function showProfileBlock()
148     {
149         $block = new AccountProfileBlock($this, $this->profile);
150         $block->show();
151     }
152
153     function showSections()
154     {
155         #TODO: tags with most subscribers
156         #TODO: tags with most "members"
157     }
158 }