From ab6222084d56671d1c69cf10c2c5177c6d286473 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Sun, 20 Aug 2006 03:45:47 +0000 Subject: [PATCH] Experimental OpenSearch description --- includes/Skin.php | 9 ++++++++- opensearch_desc.php | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 opensearch_desc.php diff --git a/includes/Skin.php b/includes/Skin.php index 45fca59842..69804dced0 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -157,7 +157,7 @@ class Skin extends Linker { } function initPage( &$out ) { - global $wgFavicon; + global $wgFavicon, $wgScriptPath; $fname = 'Skin::initPage'; wfProfileIn( $fname ); @@ -166,6 +166,13 @@ class Skin extends Linker { $out->addLink( array( 'rel' => 'shortcut icon', 'href' => $wgFavicon ) ); } + # OpenSearch description link + $out->addLink( array( + 'rel' => 'search', + 'type' => 'application/opensearchdescription+xml', + 'href' => "$wgScriptPath/opensearch_desc.php" + )); + $this->addMetadataLinks($out); $this->mRevisionId = $out->mRevisionId; diff --git a/opensearch_desc.php b/opensearch_desc.php new file mode 100644 index 0000000000..6aeacc4b40 --- /dev/null +++ b/opensearch_desc.php @@ -0,0 +1,32 @@ +getFullURL( '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 << + +$shortName +$siteName +$favicon + + +EOT; + +?> -- 2.20.1