3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2008, 2009, StatusNet, 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('STATUSNET') && !defined('LACONICA')) { exit(1); }
22 // @todo FIXME: documentation missing.
23 class TagAction extends Action
27 function prepare($args)
29 parent::prepare($args);
30 $taginput = $this->trimmed('tag');
31 $this->tag = common_canonical_tag($taginput);
34 common_redirect(common_local_url('publictagcloud'), 301);
38 if ($this->tag != $taginput) {
39 common_redirect(common_local_url('tag', array('tag' => $this->tag)),
44 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
46 common_set_returnto($this->selfUrl());
48 $this->notice = Notice_tag::getStream($this->tag, (($this->page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
50 if($this->page > 1 && $this->notice->N == 0){
51 // TRANS: Server error when page not found (404).
52 $this->serverError(_('No such page.'),$code=404);
58 function showSections()
60 $pop = new PopularNoticeSection($this);
66 if ($this->page == 1) {
67 // TRANS: Title for first page of notices with tags.
68 // TRANS: %s is the tag.
69 return sprintf(_('Notices tagged with %s'), $this->tag);
71 // TRANS: Title for all but the first page of notices with tags.
72 // TRANS: %1$s is the tag, %2$d is the page number.
73 return sprintf(_('Notices tagged with %1$s, page %2$d'),
79 function handle($args)
81 parent::handle($args);
88 return array(new Feed(Feed::RSS1,
89 common_local_url('tagrss',
90 array('tag' => $this->tag)),
91 // TRANS: Link label for feed on "notices with tag" page.
92 // TRANS: %s is the tag the feed is for.
93 sprintf(_('Notice feed for tag %s (RSS 1.0)'),
96 common_local_url('ApiTimelineTag',
97 array('format' => 'rss',
98 'tag' => $this->tag)),
99 // TRANS: Link label for feed on "notices with tag" page.
100 // TRANS: %s is the tag the feed is for.
101 sprintf(_('Notice feed for tag %s (RSS 2.0)'),
104 common_local_url('ApiTimelineTag',
105 array('format' => 'atom',
106 'tag' => $this->tag)),
107 // TRANS: Link label for feed on "notices with tag" page.
108 // TRANS: %s is the tag the feed is for.
109 sprintf(_('Notice feed for tag %s (Atom)'),
113 function showContent()
115 if(Event::handle('StartTagShowContent', array($this))) {
117 $nl = new NoticeList($this->notice, $this);
121 $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
122 $this->page, 'tag', array('tag' => $this->tag));
124 Event::handle('EndTagShowContent', array($this));
128 function isReadOnly($args)