http://www.mediawiki.org/wiki/Special:Code/MediaWiki/79649
Revision: 79649 Author: philip Date: 2011-01-05 16:21:01 +0000 (Wed, 05 Jan 2011) Log Message: ----------- Add fallback languages support for ApiOpenSearch. Modified Paths: -------------- trunk/phase3/includes/api/ApiOpenSearch.php Modified: trunk/phase3/includes/api/ApiOpenSearch.php =================================================================== --- trunk/phase3/includes/api/ApiOpenSearch.php 2011-01-05 16:13:29 UTC (rev 79648) +++ trunk/phase3/includes/api/ApiOpenSearch.php 2011-01-05 16:21:01 UTC (rev 79649) @@ -61,6 +61,21 @@ $srchres = PrefixSearch::titleSearch( $search, $limit, $namespaces ); + + // if the content language has variants, try to retrieve fallback results + if ( ( $fblimit = $limit - count( $srchres ) ) > 0 ) { + global $wgContLang; + $fbsearchs = $wgContLang->autoConvertToAllVariants( $search ); + $fbsearchs = array_diff( array_unique( $fbsearchs ), ( array ) $search ); + foreach ( $fbsearchs as $fbsearch ) { + $_srchres = PrefixSearch::titleSearch( $fbsearch, $fblimit, + $namespaces ); + $srchres = array_merge( $srchres, $_srchres ); + if ( ( $fblimit -= - count( $_srchres ) ) == 0 ) { + break; + } + } + } } // Set top level elements $result = $this->getResult(); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs