From d6c817be8dfb9d41ea3f19cecd90619cde97209d Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Thu, 11 Feb 2016 22:43:34 +0100 Subject: opensearch support --- www/index.php | 11 ++++++++++- www/opensearchdescription.php | 17 +++++++++++++++++ www/www-header.php | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 www/opensearchdescription.php (limited to 'www') diff --git a/www/index.php b/www/index.php index 54d5da8..dbdcfd2 100644 --- a/www/index.php +++ b/www/index.php @@ -137,11 +137,20 @@ $urlSortRelevance = buildLink( ); $urlSortDate = $urlSortRelevance . '&sort=date'; +if (isset($_GET['format']) && $_GET['format'] == 'opensearch') { + $template = 'opensearch'; + $baseLink .= '&format=opensearch'; + header('Content-type: application/atom+xml'); +} else { + $template = 'search'; +} + render( - 'search', + $template, array( 'queryTime' => round($timeEnd - $timeBegin, 2) . 's', 'query' => $query, + 'fullUrl' => Helper::fullUrl($baseLink), 'cleanQuery' => $cleanQuery, 'urlNoSite' => $urlNoSite, 'site' => $site, diff --git a/www/opensearchdescription.php b/www/opensearchdescription.php new file mode 100644 index 0000000..443546e --- /dev/null +++ b/www/opensearchdescription.php @@ -0,0 +1,17 @@ + Helper::fullUrl('/'), + ) +); +?> \ No newline at end of file diff --git a/www/www-header.php b/www/www-header.php index da0d74c..e7c4542 100644 --- a/www/www-header.php +++ b/www/www-header.php @@ -27,7 +27,7 @@ function render($tplname, $vars = array(), $return = false) //$vars['htmlhelper'] = new HtmlHelper(); } $vars['apptitle'] = 'cweiske.de search'; - $vars['baseurl'] = '/'; + $vars['baseUrl'] = '/'; $template = $GLOBALS['twig']->loadTemplate($tplname . '.htm'); if ($return) { -- cgit v1.2.3