Use CSS columns instead of tables in Special:SpecialPages
[lhc/web/wiklou.git] / opensearch_desc.php
index 4e8a1a2..5e5e35d 100644 (file)
@@ -20,9 +20,9 @@
  * @file
  */
 
-require_once( __DIR__ . '/includes/WebStart.php' );
+require_once __DIR__ . '/includes/WebStart.php';
 
-if( $wgRequest->getVal( 'ctype' ) == 'application/xml' ) {
+if ( $wgRequest->getVal( 'ctype' ) == 'application/xml' ) {
        // Makes testing tweaks about a billion times easier
        $ctype = 'application/xml';
 } else {
@@ -78,20 +78,25 @@ $urls[] = array(
        'method' => 'get',
        'template' => $searchPage->getCanonicalURL( 'search={searchTerms}' ) );
 
-if( $wgEnableAPI ) {
-       // JSON interface for search suggestions.
-       // Supported in Firefox 2 and later.
-       $urls[] = array(
-               'type' => 'application/x-suggestions+json',
-               'method' => 'get',
-               'template' => SearchEngine::getOpenSearchTemplate() );
+foreach ( $wgOpenSearchTemplates as $type => $template ) {
+       if ( !$template && $wgEnableAPI ) {
+               $template = ApiOpenSearch::getOpenSearchTemplate( $type );
+       }
+
+       if ( $template ) {
+               $urls[] = array(
+                       'type' => $type,
+                       'method' => 'get',
+                       'template' => $template,
+               );
+       }
 }
 
 // Allow hooks to override the suggestion URL settings in a more
 // general way than overriding the whole search engine...
 wfRunHooks( 'OpenSearchUrls', array( &$urls ) );
 
-foreach( $urls as $attribs ) {
+foreach ( $urls as $attribs ) {
        print Xml::element( 'Url', $attribs );
 }