6aeacc4b4010bdf21a8746f4e24e2d77942f8221
[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 $favicon = htmlspecialchars( $wgFavicon );
11 $title = Title::makeTitle( NS_SPECIAL, 'Search' );
12 $template = $title->getFullURL( 'search={searchTerms}' );
13
14 $response = $wgRequest->response();
15 $response->header( 'Content-type: application/opensearchdescription+xml' );
16
17 # Set an Expires header so that squid can cache it for a short time
18 # Short enough so that the sysadmin barely notices when $wgSitename is changed
19 $expiryTime = 300; # 5 minutes
20 $response->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expiryTime ) . ' GMT' );
21
22 echo <<<EOT
23 <?xml version="1.0"?>
24 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
25 <ShortName>$shortName</ShortName>
26 <Description>$siteName</Description>
27 <Image height="16" width="16" type="image/x-icon">$favicon</Image>
28 <Url type="text/html" method="get" template="$template"/>
29 </OpenSearchDescription>
30 EOT;
31
32 ?>