Fixed api=compare example to use existing parameters
[lhc/web/wiklou.git] / includes / api / ApiOpenSearch.php
index 8b382a4..bdab14f 100644 (file)
@@ -52,26 +52,30 @@ class ApiOpenSearch extends ApiBase {
 
                // MWSuggest or similar hit
                if ( $suggest && !$wgEnableOpenSearchSuggest ) {
-                       $srchres = array();
+                       $searches = array();
                } else {
-                       // Open search results may be stored for a very long
-                       // time
+                       // Open search results may be stored for a very long time
                        $this->getMain()->setCacheMaxAge( $wgSearchSuggestCacheExpiry );
                        $this->getMain()->setCacheMode( 'public' );
 
-                       $srchres = PrefixSearch::titleSearch( $search, $limit,
+                       $searches = PrefixSearch::titleSearch( $search, $limit,
                                $namespaces );
                        
                        // if the content language has variants, try to retrieve fallback results
-                       if ( ( $fblimit = $limit - count( $srchres ) ) > 0 ) {
+                       $fallbackLimit = $limit - count( $searches );
+                       if ( $fallbackLimit > 0 ) {
                                global $wgContLang;
-                               $fbsearchs = $wgContLang->autoConvertToAllVariants( $search );
-                               $fbsearchs = array_diff( array_unique( $fbsearchs ), ( array ) $search );
-                               foreach ( $fbsearchs as $fbsearch ) {
-                                       $_srchres = PrefixSearch::titleSearch( $fbsearch, $fblimit,
+
+                               $fallbackSearches = $wgContLang->autoConvertToAllVariants( $search );
+                               $fallbackSearches = array_diff( array_unique( $fallbackSearches ), array( $search ) );
+
+                               foreach ( $fallbackSearches as $fbs ) {
+                                       $fallbackSearchResult = PrefixSearch::titleSearch( $fbs, $fallbackLimit,
                                                $namespaces );
-                                       $srchres = array_merge( $srchres, $_srchres );
-                                       if ( ( $fblimit -= - count( $_srchres ) ) == 0 ) {
+                                       $searches = array_merge( $searches, $fallbackSearchResult );
+                                       $fallbackLimit -= count( $fallbackSearchResult );
+
+                                       if ( $fallbackLimit == 0 ) {
                                                break;
                                        }
                                }
@@ -80,7 +84,7 @@ class ApiOpenSearch extends ApiBase {
                // Set top level elements
                $result = $this->getResult();
                $result->addValue( null, 0, $search );
-               $result->addValue( null, 1, $srchres );
+               $result->addValue( null, 1, $searches );
        }
 
        public function getAllowedParams() {
@@ -112,7 +116,7 @@ class ApiOpenSearch extends ApiBase {
        }
 
        public function getDescription() {
-               return 'This module implements OpenSearch protocol';
+               return 'Searches the wiki using the OpenSearch protocol';
        }
 
        protected function getExamples() {