From ca32f08966f1b51fcb19460f0996bb0c4048e6fe Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sat, 3 Dec 2011 13:29:22 +0100 Subject: Update to MediaWiki 1.18.0 * also update ArchLinux skin to chagnes in MonoBook * Use only css to hide our menu bar when printing --- includes/PrefixSearch.php | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'includes/PrefixSearch.php') diff --git a/includes/PrefixSearch.php b/includes/PrefixSearch.php index 236e4370..0efe1bdd 100644 --- a/includes/PrefixSearch.php +++ b/includes/PrefixSearch.php @@ -15,7 +15,7 @@ class PrefixSearch { * @param $namespaces Array: used if query is not explicitely prefixed * @return Array of strings */ - public static function titleSearch( $search, $limit, $namespaces=array() ) { + public static function titleSearch( $search, $limit, $namespaces = array() ) { $search = trim( $search ); if( $search == '' ) { return array(); // Return empty result @@ -26,8 +26,9 @@ class PrefixSearch { $title = Title::newFromText( $search ); if( $title && $title->getInterwiki() == '' ) { $ns = array($title->getNamespace()); - if($ns[0] == NS_MAIN) + if( $ns[0] == NS_MAIN ) { $ns = $namespaces; // no explicit prefix, use default namespaces + } return self::searchBackend( $ns, $title->getText(), $limit ); } @@ -38,13 +39,12 @@ class PrefixSearch { && $title->getNamespace() != NS_MAIN && $title->getInterwiki() == '' ) { return self::searchBackend( - array($title->getNamespace()), '', $limit ); + array( $title->getNamespace() ), '', $limit ); } return self::searchBackend( $namespaces, $search, $limit ); } - /** * Do a prefix search of titles and return a list of matching page names. * @param $namespaces Array @@ -53,10 +53,10 @@ class PrefixSearch { * @return Array of strings */ protected static function searchBackend( $namespaces, $search, $limit ) { - if( count($namespaces) == 1 ){ + if( count( $namespaces ) == 1 ) { $ns = $namespaces[0]; if( $ns == NS_MEDIA ) { - $namespaces = array(NS_FILE); + $namespaces = array( NS_FILE ); } elseif( $ns == NS_SPECIAL ) { return self::specialSearch( $search, $limit ); } @@ -85,15 +85,13 @@ class PrefixSearch { // Unlike SpecialPage itself, we want the canonical forms of both // canonical and alias title forms... - SpecialPage::initList(); - SpecialPage::initAliasList(); $keys = array(); - foreach( array_keys( SpecialPage::$mList ) as $page ) { + foreach( SpecialPageFactory::getList() as $page => $class ) { $keys[$wgContLang->caseFold( $page )] = $page; } foreach( $wgContLang->getSpecialPageAliases() as $page => $aliases ) { - if( !array_key_exists( $page, SpecialPage::$mList ) ) {# bug 20885 + if( !array_key_exists( $page, SpecialPageFactory::getList() ) ) {# bug 20885 continue; } @@ -135,12 +133,13 @@ class PrefixSearch { * @return Array of title strings */ protected static function defaultSearchBackend( $namespaces, $search, $limit ) { - $ns = array_shift($namespaces); // support only one namespace - if( in_array(NS_MAIN,$namespaces)) + $ns = array_shift( $namespaces ); // support only one namespace + if( in_array( NS_MAIN, $namespaces ) ) { $ns = NS_MAIN; // if searching on many always default to main + } // Prepare nested request - $req = new FauxRequest(array ( + $req = new FauxRequest( array( 'action' => 'query', 'list' => 'allpages', 'apnamespace' => $ns, @@ -149,7 +148,7 @@ class PrefixSearch { )); // Execute - $module = new ApiMain($req); + $module = new ApiMain( $req ); $module->execute(); // Get resulting data @@ -157,7 +156,7 @@ class PrefixSearch { // Reformat useful data for future printing by JSON engine $srchres = array (); - foreach ((array)$data['query']['allpages'] as $pageinfo) { + foreach ( (array)$data['query']['allpages'] as $pageinfo ) { // Note: this data will no be printable by the xml engine // because it does not support lists of unnamed items $srchres[] = $pageinfo['title']; @@ -172,18 +171,19 @@ class PrefixSearch { * @param $namespaces Array * @return Array (default: contains only NS_MAIN) */ - protected static function validateNamespaces($namespaces){ + protected static function validateNamespaces( $namespaces ) { global $wgContLang; // We will look at each given namespace against wgContLang namespaces $validNamespaces = $wgContLang->getNamespaces(); - if( is_array($namespaces) && count($namespaces)>0 ){ + if( is_array( $namespaces ) && count( $namespaces ) > 0 ) { $valid = array(); - foreach ($namespaces as $ns){ - if( is_numeric($ns) && array_key_exists($ns, $validNamespaces) ) + foreach ( $namespaces as $ns ) { + if( is_numeric( $ns ) && array_key_exists( $ns, $validNamespaces ) ) { $valid[] = $ns; + } } - if( count($valid) > 0 ) { + if( count( $valid ) > 0 ) { return $valid; } } -- cgit v1.2.2