noticesearchrss.php 2.85 KB
Newer Older
1
<?php
Robin Millette's avatar
Robin Millette committed
2 3 4 5 6 7
/**
 * RSS feed for notice search action class.
 *
 * PHP version 5
 *
 * @category Action
8
 * @package  StatusNet
9 10
 * @author   Evan Prodromou <evan@status.net>
 * @author   Robin Millette <millette@status.net>
Robin Millette's avatar
Robin Millette committed
11
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
12
 * @link     http://status.net/
Robin Millette's avatar
Robin Millette committed
13
 *
14
 * StatusNet - the distributed open-source microblogging tool
15
 * Copyright (C) 2008, 2009, StatusNet, Inc.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
 *
 * 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/>.
 */

31
if (!defined('STATUSNET') && !defined('LACONICA')) {
Robin Millette's avatar
Robin Millette committed
32 33
    exit(1);
}
34

Robin Millette's avatar
Robin Millette committed
35
require_once INSTALLDIR.'/lib/rssaction.php';
36

Robin Millette's avatar
Robin Millette committed
37 38 39 40 41 42
/**
 * RSS feed for notice search action class.
 *
 * Formatting of RSS handled by Rss10Action
 *
 * @category Action
43
 * @package  StatusNet
44 45
 * @author   Evan Prodromou <evan@status.net>
 * @author   Robin Millette <millette@status.net>
Robin Millette's avatar
Robin Millette committed
46
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
47
 * @link     http://status.net/
Robin Millette's avatar
Robin Millette committed
48
 */
49 50
class NoticesearchrssAction extends Rss10Action
{
51

52 53
    function init()
    {
54 55
        return true;
    }
56

Robin Millette's avatar
Robin Millette committed
57
    function getNotices($limit=0)
58
    {
59

60 61
        $q = $this->trimmed('q');
        $notices = array();
62

63
        $notice = new Notice();
64

65
        $search_engine = $notice->getSearchEngine('notice');
66
        $search_engine->set_sort_mode('chron');
67

68
        if (!$limit) $limit = 20;
69
        $search_engine->limit(0, $limit, true);
70 71 72 73 74
        if (false === $search_engine->query($q)) {
            $cnt = 0;
        } else {
            $cnt = $notice->find();
        }
75

76 77 78 79
        if ($cnt > 0) {
            while ($notice->fetch()) {
                $notices[] = clone($notice);
            }
80
        }
81

82 83
        return $notices;
    }
84

Robin Millette's avatar
Robin Millette committed
85
    function getChannel()
86
    {
87 88
        $q = $this->trimmed('q');
        $c = array('url' => common_local_url('noticesearchrss', array('q' => $q)),
89
                   'title' => sprintf(_('Updates with "%s"'), $q),
90
                   'link' => common_local_url('noticesearch', array('q' => $q)),
91 92
                   'description' => sprintf(_('Updates matching search term "%1$s" on %2$s!'),
                                            $q, common_config('site', 'name')));
93 94
        return $c;
    }
95

Robin Millette's avatar
Robin Millette committed
96
    function getImage()
97
    {
Evan Prodromou's avatar
Evan Prodromou committed
98
        return null;
99
    }
100

101
    function isReadOnly($args)
102 103 104
    {
        return true;
    }
105
}