another minor fix
[lhc/web/wiklou.git] / opensearch_desc.php
1 <?php
2
3 /**
4 * Generate an OpenSearch description file
5 */
6
7 require_once( dirname(__FILE__) . '/includes/WebStart.php' );
8 $shortName = htmlspecialchars( mb_substr( $wgSitename, 0, 16 ) );
9 $siteName = htmlspecialchars( $wgSitename );
10
11 if ( !preg_match( '/^https?:/', $wgFavicon ) ) {
12 $favicon = htmlspecialchars( $wgServer . $wgFavicon );
13 } else {
14 $favicon = htmlspecialchars( $wgFavicon );
15 }
16
17 $title = Title::makeTitle( NS_SPECIAL, 'Search' );
18 $template = $title->escapeFullURL( 'search={searchTerms}' );
19
20 $response = $wgRequest->response();
21 $response->header( 'Content-type: application/opensearchdescription+xml' );
22
23 # Set an Expires header so that squid can cache it for a short time
24 # Short enough so that the sysadmin barely notices when $wgSitename is changed
25 $expiryTime = 300; # 5 minutes
26 $response->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expiryTime ) . ' GMT' );
27
28 echo <<<EOT
29 <?xml version="1.0"?>
30 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
31 <ShortName>$shortName</ShortName>
32 <Description>$siteName</Description>
33 <Image height="16" width="16" type="image/x-icon">$favicon</Image>
34 <Url type="text/html" method="get" template="$template"/>
35 </OpenSearchDescription>
36 EOT;
37
38 ?>