3 * Laconica - a distributed open-source microblogging tool
4 * Copyright (C) 2008, 2009, Control Yourself, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 if (!defined('LACONICA')) { exit(1); }
22 class TagAction extends Action
24 function prepare($args)
26 parent::prepare($args);
27 $taginput = $this->trimmed('tag');
28 $this->tag = common_canonical_tag($taginput);
31 common_redirect(common_local_url('publictagcloud'), 301);
35 if ($this->tag != $taginput) {
36 common_redirect(common_local_url('tag', array('tag' => $this->tag)),
41 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
43 common_set_returnto($this->selfUrl());
48 function showSections()
50 $pop = new PopularNoticeSection($this);
56 if ($this->page == 1) {
57 return sprintf(_("Notices tagged with %s"), $this->tag);
59 return sprintf(_("Notices tagged with %s, page %d"),
65 function handle($args)
67 parent::handle($args);
74 return array(new Feed(Feed::RSS1,
75 common_local_url('tagrss',
76 array('tag' => $this->tag)),
77 sprintf(_('Notice feed for tag %s (RSS 1.0)'),
80 common_local_url('api',
81 array('apiaction' => 'tags',
82 'method' => 'timeline',
83 'argument' => $this->tag.'.rss')),
84 sprintf(_('Notice feed for %s group (RSS 2.0)'),
87 common_local_url('api',
88 array('apiaction' => 'tags',
89 'method' => 'timeline',
90 'argument' => $this->tag.'.atom')),
91 sprintf(_('Notice feed for tag %s (Atom)'),
95 function showContent()
97 $notice = Notice_tag::getStream($this->tag, (($this->page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
99 $nl = new NoticeList($notice, $this);
103 $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
104 $this->page, 'tag', array('tag' => $this->tag));
107 function isReadOnly($args)