please don't throw away the changelog, nick
[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 require_once( dirname(__FILE__) . '/languages/Names.php' );
9 $fullName = "$wgSitename ({$wgLanguageNames[$wgLanguageCode]})";
10 $shortName = htmlspecialchars( mb_substr( $fullName, 0, 24 ) );
11 $siteName = htmlspecialchars( $fullName );
12
13 if ( !preg_match( '/^https?:/', $wgFavicon ) ) {
14 $favicon = htmlspecialchars( $wgServer . $wgFavicon );
15 } else {
16 $favicon = htmlspecialchars( $wgFavicon );
17 }
18
19 $title = Title::makeTitle( NS_SPECIAL, 'Search' );
20 $template = $title->escapeFullURL( 'search={searchTerms}' );
21
22 $response = $wgRequest->response();
23 $response->header( 'Content-type: application/opensearchdescription+xml' );
24
25 # Set an Expires header so that squid can cache it for a short time
26 # Short enough so that the sysadmin barely notices when $wgSitename is changed
27 $expiryTime = 300; # 5 minutes
28 $response->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expiryTime ) . ' GMT' );
29
30 echo <<<EOT
31 <?xml version="1.0"?>
32 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
33 <ShortName>$shortName</ShortName>
34 <Description>$siteName</Description>
35 <Image height="16" width="16" type="image/x-icon">$favicon</Image>
36 <Url type="text/html" method="get" template="$template"/>
37 </OpenSearchDescription>
38 EOT;
39
40
41 ?>