]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/opensearch.php
f9c6f4c5723f5ca56ebb1eb08c85499aabaeead1
[quix0rs-gnu-social.git] / actions / opensearch.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 OpensearchAction extends Action {
23
24     function handle($args)
25     {
26
27         parent::handle($args);
28
29         $type = $this->trimmed('type');
30
31         $short_name = '';
32         if ($type == 'people') {
33             $type = 'peoplesearch';
34             $short_name = _('People Search');
35         } else {
36             $short_name = _('Notice Search');
37             $type = 'noticesearch';
38         }
39
40         header('Content-Type: text/html');
41
42         common_start_xml();
43         common_element_start('OpenSearchDescription', array('xmlns' => 'http://a9.com/-/spec/opensearch/1.1/'));
44
45         $short_name =  common_config('site', 'name').' '.$short_name;
46         common_element('ShortName', null, $short_name);
47         common_element('Contact', null, common_config('site', 'email'));
48         common_element('Url', array('type' => 'text/html', 'method' => 'get',
49                        'template' => str_replace('---', '{searchTerms}', common_local_url($type, array('q' => '---')))));
50         common_element('Image', array('height' => 16, 'width' => 16, 'type' => 'image/vnd.microsoft.icon'), common_path('favicon.ico'));
51         common_element('Image', array('height' => 50, 'width' => 50, 'type' => 'image/png'), theme_path('logo.png'));
52         common_element('AdultContent', null, 'false');
53         common_element('Language', null, common_language());
54         common_element('OutputEncoding', null, 'UTF-8');
55         common_element('InputEncoding', null, 'UTF-8');
56
57         common_element_end('OpenSearchDescription');
58         common_end_xml();
59     }
60 }