00001 <?php
00002
00009 require_once( dirname(__FILE__) . '/includes/WebStart.php' );
00010
00011 if( $wgRequest->getVal( 'ctype' ) == 'application/xml' ) {
00012
00013 $ctype = 'application/xml';
00014 } else {
00015 $ctype = 'application/opensearchdescription+xml';
00016 }
00017
00018 $response = $wgRequest->response();
00019 $response->header( "Content-type: $ctype" );
00020
00021
00022
00023 $expiryTime = 600; # 10 minutes
00024 $response->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expiryTime ) . ' GMT' );
00025 $response->header( 'Cache-control: max-age=600' );
00026
00027 print '<?xml version="1.0"?>';
00028 print Xml::openElement( 'OpenSearchDescription',
00029 array(
00030 'xmlns' => 'http://a9.com/-/spec/opensearch/1.1/',
00031 'xmlns:moz' => 'http://www.mozilla.org/2006/browser/search/' ) );
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 $fullName = wfMsgForContent( 'opensearch-desc' );
00044 print Xml::element( 'ShortName', null, $fullName );
00045 print Xml::element( 'Description', null, $fullName );
00046
00047
00048
00049 print Xml::element( 'Image',
00050 array(
00051 'height' => 16,
00052 'width' => 16,
00053 'type' => 'image/x-icon' ),
00054 wfExpandUrl( $wgFavicon ) );
00055
00056 $urls = array();
00057
00058
00059
00060
00061 $searchPage = SpecialPage::getTitleFor( 'Search' );
00062 $urls[] = array(
00063 'type' => 'text/html',
00064 'method' => 'get',
00065 'template' => $searchPage->getFullURL( 'search={searchTerms}' ) );
00066
00067 if( $wgEnableAPI ) {
00068
00069
00070 $urls[] = array(
00071 'type' => 'application/x-suggestions+json',
00072 'method' => 'get',
00073 'template' => SearchEngine::getOpenSearchTemplate() );
00074 }
00075
00076
00077
00078 wfRunHooks( 'OpenSearchUrls', array( &$urls ) );
00079
00080 foreach( $urls as $attribs ) {
00081 print Xml::element( 'Url', $attribs );
00082 }
00083
00084
00085
00086
00087
00088 print Xml::element( 'moz:SearchForm', null,
00089 $searchPage->getFullUrl() );
00090
00091 print '</OpenSearchDescription>';