3 * StatusNet, the distributed open-source microblogging tool
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.
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.
21 * You should have received a copy of the GNU Affero General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 * @author Evan Prodromou <evan@status.net>
27 * @author Zach Copley <zach@status.net>
28 * @author Shashi Gowda <connect2shashi@gmail.com>
29 * @copyright 2009 StatusNet, Inc.
30 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
31 * @link http://status.net/
34 if (!defined('STATUSNET') && !defined('LACONICA')) {
38 require_once INSTALLDIR.'/lib/peopletaglist.php';
40 define('PEOPLETAG_CACHE_WINDOW', PEOPLETAGS_PER_PAGE*3 + 1);
42 class PeopletagAction extends Action
47 function isReadOnly($args)
54 if ($this->page == 1) {
55 // TRANS: Title for list page.
56 // TRANS: %s is a list.
57 return sprintf(_('Public list %s'), $this->tag);
59 // TRANS: Title for list page.
60 // TRANS: %1$s is a list, %2$d is a page number.
61 return sprintf(_('Public list %1$s, page %2$d'), $this->tag, $this->page);
65 function prepare($args)
67 parent::prepare($args);
68 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
70 $tag_arg = $this->arg('tag');
71 $tag = common_canonical_tag($tag_arg);
73 // Permanent redirect on non-canonical nickname
75 if ($tag_arg != $tag) {
76 $args = array('tag' => $nickname);
77 if ($this->page && $this->page != 1) {
78 $args['page'] = $this->page;
80 common_redirect(common_local_url('peopletag', $args), 301);
88 function handle($args)
90 parent::handle($args);
94 function showLocalNav()
96 $nav = new PublicGroupNav($this);
100 function showAnonymousMessage()
103 // TRANS: Message for anonymous users on list page.
104 // TRANS: This message contains Markdown links in the form [description](link).
105 _('Lists are how you sort similar ' .
106 'people on %%site.name%%, a [micro-blogging]' .
107 '(http://en.wikipedia.org/wiki/Micro-blogging) service ' .
108 'based on the Free Software [StatusNet](http://status.net/) tool. ' .
109 'You can then easily keep track of what they ' .
110 'are doing by subscribing to the list\'s timeline.' );
111 $this->elementStart('div', array('id' => 'anon_notice'));
112 $this->raw(common_markup_to_html($notice));
113 $this->elementEnd('div');
116 function showContent()
118 $offset = ($this->page-1) * PEOPLETAGS_PER_PAGE;
119 $limit = PEOPLETAGS_PER_PAGE + 1;
121 $ptags = new Profile_list();
122 $ptags->tag = $this->tag;
124 $user = common_current_user();
127 $ckey = sprintf('profile_list:tag:%s', $this->tag);
128 $ptags->private = false;
129 $ptags->orderBy('profile_list.modified DESC');
131 $c = Cache::instance();
132 if ($offset+$limit <= PEOPLETAG_CACHE_WINDOW && !empty($c)) {
133 $cached_ptags = Profile_list::getCached($ckey, $offset, $limit);
134 if ($cached_ptags === false) {
135 $ptags->limit(0, PEOPLETAG_CACHE_WINDOW);
138 Profile_list::setCache($ckey, $ptags, $offset, $limit);
140 $ptags = clone($cached_ptags);
143 $ptags->limit($offset, $limit);
147 $ptags->whereAdd('(profile_list.private = false OR (' .
148 ' profile_list.tagger =' . $user->id .
149 ' AND profile_list.private = true) )');
151 $ptags->orderBy('profile_list.modified DESC');
155 $pl = new PeopletagList($ptags, $this);
158 $this->pagination($this->page > 1, $cnt > PEOPLETAGS_PER_PAGE,
159 $this->page, 'peopletag', array('tag' => $this->tag));
162 function showSections()