X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=opensearch_desc.php;h=0b5697270a7a2be9546b011b0d5922cb44ae95c8;hb=b51076a84446d157bed511246450e70d26e0f945;hp=630b05c16a4aa7763d0dc26beac8c751a5aaf11b;hpb=29719f846b8887e1190ddf85125387c079f9539b;p=lhc%2Fweb%2Fwiklou.git diff --git a/opensearch_desc.php b/opensearch_desc.php index 630b05c16a..0b5697270a 100644 --- a/opensearch_desc.php +++ b/opensearch_desc.php @@ -20,9 +20,9 @@ * @file */ -require_once( dirname(__FILE__) . '/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 { @@ -65,7 +65,7 @@ print Xml::element( 'Image', 'height' => 16, 'width' => 16, 'type' => 'image/x-icon' ), - wfExpandUrl( $wgFavicon , PROTO_CURRENT ) ); + wfExpandUrl( $wgFavicon, PROTO_CURRENT ) ); $urls = array(); @@ -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 ) ); +Hooks::run( 'OpenSearchUrls', array( &$urls ) ); -foreach( $urls as $attribs ) { +foreach ( $urls as $attribs ) { print Xml::element( 'Url', $attribs ); }