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