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);
93 function showLocalNav()
95 $nav = new PublicGroupNav($this);
99 function showAnonymousMessage()
102 // TRANS: Message for anonymous users on list page.
103 // TRANS: This message contains Markdown links in the form [description](link).
104 _('Lists are how you sort similar ' .
105 'people on %%site.name%%, a [micro-blogging]' .
106 '(http://en.wikipedia.org/wiki/Micro-blogging) service ' .
107 'based on the Free Software [StatusNet](http://status.net/) tool. ' .
108 'You can then easily keep track of what they ' .
109 'are doing by subscribing to the list\'s timeline.' );
110 $this->elementStart('div', array('id' => 'anon_notice'));
111 $this->raw(common_markup_to_html($notice));
112 $this->elementEnd('div');
115 function showContent()
117 $offset = ($this->page-1) * PEOPLETAGS_PER_PAGE;
118 $limit = PEOPLETAGS_PER_PAGE + 1;
120 $ptags = new Profile_list();
121 $ptags->tag = $this->tag;
123 $user = common_current_user();
126 $ckey = sprintf('profile_list:tag:%s', $this->tag);
127 $ptags->private = false;
128 $ptags->orderBy('profile_list.modified DESC');
130 $c = Cache::instance();
131 if ($offset+$limit <= PEOPLETAG_CACHE_WINDOW && !empty($c)) {
132 $cached_ptags = Profile_list::getCached($ckey, $offset, $limit);
133 if ($cached_ptags === false) {
134 $ptags->limit(0, PEOPLETAG_CACHE_WINDOW);
137 Profile_list::setCache($ckey, $ptags, $offset, $limit);
139 $ptags = clone($cached_ptags);
142 $ptags->limit($offset, $limit);
146 $ptags->whereAdd('(profile_list.private = false OR (' .
147 ' profile_list.tagger =' . $user->id .
148 ' AND profile_list.private = true) )');
150 $ptags->orderBy('profile_list.modified DESC');
154 $pl = new PeopletagList($ptags, $this);
157 $this->pagination($this->page > 1, $cnt > PEOPLETAGS_PER_PAGE,
158 $this->page, 'peopletag', array('tag' => $this->tag));
161 function showSections()