Merge "mw.language.convertPlural: Check if matching form exists"
[lhc/web/wiklou.git] / includes / api / ApiQuerySiteinfo.php
index a776706..1c188da 100644 (file)
@@ -106,7 +106,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                // Abuse siprop as a query-continue parameter
                                // and set it to all unprocessed props
                                $this->setContinueEnumParameter( 'prop', implode( '|',
-                                               array_diff( $params['prop'], $done ) ) );
+                                       array_diff( $params['prop'], $done ) ) );
                                break;
                        }
                        $done[] = $p;
@@ -114,9 +114,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
        }
 
        protected function appendGeneralInfo( $property ) {
-               global $wgContLang,
-                       $wgDisableLangConversion,
-                       $wgDisableTitleConversion;
+               global $wgContLang, $wgDisableLangConversion, $wgDisableTitleConversion;
 
                $data = array();
                $mainPage = Title::newMainPage();
@@ -153,8 +151,12 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                }
 
                if ( $wgContLang->linkPrefixExtension() ) {
-                       $data['linkprefix'] = wfMessage( 'linkprefix' )->inContentLanguage()->text();
+                       $linkPrefixCharset = $wgContLang->linkPrefixCharset();
+                       $data['linkprefixcharset'] = $linkPrefixCharset;
+                       // For backwards compatability
+                       $data['linkprefix'] = "/^((?>.*[^$linkPrefixCharset]|))(.+)$/sDu";
                } else {
+                       $data['linkprefixcharset'] = '';
                        $data['linkprefix'] = '';
                }
 
@@ -276,6 +278,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                }
 
                $this->getResult()->setIndexedTagName( $data, 'ns' );
+
                return $this->getResult()->addValue( 'query', $property, $data );
        }
 
@@ -299,6 +302,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                sort( $data );
 
                $this->getResult()->setIndexedTagName( $data, 'ns' );
+
                return $this->getResult()->addValue( 'query', $property, $data );
        }
 
@@ -314,6 +318,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        }
                }
                $this->getResult()->setIndexedTagName( $data, 'specialpage' );
+
                return $this->getResult()->addValue( 'query', $property, $data );
        }
 
@@ -330,6 +335,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        $data[] = $arr;
                }
                $this->getResult()->setIndexedTagName( $data, 'magicword' );
+
                return $this->getResult()->addValue( 'query', $property, $data );
        }
 
@@ -357,7 +363,9 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        if ( $row['iw_local'] == '1' ) {
                                $val['local'] = '';
                        }
-                       // $val['trans'] = intval( $row['iw_trans'] ); // should this be exposed?
+                       if ( $row['iw_trans'] == '1' ) {
+                               $val['trans'] = '';
+                       }
                        if ( isset( $langNames[$prefix] ) ) {
                                $val['language'] = $langNames[$prefix];
                        }
@@ -373,6 +381,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                }
 
                $this->getResult()->setIndexedTagName( $data, 'iw' );
+
                return $this->getResult()->addValue( 'query', $property, $data );
        }
 
@@ -382,7 +391,10 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                $lb = wfGetLB();
                if ( $includeAll ) {
                        if ( !$wgShowHostnames ) {
-                               $this->dieUsage( 'Cannot view all servers info unless $wgShowHostnames is true', 'includeAllDenied' );
+                               $this->dieUsage(
+                                       'Cannot view all servers info unless $wgShowHostnames is true',
+                                       'includeAllDenied'
+                               );
                        }
 
                        $lags = $lb->getLagTimes();
@@ -404,6 +416,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
 
                $result = $this->getResult();
                $result->setIndexedTagName( $data, 'db' );
+
                return $this->getResult()->addValue( 'query', $property, $data );
        }
 
@@ -444,7 +457,6 @@ class ApiQuerySiteinfo extends ApiQueryBase {
 
                                if ( $group == 'user' ) {
                                        $arr['number'] = SiteStats::users();
-
                                // '*' and autopromote groups have no size
                                } elseif ( $group !== '*' && !isset( $wgAutopromote[$group] ) ) {
                                        $arr['number'] = SiteStats::numberInGroup( $group );
@@ -470,6 +482,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                }
 
                $result->setIndexedTagName( $data, 'group' );
+
                return $result->addValue( 'query', $property, $data );
        }
 
@@ -481,6 +494,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        $data[] = array( 'ext' => $ext );
                }
                $this->getResult()->setIndexedTagName( $data, 'fe' );
