xref: /dokuwiki/lib/exe/opensearch.php (revision f9a94e78392d6a178b0e7f29a005688fc44e5cc3)
1<?php
2/**
3 * DokuWiki OpenSearch creator
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @link       http://www.opensearch.org/
7 * @author     Mike Frysinger <vapier@gentoo.org>
8 * @author     Andreas Gohr <andi@splitbrain.org>
9 */
10
11if (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/../../');
12if (!defined('NOSESSION')) define('NOSESSION', true); // we do not use a session or authentication here (better caching)
13if (!defined('NL')) define('NL', "\n");
14require_once(DOKU_INC . 'inc/init.php');
15
16// try to be clever about the favicon location
17if (file_exists(DOKU_INC . 'favicon.ico')) {
18    $ico = DOKU_URL . 'favicon.ico';
19} elseif (file_exists(tpl_incdir() . 'images/favicon.ico')) {
20    $ico = DOKU_URL . 'lib/tpl/' . $conf['template'] . '/images/favicon.ico';
21} elseif (file_exists(tpl_incdir() . 'favicon.ico')) {
22    $ico = DOKU_URL . 'lib/tpl/' . $conf['template'] . '/favicon.ico';
23} else {
24    $ico = DOKU_URL . 'lib/tpl/dokuwiki/images/favicon.ico';
25}
26
27// output
28header('Content-Type: application/opensearchdescription+xml; charset=utf-8');
29echo '<?xml version="1.0"?>' . NL;
30echo '<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">' . NL;
31echo '  <ShortName>' . hsc($conf['title']) . '</ShortName>' . NL;
32echo '  <Image width="16" height="16" type="image/x-icon">' . $ico . '</Image>' . NL;
33echo '  <Url type="text/html" template="' . DOKU_URL . DOKU_SCRIPT . '?do=search&amp;id={searchTerms}" />' . NL;
34echo '  <Url type="application/x-suggestions+json" template="' .
35    DOKU_URL . 'lib/exe/ajax.php?call=suggestions&amp;q={searchTerms}" />' . NL;
36echo '</OpenSearchDescription>' . NL;
37