opensearch.php 3.18 KB
Newer Older
matthew.gregg's avatar
matthew.gregg committed
1
<?php
Robin Millette's avatar
Robin Millette committed
2 3 4 5 6 7 8

/**
 * Opensearch action class.
 *
 * PHP version 5
 *
 * @category Action
9
 * @package  StatusNet
10 11
 * @author   Evan Prodromou <evan@status.net>
 * @author   Robin Millette <millette@status.net>
Robin Millette's avatar
Robin Millette committed
12
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
13
 * @link     http://status.net/
Robin Millette's avatar
Robin Millette committed
14
 *
15
 * StatusNet - the distributed open-source microblogging tool
16
 * Copyright (C) 2008, 2009, StatusNet, Inc.
matthew.gregg's avatar
matthew.gregg committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
 *
 * 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/>.
 */

32
if (!defined('STATUSNET')) {
Robin Millette's avatar
Robin Millette committed
33 34
    exit(1);
}
matthew.gregg's avatar
matthew.gregg committed
35

Robin Millette's avatar
Robin Millette committed
36 37 38 39 40 41
/**
 * Opensearch action class.
 *
 * Formatting of RSS handled by Rss10Action
 *
 * @category Action
42
 * @package  StatusNet
43 44
 * @author   Evan Prodromou <evan@status.net>
 * @author   Robin Millette <millette@status.net>
Robin Millette's avatar
Robin Millette committed
45
 * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
46
 * @link     http://status.net/
Robin Millette's avatar
Robin Millette committed
47
 */
48 49
class OpensearchAction extends Action
{
Robin Millette's avatar
Robin Millette committed
50 51 52 53 54 55 56
    /**
     * Class handler.
     *
     * @param array $args query arguments
     * 
     * @return boolean false if user doesn't exist
     */
57 58
    function handle($args)
    {
59
        parent::handle($args);
Robin Millette's avatar
Robin Millette committed
60
        $type       = $this->trimmed('type');
61 62
        $short_name = '';
        if ($type == 'people') {
Robin Millette's avatar
Robin Millette committed
63
            $type       = 'peoplesearch';
64 65
            $short_name = _('People Search');
        } else {
Robin Millette's avatar
Robin Millette committed
66
            $type       = 'noticesearch';
67 68
            $short_name = _('Notice Search');
        }
69
        header('Content-Type: application/opensearchdescription+xml');
70
        $this->startXML();
71
        $this->elementStart('OpenSearchDescription', array('xmlns' => 'http://a9.com/-/spec/opensearch/1.1/'));
72
        $short_name =  common_config('site', 'name').' '.$short_name;
73 74 75
        $this->element('ShortName', null, $short_name);
        $this->element('Contact', null, common_config('site', 'email'));
        $this->element('Url', array('type' => 'text/html', 'method' => 'get',
76
                       'template' => str_replace('---', '{searchTerms}', common_local_url($type, array('q' => '---')))));
77 78 79 80 81 82 83
        $this->element('Image', array('height' => 16, 'width' => 16, 'type' => 'image/vnd.microsoft.icon'), common_path('favicon.ico'));
        $this->element('Image', array('height' => 50, 'width' => 50, 'type' => 'image/png'), theme_path('logo.png'));
        $this->element('AdultContent', null, 'false');
        $this->element('Language', null, common_language());
        $this->element('OutputEncoding', null, 'UTF-8');
        $this->element('InputEncoding', null, 'UTF-8');
        $this->elementEnd('OpenSearchDescription');
84
        $this->endXML();
85
    }
86

87
    function isReadOnly($args)
88 89 90
    {
        return true;
    }
matthew.gregg's avatar
matthew.gregg committed
91
}
Robin Millette's avatar
Robin Millette committed
92