2006-08-20 03:45:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generate an OpenSearch description file
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
require_once( dirname(__FILE__) . '/includes/WebStart.php' );
|
2006-10-09 19:43:20 +00:00
|
|
|
require_once( dirname(__FILE__) . '/languages/Names.php' );
|
|
|
|
|
$fullName = "$wgSitename ({$wgLanguageNames[$wgLanguageCode]})";
|
|
|
|
|
$shortName = htmlspecialchars( mb_substr( $fullName, 0, 24 ) );
|
|
|
|
|
$siteName = htmlspecialchars( $fullName );
|
2006-08-20 04:14:56 +00:00
|
|
|
|
|
|
|
|
if ( !preg_match( '/^https?:/', $wgFavicon ) ) {
|
|
|
|
|
$favicon = htmlspecialchars( $wgServer . $wgFavicon );
|
|
|
|
|
} else {
|
|
|
|
|
$favicon = htmlspecialchars( $wgFavicon );
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-30 06:25:31 +00:00
|
|
|
$title = SpecialPage::getTitleFor( 'Search' );
|
2006-08-20 05:18:57 +00:00
|
|
|
$template = $title->escapeFullURL( 'search={searchTerms}' );
|
2006-08-20 03:45:47 +00:00
|
|
|
|
2006-10-16 02:41:41 +00:00
|
|
|
$suggest = htmlspecialchars($wgServer . $wgScriptPath . '/api.php?action=opensearch&search={searchTerms}');
|
2006-10-16 02:31:28 +00:00
|
|
|
|
|
|
|
|
|
2006-08-20 03:45:47 +00:00
|
|
|
$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"/>
|
2006-10-16 02:31:28 +00:00
|
|
|
<Url type="application/x-suggestions+json" method="GET" template="$suggest"/>
|
2006-08-20 03:45:47 +00:00
|
|
|
</OpenSearchDescription>
|
|
|
|
|
EOT;
|
|
|
|
|
|
2006-10-09 19:43:20 +00:00
|
|
|
|
2006-08-20 03:45:47 +00:00
|
|
|
?>
|