Index: trunk/phase3/includes/api/ApiOpenSearch.php |
— | — | @@ -61,6 +61,21 @@ |
62 | 62 | |
63 | 63 | $srchres = PrefixSearch::titleSearch( $search, $limit, |
64 | 64 | $namespaces ); |
| 65 | + |
| 66 | + // if the content language has variants, try to retrieve fallback results |
| 67 | + if ( ( $fblimit = $limit - count( $srchres ) ) > 0 ) { |
| 68 | + global $wgContLang; |
| 69 | + $fbsearchs = $wgContLang->autoConvertToAllVariants( $search ); |
| 70 | + $fbsearchs = array_diff( array_unique( $fbsearchs ), ( array ) $search ); |
| 71 | + foreach ( $fbsearchs as $fbsearch ) { |
| 72 | + $_srchres = PrefixSearch::titleSearch( $fbsearch, $fblimit, |
| 73 | + $namespaces ); |
| 74 | + $srchres = array_merge( $srchres, $_srchres ); |
| 75 | + if ( ( $fblimit -= - count( $_srchres ) ) == 0 ) { |
| 76 | + break; |
| 77 | + } |
| 78 | + } |
| 79 | + } |
65 | 80 | } |
66 | 81 | // Set top level elements |
67 | 82 | $result = $this->getResult(); |