]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/tag.php
take an argument for fixup_utf8
[quix0rs-gnu-social.git] / actions / tag.php
1 <?php
2 /*
3  * Laconica - a distributed open-source microblogging tool
4  * Copyright (C) 2008, Controlez-Vous, Inc.
5  *
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.
10  *
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.
15  *
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/>.
18  */
19
20 if (!defined('LACONICA')) { exit(1); }
21
22 class TagAction extends Action
23 {
24     function prepare($args)
25     {
26         parent::prepare($args);
27         $taginput = $this->trimmed('tag');
28         $this->tag = common_canonical_tag($taginput);
29
30         if (!$this->tag) {
31             common_redirect(common_local_url('publictagcloud'), 301);
32             return false;
33         }
34
35         if ($this->tag != $taginput) {
36             common_redirect(common_local_url('tag', array('tag' => $this->tag)),
37                             301);
38             return false;
39         }
40
41         $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
42
43         common_set_returnto($this->selfUrl());
44
45         return true;
46     }
47
48     function showSections()
49     {
50         $pop = new PopularNoticeSection($this);
51         $pop->show();
52     }
53
54
55     function title()
56     {
57         if ($this->page == 1) {
58             return sprintf(_("Notices tagged with %s"), $this->tag);
59         } else {
60             return sprintf(_("Notices tagged with %s, page %d"),
61                            $this->tag,
62                            $this->page);
63         }
64     }
65
66     function handle($args)
67     {
68         parent::handle($args);
69
70         $this->showPage();
71     }
72
73     function getFeeds()
74     {
75         return array(new Feed(Feed::RSS1,
76                               common_local_url('tagrss', array('tag' => $this->tag)),
77                               sprintf(_('Feed for tag %s'), $this->tag)));
78     }
79
80     /**
81      * Output document relationship links
82      *
83      * @return void
84      */
85     function showRelationshipLinks()
86     {
87         $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
88                                      $this->page, 'tag', array('tag' => $this->tag));
89     }
90
91     function showPageNotice()
92     {
93         return sprintf(_('Messages tagged "%s", most recent first'), $this->tag);
94     }
95
96     function showContent()
97     {
98         $notice = Notice_tag::getStream($this->tag, (($this->page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
99
100         $nl = new NoticeList($notice, $this);
101
102         $cnt = $nl->show();
103
104         $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
105                           $this->page, 'tag', array('tag' => $this->tag));
106     }
107
108     function isReadOnly($args)
109     {
110         return true;
111     }
112 }