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