MediaWiki  REL1_20
ApiQuerySiteinfo.php
Go to the documentation of this file.
00001 <?php
00032 class ApiQuerySiteinfo extends ApiQueryBase {
00033 
00034         public function __construct( $query, $moduleName ) {
00035                 parent::__construct( $query, $moduleName, 'si' );
00036         }
00037 
00038         public function execute() {
00039                 $params = $this->extractRequestParams();
00040                 $done = array();
00041                 $fit = false;
00042                 foreach ( $params['prop'] as $p ) {
00043                         switch ( $p ) {
00044                                 case 'general':
00045                                         $fit = $this->appendGeneralInfo( $p );
00046                                         break;
00047                                 case 'namespaces':
00048                                         $fit = $this->appendNamespaces( $p );
00049                                         break;
00050                                 case 'namespacealiases':
00051                                         $fit = $this->appendNamespaceAliases( $p );
00052                                         break;
00053                                 case 'specialpagealiases':
00054                                         $fit = $this->appendSpecialPageAliases( $p );
00055                                         break;
00056                                 case 'magicwords':
00057                                         $fit = $this->appendMagicWords( $p );
00058                                         break;
00059                                 case 'interwikimap':
00060                                         $filteriw = isset( $params['filteriw'] ) ? $params['filteriw'] : false;
00061                                         $fit = $this->appendInterwikiMap( $p, $filteriw );
00062                                         break;
00063                                 case 'dbrepllag':
00064                                         $fit = $this->appendDbReplLagInfo( $p, $params['showalldb'] );
00065                                         break;
00066                                 case 'statistics':
00067                                         $fit = $this->appendStatistics( $p );
00068                                         break;
00069                                 case 'usergroups':
00070                                         $fit = $this->appendUserGroups( $p, $params['numberingroup'] );
00071                                         break;
00072                                 case 'extensions':
00073                                         $fit = $this->appendExtensions( $p );
00074                                         break;
00075                                 case 'fileextensions':
00076                                         $fit = $this->appendFileExtensions( $p );
00077                                         break;
00078                                 case 'rightsinfo':
00079                                         $fit = $this->appendRightsInfo( $p );
00080                                         break;
00081                                 case 'languages':
00082                                         $fit = $this->appendLanguages( $p );
00083                                         break;
00084                                 case 'skins':
00085                                         $fit = $this->appendSkins( $p );
00086                                         break;
00087                                 case 'extensiontags':
00088                                         $fit = $this->appendExtensionTags( $p );
00089                                         break;
00090                                 case 'functionhooks':
00091                                         $fit = $this->appendFunctionHooks( $p );
00092                                         break;
00093                                 case 'showhooks':
00094                                         $fit = $this->appendSubscribedHooks( $p );
00095                                         break;
00096                                 case 'variables':
00097                                         $fit = $this->appendVariables( $p );
00098                                         break;
00099                                 default:
00100                                         ApiBase::dieDebug( __METHOD__, "Unknown prop=$p" );
00101                         }
00102                         if ( !$fit ) {
00103                                 // Abuse siprop as a query-continue parameter
00104                                 // and set it to all unprocessed props
00105                                 $this->setContinueEnumParameter( 'prop', implode( '|',
00106                                                 array_diff( $params['prop'], $done ) ) );
00107                                 break;
00108                         }
00109                         $done[] = $p;
00110                 }
00111         }
00112 
00113         protected function appendGeneralInfo( $property ) {
00114                 global $wgContLang;
00115 
00116                 $data = array();
00117                 $mainPage = Title::newMainPage();
00118                 $data['mainpage'] = $mainPage->getPrefixedText();
00119                 $data['base'] = wfExpandUrl( $mainPage->getFullUrl(), PROTO_CURRENT );
00120                 $data['sitename'] = $GLOBALS['wgSitename'];
00121                 $data['generator'] = "MediaWiki {$GLOBALS['wgVersion']}";
00122                 $data['phpversion'] = phpversion();
00123                 $data['phpsapi'] = php_sapi_name();
00124                 $data['dbtype'] = $GLOBALS['wgDBtype'];
00125                 $data['dbversion'] = $this->getDB()->getServerVersion();
00126 
00127                 $git = SpecialVersion::getGitHeadSha1( $GLOBALS['IP'] );
00128                 if ( $git ) {
00129                         $data['git-hash'] = $git;
00130                 } else {
00131                         $svn = SpecialVersion::getSvnRevision( $GLOBALS['IP'] );
00132                         if ( $svn ) {
00133                                 $data['rev'] = $svn;
00134                         }
00135                 }
00136 
00137                 // 'case-insensitive' option is reserved for future
00138                 $data['case'] = $GLOBALS['wgCapitalLinks'] ? 'first-letter' : 'case-sensitive';
00139 
00140                 if ( isset( $GLOBALS['wgRightsCode'] ) ) {
00141                         $data['rightscode'] = $GLOBALS['wgRightsCode'];
00142                 }
00143                 $data['rights'] = $GLOBALS['wgRightsText'];
00144                 $data['lang'] = $GLOBALS['wgLanguageCode'];
00145 
00146                 $fallbacks = array();
00147                 foreach( $wgContLang->getFallbackLanguages() as $code ) {
00148                         $fallbacks[] = array( 'code' => $code );
00149                 }
00150                 $data['fallback'] = $fallbacks;
00151                 $this->getResult()->setIndexedTagName( $data['fallback'], 'lang' );
00152 
00153                 if( $wgContLang->hasVariants() ) {
00154                         $variants = array();
00155                         foreach( $wgContLang->getVariants() as $code ) {
00156                                 $variants[] = array( 'code' => $code );
00157                         }
00158                         $data['variants'] = $variants;
00159                         $this->getResult()->setIndexedTagName( $data['variants'], 'lang' );
00160                 }
00161 
00162                 if ( $wgContLang->isRTL() ) {
00163                         $data['rtl'] = '';
00164                 }
00165                 $data['fallback8bitEncoding'] = $wgContLang->fallback8bitEncoding();
00166 
00167                 if ( wfReadOnly() ) {
00168                         $data['readonly'] = '';
00169                         $data['readonlyreason'] = wfReadOnlyReason();
00170                 }
00171                 if ( $GLOBALS['wgEnableWriteAPI'] ) {
00172                         $data['writeapi'] = '';
00173                 }
00174 
00175                 $tz = $GLOBALS['wgLocaltimezone'];
00176                 $offset = $GLOBALS['wgLocalTZoffset'];
00177                 if ( is_null( $tz ) ) {
00178                         $tz = 'UTC';
00179                         $offset = 0;
00180                 } elseif ( is_null( $offset ) ) {
00181                         $offset = 0;
00182                 }
00183                 $data['timezone'] = $tz;
00184                 $data['timeoffset'] = intval( $offset );
00185                 $data['articlepath'] = $GLOBALS['wgArticlePath'];
00186                 $data['scriptpath'] = $GLOBALS['wgScriptPath'];
00187                 $data['script'] = $GLOBALS['wgScript'];
00188                 $data['variantarticlepath'] = $GLOBALS['wgVariantArticlePath'];
00189                 $data['server'] = $GLOBALS['wgServer'];
00190                 $data['wikiid'] = wfWikiID();
00191                 $data['time'] = wfTimestamp( TS_ISO_8601, time() );
00192 
00193                 if ( $GLOBALS['wgMiserMode'] ) {
00194                         $data['misermode'] = '';
00195                 }
00196 
00197                 $data['maxuploadsize'] = UploadBase::getMaxUploadSize();
00198 
00199                 wfRunHooks( 'APIQuerySiteInfoGeneralInfo', array( $this, &$data ) );
00200 
00201                 return $this->getResult()->addValue( 'query', $property, $data );
00202         }
00203 
00204         protected function appendNamespaces( $property ) {
00205                 global $wgContLang;
00206                 $data = array();
00207                 foreach ( $wgContLang->getFormattedNamespaces() as $ns => $title ) {
00208                         $data[$ns] = array(
00209                                 'id' => intval( $ns ),
00210                                 'case' => MWNamespace::isCapitalized( $ns ) ? 'first-letter' : 'case-sensitive',
00211                         );
00212                         ApiResult::setContent( $data[$ns], $title );
00213                         $canonical = MWNamespace::getCanonicalName( $ns );
00214 
00215                         if ( MWNamespace::hasSubpages( $ns ) ) {
00216                                 $data[$ns]['subpages'] = '';
00217                         }
00218 
00219                         if ( $canonical ) {
00220                                 $data[$ns]['canonical'] = strtr( $canonical, '_', ' ' );
00221                         }
00222 
00223                         if ( MWNamespace::isContent( $ns ) ) {
00224                                 $data[$ns]['content'] = '';
00225                         }
00226 
00227                         if ( MWNamespace::isNonincludable( $ns ) ) {
00228                                 $data[$ns]['nonincludable'] = '';
00229                         }
00230                 }
00231 
00232                 $this->getResult()->setIndexedTagName( $data, 'ns' );
00233                 return $this->getResult()->addValue( 'query', $property, $data );
00234         }
00235 
00236         protected function appendNamespaceAliases( $property ) {
00237                 global $wgNamespaceAliases, $wgContLang;
00238                 $aliases = array_merge( $wgNamespaceAliases, $wgContLang->getNamespaceAliases() );
00239                 $namespaces = $wgContLang->getNamespaces();
00240                 $data = array();
00241                 foreach ( $aliases as $title => $ns ) {
00242                         if ( $namespaces[$ns] == $title ) {
00243                                 // Don't list duplicates
00244                                 continue;
00245                         }
00246                         $item = array(
00247                                 'id' => intval( $ns )
00248                         );
00249                         ApiResult::setContent( $item, strtr( $title, '_', ' ' ) );
00250                         $data[] = $item;
00251                 }
00252 
00253                 $this->getResult()->setIndexedTagName( $data, 'ns' );
00254                 return $this->getResult()->addValue( 'query', $property, $data );
00255         }
00256 
00257         protected function appendSpecialPageAliases( $property ) {
00258                 global $wgContLang;
00259                 $data = array();
00260                 $aliases = $wgContLang->getSpecialPageAliases();
00261                 foreach ( SpecialPageFactory::getList() as $specialpage => $stuff ) {
00262                         if ( isset( $aliases[$specialpage] ) ) {
00263                                 $arr = array( 'realname' => $specialpage, 'aliases' => $aliases[$specialpage] );
00264                                 $this->getResult()->setIndexedTagName( $arr['aliases'], 'alias' );
00265                                 $data[] = $arr;
00266                         }
00267                 }
00268                 $this->getResult()->setIndexedTagName( $data, 'specialpage' );
00269                 return $this->getResult()->addValue( 'query', $property, $data );
00270         }
00271 
00272         protected function appendMagicWords( $property ) {
00273                 global $wgContLang;
00274                 $data = array();
00275                 foreach ( $wgContLang->getMagicWords() as $magicword => $aliases ) {
00276                         $caseSensitive = array_shift( $aliases );
00277                         $arr = array( 'name' => $magicword, 'aliases' => $aliases );
00278                         if ( $caseSensitive ) {
00279                                 $arr['case-sensitive'] = '';
00280                         }
00281                         $this->getResult()->setIndexedTagName( $arr['aliases'], 'alias' );
00282                         $data[] = $arr;
00283                 }
00284                 $this->getResult()->setIndexedTagName( $data, 'magicword' );
00285                 return $this->getResult()->addValue( 'query', $property, $data );
00286         }
00287 
00288         protected function appendInterwikiMap( $property, $filter ) {
00289                 $local = null;
00290                 if ( $filter === 'local' ) {
00291                         $local = 1;
00292                 } elseif ( $filter === '!local' ) {
00293                         $local = 0;
00294                 } elseif ( $filter ) {
00295                         ApiBase::dieDebug( __METHOD__, "Unknown filter=$filter" );
00296                 }
00297 
00298                 $params = $this->extractRequestParams();
00299                 $langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : '';
00300                 $langNames = Language::fetchLanguageNames( $langCode );
00301 
00302                 $getPrefixes = Interwiki::getAllPrefixes( $local );
00303                 $data = array();
00304 
00305                 foreach ( $getPrefixes as $row ) {
00306                         $prefix = $row['iw_prefix'];
00307                         $val = array();
00308                         $val['prefix'] = $prefix;
00309                         if ( $row['iw_local'] == '1' ) {
00310                                 $val['local'] = '';
00311                         }
00312                         // $val['trans'] = intval( $row['iw_trans'] ); // should this be exposed?
00313                         if ( isset( $langNames[$prefix] ) ) {
00314                                 $val['language'] = $langNames[$prefix];
00315                         }
00316                         $val['url'] = wfExpandUrl( $row['iw_url'], PROTO_CURRENT );
00317                         if( isset( $row['iw_wikiid'] ) ) {
00318                                 $val['wikiid'] = $row['iw_wikiid'];
00319                         }
00320                         if( isset( $row['iw_api'] ) ) {
00321                                 $val['api'] = $row['iw_api'];
00322                         }
00323 
00324                         $data[] = $val;
00325                 }
00326 
00327                 $this->getResult()->setIndexedTagName( $data, 'iw' );
00328                 return $this->getResult()->addValue( 'query', $property, $data );
00329         }
00330 
00331         protected function appendDbReplLagInfo( $property, $includeAll ) {
00332                 global $wgShowHostnames;
00333                 $data = array();
00334                 $lb = wfGetLB();
00335                 if ( $includeAll ) {
00336                         if ( !$wgShowHostnames ) {
00337                                 $this->dieUsage( 'Cannot view all servers info unless $wgShowHostnames is true', 'includeAllDenied' );
00338                         }
00339 
00340                         $lags = $lb->getLagTimes();
00341                         foreach ( $lags as $i => $lag ) {
00342                                 $data[] = array(
00343                                         'host' => $lb->getServerName( $i ),
00344                                         'lag' => $lag
00345                                 );
00346                         }
00347                 } else {
00348                         list( $host, $lag, $index ) = $lb->getMaxLag();
00349                         $data[] = array(
00350                                 'host' => $wgShowHostnames
00351                                                 ? $lb->getServerName( $index )
00352                                                 : '',
00353                                 'lag' => intval( $lag )
00354                         );
00355                 }
00356 
00357                 $result = $this->getResult();
00358                 $result->setIndexedTagName( $data, 'db' );
00359                 return $this->getResult()->addValue( 'query', $property, $data );
00360         }
00361 
00362         protected function appendStatistics( $property ) {
00363                 global $wgDisableCounters;
00364                 $data = array();
00365                 $data['pages'] = intval( SiteStats::pages() );
00366                 $data['articles'] = intval( SiteStats::articles() );
00367                 if ( !$wgDisableCounters ) {
00368                         $data['views'] = intval( SiteStats::views() );
00369                 }
00370                 $data['edits'] = intval( SiteStats::edits() );
00371                 $data['images'] = intval( SiteStats::images() );
00372                 $data['users'] = intval( SiteStats::users() );
00373                 $data['activeusers'] = intval( SiteStats::activeUsers() );
00374                 $data['admins'] = intval( SiteStats::numberingroup( 'sysop' ) );
00375                 $data['jobs'] = intval( SiteStats::jobs() );
00376                 return $this->getResult()->addValue( 'query', $property, $data );
00377         }
00378 
00379         protected function appendUserGroups( $property, $numberInGroup ) {
00380                 global $wgGroupPermissions, $wgAddGroups, $wgRemoveGroups, $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
00381 
00382                 $data = array();
00383                 $result = $this->getResult();
00384                 foreach ( $wgGroupPermissions as $group => $permissions ) {
00385                         $arr = array(
00386                                 'name' => $group,
00387                                 'rights' => array_keys( $permissions, true ),
00388                         );
00389 
00390                         if ( $numberInGroup ) {
00391                                 global $wgAutopromote;
00392 
00393                                 if ( $group == 'user' ) {
00394                                         $arr['number'] = SiteStats::users();
00395 
00396                                 // '*' and autopromote groups have no size
00397                                 } elseif ( $group !== '*' && !isset( $wgAutopromote[$group] ) ) {
00398                                         $arr['number'] = SiteStats::numberInGroup( $group );
00399                                 }
00400                         }
00401 
00402                         $groupArr = array(
00403                                 'add' => $wgAddGroups,
00404                                 'remove' => $wgRemoveGroups,
00405                                 'add-self' => $wgGroupsAddToSelf,
00406                                 'remove-self' => $wgGroupsRemoveFromSelf
00407                         );
00408 
00409                         foreach ( $groupArr as $type => $rights ) {
00410                                 if ( isset( $rights[$group] ) ) {
00411                                         $arr[$type] = $rights[$group];
00412                                         $result->setIndexedTagName( $arr[$type], 'group' );
00413                                 }
00414                         }
00415 
00416                         $result->setIndexedTagName( $arr['rights'], 'permission' );
00417                         $data[] = $arr;
00418                 }
00419 
00420                 $result->setIndexedTagName( $data, 'group' );
00421                 return $result->addValue( 'query', $property, $data );
00422         }
00423 
00424         protected function appendFileExtensions( $property ) {
00425                 global $wgFileExtensions;
00426 
00427                 $data = array();
00428                 foreach ( $wgFileExtensions as $ext ) {
00429                         $data[] = array( 'ext' => $ext );
00430                 }
00431                 $this->getResult()->setIndexedTagName( $data, 'fe' );
00432                 return $this->getResult()->addValue( 'query', $property, $data );
00433         }
00434 
00435         protected function appendExtensions( $property ) {
00436                 global $wgExtensionCredits;
00437                 $data = array();
00438                 foreach ( $wgExtensionCredits as $type => $extensions ) {
00439                         foreach ( $extensions as $ext ) {
00440                                 $ret = array();
00441                                 $ret['type'] = $type;
00442                                 if ( isset( $ext['name'] ) ) {
00443                                         $ret['name'] = $ext['name'];
00444                                 }
00445                                 if ( isset( $ext['description'] ) ) {
00446                                         $ret['description'] = $ext['description'];
00447                                 }
00448                                 if ( isset( $ext['descriptionmsg'] ) ) {
00449                                         // Can be a string or array( key, param1, param2, ... )
00450                                         if ( is_array( $ext['descriptionmsg'] ) ) {
00451                                                 $ret['descriptionmsg'] = $ext['descriptionmsg'][0];
00452                                                 $ret['descriptionmsgparams'] = array_slice( $ext['descriptionmsg'], 1 );
00453                                                 $this->getResult()->setIndexedTagName( $ret['descriptionmsgparams'], 'param' );
00454                                         } else {
00455                                                 $ret['descriptionmsg'] = $ext['descriptionmsg'];
00456                                         }
00457                                 }
00458                                 if ( isset( $ext['author'] ) ) {
00459                                         $ret['author'] = is_array( $ext['author'] ) ?
00460                                                 implode( ', ', $ext['author' ] ) : $ext['author'];
00461                                 }
00462                                 if ( isset( $ext['url'] ) ) {
00463                                         $ret['url'] = $ext['url'];
00464                                 }
00465                                 if ( isset( $ext['version'] ) ) {
00466                                                 $ret['version'] = $ext['version'];
00467                                 } elseif ( isset( $ext['svn-revision'] ) &&
00468                                         preg_match( '/\$(?:Rev|LastChangedRevision|Revision): *(\d+)/',
00469                                                 $ext['svn-revision'], $m ) )
00470                                 {
00471                                                 $ret['version'] = 'r' . $m[1];
00472                                 }
00473                                 $data[] = $ret;
00474                         }
00475                 }
00476 
00477                 $this->getResult()->setIndexedTagName( $data, 'ext' );
00478                 return $this->getResult()->addValue( 'query', $property, $data );
00479         }
00480 
00481         protected function appendRightsInfo( $property ) {
00482                 global $wgRightsPage, $wgRightsUrl, $wgRightsText;
00483                 $title = Title::newFromText( $wgRightsPage );
00484                 $url = $title ? wfExpandUrl( $title->getFullURL(), PROTO_CURRENT ) : $wgRightsUrl;
00485                 $text = $wgRightsText;
00486                 if ( !$text && $title ) {
00487                         $text = $title->getPrefixedText();
00488                 }
00489 
00490                 $data = array(
00491                         'url' => $url ? $url : '',
00492                         'text' => $text ?  $text : ''
00493                 );
00494 
00495                 return $this->getResult()->addValue( 'query', $property, $data );
00496         }
00497 
00498         public function appendLanguages( $property ) {
00499                 $params = $this->extractRequestParams();
00500                 $langCode = isset( $params['inlanguagecode'] ) ? $params['inlanguagecode'] : '';
00501                 $langNames = Language::fetchLanguageNames( $langCode );
00502 
00503                 $data = array();
00504 
00505                 foreach ( $langNames as $code => $name ) {
00506                         $lang = array( 'code' => $code );
00507                         ApiResult::setContent( $lang, $name );
00508                         $data[] = $lang;
00509                 }
00510                 $this->getResult()->setIndexedTagName( $data, 'lang' );
00511                 return $this->getResult()->addValue( 'query', $property, $data );
00512         }
00513 
00514         public function appendSkins( $property ) {
00515                 $data = array();
00516                 foreach ( Skin::getSkinNames() as $name => $displayName ) {
00517                         $skin = array( 'code' => $name );
00518                         ApiResult::setContent( $skin, $displayName );
00519                         $data[] = $skin;
00520                 }
00521                 $this->getResult()->setIndexedTagName( $data, 'skin' );
00522                 return $this->getResult()->addValue( 'query', $property, $data );
00523         }
00524 
00525         public function appendExtensionTags( $property ) {
00526                 global $wgParser;
00527                 $wgParser->firstCallInit();
00528                 $tags = array_map( array( $this, 'formatParserTags'), $wgParser->getTags() );
00529                 $this->getResult()->setIndexedTagName( $tags, 't' );
00530                 return $this->getResult()->addValue( 'query', $property, $tags );
00531         }
00532 
00533         public function appendFunctionHooks( $property ) {
00534                 global $wgParser;
00535                 $wgParser->firstCallInit();
00536                 $hooks = $wgParser->getFunctionHooks();
00537                 $this->getResult()->setIndexedTagName( $hooks, 'h' );
00538                 return $this->getResult()->addValue( 'query', $property, $hooks );
00539         }
00540 
00541         public function appendVariables( $property ) {
00542                 $variables = MagicWord::getVariableIDs();
00543                 $this->getResult()->setIndexedTagName( $variables, 'v' );
00544                 return $this->getResult()->addValue( 'query', $property, $variables );
00545         }
00546 
00547         private function formatParserTags( $item ) {
00548                 return "<{$item}>";
00549         }
00550 
00551         public function appendSubscribedHooks( $property ) {
00552                 global $wgHooks;
00553                 $myWgHooks = $wgHooks;
00554                 ksort( $myWgHooks );
00555 
00556                 $data = array();
00557                 foreach ( $myWgHooks as $hook => $hooks )  {
00558                         $arr = array(
00559                                 'name' => $hook,
00560                                 'subscribers' => array_map( array( 'SpecialVersion', 'arrayToString' ), $hooks ),
00561                         );
00562 
00563                         $this->getResult()->setIndexedTagName( $arr['subscribers'], 's' );
00564                         $data[] = $arr;
00565                 }
00566 
00567                 $this->getResult()->setIndexedTagName( $data, 'hook' );
00568                 return $this->getResult()->addValue( 'query', $property, $data );
00569         }
00570 
00571         public function getCacheMode( $params ) {
00572                 return 'public';
00573         }
00574 
00575         public function getAllowedParams() {
00576                 return array(
00577                         'prop' => array(
00578                                 ApiBase::PARAM_DFLT => 'general',
00579                                 ApiBase::PARAM_ISMULTI => true,
00580                                 ApiBase::PARAM_TYPE => array(
00581                                         'general',
00582                                         'namespaces',
00583                                         'namespacealiases',
00584                                         'specialpagealiases',
00585                                         'magicwords',
00586                                         'interwikimap',
00587                                         'dbrepllag',
00588                                         'statistics',
00589                                         'usergroups',
00590                                         'extensions',
00591                                         'fileextensions',
00592                                         'rightsinfo',
00593                                         'languages',
00594                                         'skins',
00595                                         'extensiontags',
00596                                         'functionhooks',
00597                                         'showhooks',
00598                                         'variables',
00599                                 )
00600                         ),
00601                         'filteriw' => array(
00602                                 ApiBase::PARAM_TYPE => array(
00603                                         'local',
00604                                         '!local',
00605                                 )
00606                         ),
00607                         'showalldb' => false,
00608                         'numberingroup' => false,
00609                         'inlanguagecode' => null,
00610                 );
00611         }
00612 
00613         public function getParamDescription() {
00614                 $p = $this->getModulePrefix();
00615                 return array(
00616                         'prop' => array(
00617                                 'Which sysinfo properties to get:',
00618                                 ' general               - Overall system information',
00619                                 ' namespaces            - List of registered namespaces and their canonical names',
00620                                 ' namespacealiases      - List of registered namespace aliases',
00621                                 ' specialpagealiases    - List of special page aliases',
00622                                 ' magicwords            - List of magic words and their aliases',
00623                                 ' statistics            - Returns site statistics',
00624                                 " interwikimap          - Returns interwiki map (optionally filtered, (optionally localised by using {$p}inlanguagecode))",
00625                                 ' dbrepllag             - Returns database server with the highest replication lag',
00626                                 ' usergroups            - Returns user groups and the associated permissions',
00627                                 ' extensions            - Returns extensions installed on the wiki',
00628                                 ' fileextensions        - Returns list of file extensions allowed to be uploaded',
00629                                 ' rightsinfo            - Returns wiki rights (license) information if available',
00630                                 " languages             - Returns a list of languages MediaWiki supports (optionally localised by using {$p}inlanguagecode)",
00631                                 ' skins                 - Returns a list of all enabled skins',
00632                                 ' extensiontags         - Returns a list of parser extension tags',
00633                                 ' functionhooks         - Returns a list of parser function hooks',
00634                                 ' showhooks             - Returns a list of all subscribed hooks (contents of $wgHooks)',
00635                                 ' variables             - Returns a list of variable IDs',
00636                         ),
00637                         'filteriw' =>  'Return only local or only nonlocal entries of the interwiki map',
00638                         'showalldb' => 'List all database servers, not just the one lagging the most',
00639                         'numberingroup' => 'Lists the number of users in user groups',
00640                         'inlanguagecode' => 'Language code for localised language names (best effort, use CLDR extension)',
00641                 );
00642         }
00643 
00644         public function getDescription() {
00645                 return 'Return general information about the site';
00646         }
00647 
00648         public function getPossibleErrors() {
00649                 return array_merge( parent::getPossibleErrors(), array(
00650                         array( 'code' => 'includeAllDenied', 'info' => 'Cannot view all servers info unless $wgShowHostnames is true' ),
00651                 ) );
00652         }
00653 
00654         public function getExamples() {
00655                 return array(
00656                         'api.php?action=query&meta=siteinfo&siprop=general|namespaces|namespacealiases|statistics',
00657                         'api.php?action=query&meta=siteinfo&siprop=interwikimap&sifilteriw=local',
00658                         'api.php?action=query&meta=siteinfo&siprop=dbrepllag&sishowalldb=',
00659                 );
00660         }
00661 
00662         public function getHelpUrls() {
00663                 return 'https://www.mediawiki.org/wiki/API:Meta#siteinfo_.2F_si';
00664         }
00665 
00666         public function getVersion() {
00667                 return __CLASS__ . ': $Id$';
00668         }
00669 }