wiki.techinc.nl/opensearch_desc.php
Robert Stojnić d6fd8e7c13 Ajax suggestions:
* check in a new ajax suggestion engine (mwsuggest.js) which uses 
  OpenSearch to fetch results (by default via API), this should
  deprecated the old ajaxsearch thingy
* extend PrefixSearchBackend hook to accept multiple namespaces for
  future lucene use (default implementation however can still 
  process only one)
* Added to preferences, also a feature to turn it on/off for every 
  input (disabled atm until I work out browser issues completely)
* WMF wikis probably won't be using API to fetch results, but a 
  custom php wrapper that just forwards the request to appropriate
  lucene daemon, added support for that

SpecialSearch:
* moved stuff out of SpecialSearch to SearchEngine, like snippet
  highlighting and such
* support for additional interwiki results, e.g. title matches
  from other projects shown in a separate box on the right
* todo: interwiki box doesn't have standard prev/next links to 
  avoid clutter and unintuitive interface
* support for related articles
2008-04-15 23:06:28 +00:00

49 lines
1.6 KiB
PHP

<?php
/**
* Generate an OpenSearch description file
*/
require_once( dirname(__FILE__) . '/includes/WebStart.php' );
require_once( dirname(__FILE__) . '/languages/Names.php' );
$fullName = wfMsgForContent( 'opensearch-desc' );
$shortName = htmlspecialchars( mb_substr( $fullName, 0, 24 ) );
$siteName = htmlspecialchars( $fullName );
$favicon = htmlspecialchars( wfExpandUrl( $wgFavicon ) );
$title = SpecialPage::getTitleFor( 'Search' );
$template = $title->escapeFullURL( 'search={searchTerms}' );
$suggest = htmlspecialchars(SearchEngine::getOpenSearchTemplate() );
$response = $wgRequest->response();
if( $wgRequest->getVal( 'ctype' ) == 'application/xml' ) {
// Makes testing tweaks about a billion times easier
$ctype = 'application/xml';
} else {
$ctype = 'application/opensearchdescription+xml';
}
$response->header( "Content-type: $ctype" );
# 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 = 600; # 10 minutes
$response->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expiryTime ) . ' GMT' );
$response->header( 'Cache-control: max-age=600' );
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"/>
<Url type="application/x-suggestions+json" method="GET" template="$suggest"/>
</OpenSearchDescription>
EOT;
?>