diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2006-10-11 20:21:25 +0000 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2006-10-11 20:21:25 +0000 |
commit | d81f562b712f2387fa02290bf2ca86392ab356f2 (patch) | |
tree | d666cdefbe6ac320827a2c6cb473581b46e22c4c /opensearch_desc.php | |
parent | 183851b06bd6c52f3cae5375f433da720d410447 (diff) |
Aktualisierung auf Version 1.8.1
Diffstat (limited to 'opensearch_desc.php')
-rw-r--r-- | opensearch_desc.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/opensearch_desc.php b/opensearch_desc.php new file mode 100644 index 00000000..59d61eee --- /dev/null +++ b/opensearch_desc.php @@ -0,0 +1,41 @@ +<?php + +/** + * Generate an OpenSearch description file + */ + +require_once( dirname(__FILE__) . '/includes/WebStart.php' ); +require_once( dirname(__FILE__) . '/languages/Names.php' ); +$fullName = "$wgSitename ({$wgLanguageNames[$wgLanguageCode]})"; +$shortName = htmlspecialchars( mb_substr( $fullName, 0, 24 ) ); +$siteName = htmlspecialchars( $fullName ); + +if ( !preg_match( '/^https?:/', $wgFavicon ) ) { + $favicon = htmlspecialchars( $wgServer . $wgFavicon ); +} else { + $favicon = htmlspecialchars( $wgFavicon ); +} + +$title = Title::makeTitle( NS_SPECIAL, 'Search' ); +$template = $title->escapeFullURL( 'search={searchTerms}' ); + +$response = $wgRequest->response(); +$response->header( 'Content-type: application/opensearchdescription+xml' ); + +# Set an Expires header so that squid can cache it for a short time +# Short enough so that the sysadmin barely notices when $wgSitename is changed +$expiryTime = 300; # 5 minutes +$response->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expiryTime ) . ' GMT' ); + +echo <<<EOT +<?xml version="1.0"?> +<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"> +<ShortName>$shortName</ShortName> +<Description>$siteName</Description> +<Image height="16" width="16" type="image/x-icon">$favicon</Image> +<Url type="text/html" method="get" template="$template"/> +</OpenSearchDescription> +EOT; + + +?> |