]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/opensearch.php
* check usage of 'people' in UI and change it to 'users' or something else in most...
[quix0rs-gnu-social.git] / actions / opensearch.php
1 <?php
2
3 /**
4  * Opensearch action class.
5  *
6  * PHP version 5
7  *
8  * @category Action
9  * @package  StatusNet
10  * @author   Evan Prodromou <evan@status.net>
11  * @author   Robin Millette <millette@status.net>
12  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
13  * @link     http://status.net/
14  *
15  * StatusNet - the distributed open-source microblogging tool
16  * Copyright (C) 2008, 2009, StatusNet, Inc.
17  *
18  * This program is free software: you can redistribute it and/or modify
19  * it under the terms of the GNU Affero General Public License as published by
20  * the Free Software Foundation, either version 3 of the License, or
21  * (at your option) any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26  * GNU Affero General Public License for more details.
27  *
28  * You should have received a copy of the GNU Affero General Public License
29  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
30  */
31
32 if (!defined('STATUSNET') && !defined('LACONICA')) {
33     exit(1);
34 }
35
36 /**
37  * Opensearch action class.
38  *
39  * Formatting of RSS handled by Rss10Action
40  *
41  * @category Action
42  * @package  StatusNet
43  * @author   Evan Prodromou <evan@status.net>
44  * @author   Robin Millette <millette@status.net>
45  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
46  * @link     http://status.net/
47  */
48 class OpensearchAction extends Action
49 {
50     /**
51      * Class handler.
52      *
53      * @param array $args query arguments
54      * 
55      * @return boolean false if user doesn't exist
56      */
57     function handle($args)
58     {
59         parent::handle($args);
60         $type       = $this->trimmed('type');
61         $short_name = '';
62         if ($type == 'people') {
63             $type       = 'peoplesearch';
64             $short_name = _('User Search');
65         } else {
66             $type       = 'noticesearch';
67             $short_name = _('Notice Search');
68         }
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         $this->element('ShortName', null, $short_name);
74         $this->element('Contact', null, common_config('site', 'email'));
75         $this->element('Url', array('type' => 'text/html', 'method' => 'get',
76                        'template' => str_replace('---', '{searchTerms}', common_local_url($type, array('q' => '---')))));
77         $this->element('Image', array('height' => 16, 'width' => 16, 'type' => 'image/vnd.microsoft.icon'), common_path('favicon.ico'));
78         $this->element('Image', array('height' => 50, 'width' => 50, 'type' => 'image/png'), theme_path('logo.png'));
79         $this->element('AdultContent', null, 'false');
80         $this->element('Language', null, common_language());
81         $this->element('OutputEncoding', null, 'UTF-8');
82         $this->element('InputEncoding', null, 'UTF-8');
83         $this->elementEnd('OpenSearchDescription');
84         $this->endXML();
85     }
86
87     function isReadOnly($args)
88     {
89         return true;
90     }
91 }
92