+
                return $this->getResult()->addValue( 'query', $property, $data );
        }
 
@@ -515,18 +529,19 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                        $ret['url'] = $ext['url'];
                                }
                                if ( isset( $ext['version'] ) ) {
-                                               $ret['version'] = $ext['version'];
+                                       $ret['version'] = $ext['version'];
                                } elseif ( isset( $ext['svn-revision'] ) &&
                                        preg_match( '/\$(?:Rev|LastChangedRevision|Revision): *(\d+)/',
-                                               $ext['svn-revision'], $m ) )
-                               {
-                                               $ret['version'] = 'r' . $m[1];
+                                               $ext['svn-revision'], $m )
+                               {
+                                       $ret['version'] = 'r' . $m[1];
                                }
                                $data[] = $ret;
                        }
                }
 
                $this->getResult()->setIndexedTagName( $data, 'ext' );
+
                return $this->getResult()->addValue( 'query', $property, $data );
        }
 
@@ -560,6 +575,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        $data[] = $lang;
                }
                $this->getResult()->setIndexedTagName( $data, 'lang' );
+
                return $this->getResult()->addValue( 'query', $property, $data );
        }
 
@@ -579,6 +595,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        $data[] = $skin;
                }
                $this->getResult()->setIndexedTagName( $data, 'skin' );
+
                return $this->getResult()->addValue( 'query', $property, $data );
        }
 
@@ -587,6 +604,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                $wgParser->firstCallInit();
                $tags = array_map( array( $this, 'formatParserTags' ), $wgParser->getTags() );
                $this->getResult()->setIndexedTagName( $tags, 't' );
+
                return $this->getResult()->addValue( 'query', $property, $tags );
        }
 
@@ -595,12 +613,14 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                $wgParser->firstCallInit();
                $hooks = $wgParser->getFunctionHooks();
                $this->getResult()->setIndexedTagName( $hooks, 'h' );
+
                return $this->getResult()->addValue( 'query', $property, $hooks );
        }
 
        public function appendVariables( $property ) {
                $variables = MagicWord::getVariableIDs();
                $this->getResult()->setIndexedTagName( $variables, 'v' );
+
                return $this->getResult()->addValue( 'query', $property, $variables );
        }
 
@@ -609,6 +629,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                // Make a copy of the global so we don't try to set the _element key of it - bug 45130
                $protocols = array_values( $wgUrlProtocols );
                $this->getResult()->setIndexedTagName( $protocols, 'p' );
+
                return $this->getResult()->addValue( 'query', $property, $protocols );
        }
 
@@ -633,6 +654,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                }
 
                $this->getResult()->setIndexedTagName( $data, 'hook' );
+
                return $this->getResult()->addValue( 'query', $property, $data );
        }
 
@@ -681,6 +703,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
 
        public function getParamDescription() {
                $p = $this->getModulePrefix();
+
                return array(
                        'prop' => array(
                                'Which sysinfo properties to get:',
@@ -690,14 +713,14 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                ' specialpagealiases    - List of special page aliases',
                                ' magicwords            - List of magic words and their aliases',
                                ' statistics            - Returns site statistics',
-                               " interwikimap          - Returns interwiki map " .
+                               ' interwikimap          - Returns interwiki map ' .
                                        "(optionally filtered, (optionally localised by using {$p}inlanguagecode))",
                                ' dbrepllag             - Returns database server with the highest replication lag',
                                ' usergroups            - Returns user groups and the associated permissions',
                                ' extensions            - Returns extensions installed on the wiki',
                                ' fileextensions        - Returns list of file extensions allowed to be uploaded',
                                ' rightsinfo            - Returns wiki rights (license) information if available',
-                               " languages             - Returns a list of languages MediaWiki supports" .
+                               ' languages             - Returns a list of languages MediaWiki supports' .
                                        "(optionally localised by using {$p}inlanguagecode)",
                                ' skins                 - Returns a list of all enabled skins',
                                ' extensiontags         - Returns a list of parser extension tags',
@@ -709,7 +732,8 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                        'filteriw' => 'Return only local or only nonlocal entries of the interwiki map',
                        'showalldb' => 'List all database servers, not just the one lagging the most',
                        'numberingroup' => 'Lists the number of users in user groups',
-                       'inlanguagecode' => 'Language code for localised language names (best effort, use CLDR extension)',
+                       'inlanguagecode' => 'Language code for localised language names ' .
+                               '(best effort, use CLDR extension)',
                );
        }