]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/tag.php
Link rtsp, mms & tel URI schemes, correct pseudo-protocol ones.
[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         }
38
39         $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
40         return true;
41     }
42
43     function title()
44     {
45         if ($this->page == 1) {
46             return sprintf(_("Notices tagged with %s"), $this->tag);
47         } else {
48             return sprintf(_("Notices tagged with %s, page %d"),
49                            $this->tag,
50                            $this->page);
51         }
52     }
53
54     function handle($args)
55     {
56         parent::handle($args);
57
58         $this->showPage();
59     }
60
61     function showFeeds()
62     {
63         $this->element('link', array('rel' => 'alternate',
64                                      'href' => common_local_url('tagrss', array('tag' => $this->tag)),
65                                      'type' => 'application/rss+xml',
66                                      'title' => sprintf(_('Feed for tag %s'), $this->tag)));
67     }
68
69     function showPageNotice()
70     {
71         return sprintf(_('Messages tagged "%s", most recent first'), $this->tag);
72     }
73
74     function showExportData()
75     {
76         $fl = new FeedList($this);
77         $fl->show(array(0=>array('href'=>common_local_url('tagrss', array('tag' => $this->tag)),
78                                  'type' => 'rss',
79                                  'version' => 'RSS 1.0',
80                                  'item' => 'tagrss')));
81     }
82
83     function showContent()
84     {
85         $notice = Notice_tag::getStream($this->tag, (($this->page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1);
86
87         $nl = new NoticeList($notice, $this);
88
89         $cnt = $nl->show();
90
91         $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
92                           $this->page, 'tag', array('tag' => $this->tag));
93     }
94 }