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