tagrss.php 2.07 KB
Newer Older
tryggvib's avatar
tryggvib committed
1 2 3
<?php
/*
 * Laconica - a distributed open-source microblogging tool
4
 * Copyright (C) 2008, 2009, Control Yourself, Inc.
tryggvib's avatar
tryggvib committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

if (!defined('LACONICA')) { exit(1); }

require_once(INSTALLDIR.'/lib/rssaction.php');

// Formatting of RSS handled by Rss10Action

26 27
class TagrssAction extends Rss10Action
{
Robin Millette's avatar
Robin Millette committed
28
    var $tag;
tryggvib's avatar
tryggvib committed
29

Robin Millette's avatar
Robin Millette committed
30 31 32
    function prepare($args) {
        parent::prepare($args);
        $tag = common_canonical_tag($this->trimmed('tag'));
33 34
        $this->tag = Notice_tag::staticGet('tag', $tag);
        if (!$this->tag) {
35
            $this->clientError(_('No such tag.'));
36 37 38 39 40
            return false;
        } else {
            return true;
        }
    }
tryggvib's avatar
tryggvib committed
41

Robin Millette's avatar
Robin Millette committed
42
    function getNotices($limit=0)
43
    {
44
        $tag = $this->tag;
tryggvib's avatar
tryggvib committed
45

46
        if (is_null($tag)) {
Evan Prodromou's avatar
Evan Prodromou committed
47
            return null;
48
        }
tryggvib's avatar
tryggvib committed
49

50 51 52 53
        $notice = Notice_tag::getStream($tag->tag, 0, ($limit == 0) ? NOTICES_PER_PAGE : $limit);
        while ($notice->fetch()) {
            $notices[] = clone($notice);
        }
tryggvib's avatar
tryggvib committed
54

55 56
        return $notices;
    }
tryggvib's avatar
tryggvib committed
57

Robin Millette's avatar
Robin Millette committed
58
    function getChannel()
59
    {
Robin Millette's avatar
Robin Millette committed
60
        $tagname = $this->tag->tag;
61 62 63 64 65 66
        $c = array('url' => common_local_url('tagrss', array('tag' => $tagname)),
               'title' => $tagname,
               'link' => common_local_url('tagrss', array('tag' => $tagname)),
               'description' => sprintf(_('Microblog tagged with %s'), $tagname));
        return $c;
    }
67

68
    function isReadOnly($args)
69 70 71
    {
        return true;
    }
tryggvib's avatar
tryggvib committed
72
}