3 * Opensearch action class.
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/
14 * StatusNet - the distributed open-source microblogging tool
15 * Copyright (C) 2008, 2009, StatusNet, Inc.
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.
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.
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/>.
31 if (!defined('STATUSNET') && !defined('LACONICA')) {
36 * Opensearch action class.
38 * Formatting of RSS handled by Rss10Action
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/
47 class OpensearchAction extends Action
52 * @param array $args query arguments
54 * @return boolean false if user doesn't exist
56 function handle($args)
58 parent::handle($args);
59 $type = $this->trimmed('type');
61 if ($type == 'people') {
62 $type = 'peoplesearch';
63 // TRANS: ShortName in the OpenSearch interface when trying to find users.
64 $short_name = _('People Search');
66 $type = 'noticesearch';
67 // TRANS: ShortName in the OpenSearch interface when trying to find notices.
68 $short_name = _('Notice Search');
70 header('Content-Type: application/opensearchdescription+xml');
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');
88 function isReadOnly($args)