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