I doubt we'll get $this->hookError set to '0', but let's head that off at the pass.
[lhc/web/wiklou.git] / opensearch_desc.php
index 6aeacc4..b06b7fe 100644 (file)
@@ -5,11 +5,22 @@
  */
 
 require_once( dirname(__FILE__) . '/includes/WebStart.php' );
-$shortName = htmlspecialchars( mb_substr( $wgSitename, 0, 16 ) );
-$siteName = htmlspecialchars( $wgSitename );
-$favicon = htmlspecialchars( $wgFavicon );
-$title = Title::makeTitle( NS_SPECIAL, 'Search' );
-$template = $title->getFullURL( 'search={searchTerms}' );
+require_once( dirname(__FILE__) . '/languages/Names.php' );
+$fullName = "$wgSitename ({$wgLanguageNames[$wgLanguageCode]})";
+$shortName = htmlspecialchars( mb_substr( $fullName, 0, 24 ) );
+$siteName = htmlspecialchars( $fullName );
+
+if ( !preg_match( '/^https?:/', $wgFavicon ) ) {
+       $favicon = htmlspecialchars( $wgServer . $wgFavicon );
+} else {
+       $favicon = htmlspecialchars( $wgFavicon );
+}
+
+$title = SpecialPage::getTitleFor( 'Search' );
+$template = $title->escapeFullURL( 'search={searchTerms}' );
+
+$suggest = htmlspecialchars($wgServer . $wgScriptPath . '/api.php?action=opensearch&search={searchTerms}');
+
 
 $response = $wgRequest->response();
 $response->header( 'Content-type: application/opensearchdescription+xml' );
@@ -26,7 +37,9 @@ echo <<<EOT
 <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;
 
+
 ?>