protected function appendGeneralInfo($property) { global $wgContLang, $wgDisableLangConversion, $wgDisableTitleConversion; $data = array(); $mainPage = Title::newMainPage(); $data['mainpage'] = $mainPage->getPrefixedText(); $data['base'] = wfExpandUrl($mainPage->getFullURL(), PROTO_CURRENT); $data['sitename'] = $GLOBALS['wgSitename']; // wgLogo can either be a relative or an absolute path // make sure we always return an absolute path $data['logo'] = wfExpandUrl($GLOBALS['wgLogo'], PROTO_RELATIVE); $data['generator'] = "MediaWiki {$GLOBALS['wgVersion']}"; $data['phpversion'] = phpversion(); $data['phpsapi'] = PHP_SAPI; $data['dbtype'] = $GLOBALS['wgDBtype']; $data['dbversion'] = $this->getDB()->getServerVersion(); $allowFrom = array(''); $allowException = true; if (!$GLOBALS['wgAllowExternalImages']) { if ($GLOBALS['wgEnableImageWhitelist']) { $data['imagewhitelistenabled'] = ''; } $allowFrom = $GLOBALS['wgAllowExternalImagesFrom']; $allowException = !empty($allowFrom); } if ($allowException) { $data['externalimages'] = (array) $allowFrom; $this->getResult()->setIndexedTagName($data['externalimages'], 'prefix'); } if (!$wgDisableLangConversion) { $data['langconversion'] = ''; } if (!$wgDisableTitleConversion) { $data['titleconversion'] = ''; } if ($wgContLang->linkPrefixExtension()) { $linkPrefixCharset = $wgContLang->linkPrefixCharset(); $data['linkprefixcharset'] = $linkPrefixCharset; // For backwards compatability $data['linkprefix'] = "/^((?>.*[^{$linkPrefixCharset}]|))(.+)\$/sDu"; } else { $data['linkprefixcharset'] = ''; $data['linkprefix'] = ''; } $linktrail = $wgContLang->linkTrail(); if ($linktrail) { $data['linktrail'] = $linktrail; } else { $data['linktrail'] = ''; } $git = SpecialVersion::getGitHeadSha1($GLOBALS['IP']); if ($git) { $data['git-hash'] = $git; } else { $svn = SpecialVersion::getSvnRevision($GLOBALS['IP']); if ($svn) { $data['rev'] = $svn; } } // 'case-insensitive' option is reserved for future $data['case'] = $GLOBALS['wgCapitalLinks'] ? 'first-letter' : 'case-sensitive'; $data['lang'] = $GLOBALS['wgLanguageCode']; $fallbacks = array(); foreach ($wgContLang->getFallbackLanguages() as $code) { $fallbacks[] = array('code' => $code); } $data['fallback'] = $fallbacks; $this->getResult()->setIndexedTagName($data['fallback'], 'lang'); if ($wgContLang->hasVariants()) { $variants = array(); foreach ($wgContLang->getVariants() as $code) { $variants[] = array('code' => $code, 'name' => $wgContLang->getVariantname($code)); } $data['variants'] = $variants; $this->getResult()->setIndexedTagName($data['variants'], 'lang'); } if ($wgContLang->isRTL()) { $data['rtl'] = ''; } $data['fallback8bitEncoding'] = $wgContLang->fallback8bitEncoding(); if (wfReadOnly()) { $data['readonly'] = ''; $data['readonlyreason'] = wfReadOnlyReason(); } if ($GLOBALS['wgEnableWriteAPI']) { $data['writeapi'] = ''; } $tz = $GLOBALS['wgLocaltimezone']; $offset = $GLOBALS['wgLocalTZoffset']; if (is_null($tz)) { $tz = 'UTC'; $offset = 0; } elseif (is_null($offset)) { $offset = 0; } $data['timezone'] = $tz; $data['timeoffset'] = intval($offset); $data['articlepath'] = $GLOBALS['wgArticlePath']; $data['scriptpath'] = $GLOBALS['wgScriptPath']; $data['script'] = $GLOBALS['wgScript']; $data['variantarticlepath'] = $GLOBALS['wgVariantArticlePath']; $data['server'] = $GLOBALS['wgServer']; $data['wikiid'] = wfWikiID(); $data['time'] = wfTimestamp(TS_ISO_8601, time()); if ($GLOBALS['wgMiserMode']) { $data['misermode'] = ''; } $data['maxuploadsize'] = UploadBase::getMaxUploadSize(); $data['thumblimits'] = $GLOBALS['wgThumbLimits']; $this->getResult()->setIndexedTagName($data['thumblimits'], 'limit'); $data['imagelimits'] = array(); $this->getResult()->setIndexedTagName($data['imagelimits'], 'limit'); foreach ($GLOBALS['wgImageLimits'] as $k => $limit) { $data['imagelimits'][$k] = array('width' => $limit[0], 'height' => $limit[1]); } if (!empty($GLOBALS['wgFavicon'])) { // wgFavicon can either be a relative or an absolute path // make sure we always return an absolute path $data['favicon'] = wfExpandUrl($GLOBALS['wgFavicon'], PROTO_RELATIVE); } wfRunHooks('APIQuerySiteInfoGeneralInfo', array($this, &$data)); return $this->getResult()->addValue('query', $property, $data); }
/** * Returns a string that identifies the version of the class. * Includes the class name, the svn revision, timestamp, and * last author. * * @return string */ function getVersion() { global $sfgIP; $gitSha1 = SpecialVersion::getGitHeadSha1($sfgIP); return __CLASS__ . '-' . SF_VERSION . ($gitSha1 !== false) ? ' (' . substr($gitSha1, 0, 7) . ')' : ''; }
protected function appendGeneralInfo($property) { global $wgContLang; $config = $this->getConfig(); $data = array(); $mainPage = Title::newMainPage(); $data['mainpage'] = $mainPage->getPrefixedText(); $data['base'] = wfExpandUrl($mainPage->getFullURL(), PROTO_CURRENT); $data['sitename'] = $config->get('Sitename'); // wgLogo can either be a relative or an absolute path // make sure we always return an absolute path $data['logo'] = wfExpandUrl($config->get('Logo'), PROTO_RELATIVE); $data['generator'] = "MediaWiki {$config->get('Version')}"; $data['phpversion'] = PHP_VERSION; $data['phpsapi'] = PHP_SAPI; if (defined('HHVM_VERSION')) { $data['hhvmversion'] = HHVM_VERSION; } $data['dbtype'] = $config->get('DBtype'); $data['dbversion'] = $this->getDB()->getServerVersion(); $allowFrom = array(''); $allowException = true; if (!$config->get('AllowExternalImages')) { $data['imagewhitelistenabled'] = (bool) $config->get('EnableImageWhitelist'); $allowFrom = $config->get('AllowExternalImagesFrom'); $allowException = !empty($allowFrom); } if ($allowException) { $data['externalimages'] = (array) $allowFrom; ApiResult::setIndexedTagName($data['externalimages'], 'prefix'); } $data['langconversion'] = !$config->get('DisableLangConversion'); $data['titleconversion'] = !$config->get('DisableTitleConversion'); if ($wgContLang->linkPrefixExtension()) { $linkPrefixCharset = $wgContLang->linkPrefixCharset(); $data['linkprefixcharset'] = $linkPrefixCharset; // For backwards compatibility $data['linkprefix'] = "/^((?>.*[^{$linkPrefixCharset}]|))(.+)\$/sDu"; } else { $data['linkprefixcharset'] = ''; $data['linkprefix'] = ''; } $linktrail = $wgContLang->linkTrail(); $data['linktrail'] = $linktrail ?: ''; $data['legaltitlechars'] = Title::legalChars(); global $IP; $git = SpecialVersion::getGitHeadSha1($IP); if ($git) { $data['git-hash'] = $git; $data['git-branch'] = SpecialVersion::getGitCurrentBranch($GLOBALS['IP']); } else { $svn = SpecialVersion::getSvnRevision($IP); if ($svn) { $data['rev'] = $svn; } } // 'case-insensitive' option is reserved for future $data['case'] = $config->get('CapitalLinks') ? 'first-letter' : 'case-sensitive'; $data['lang'] = $config->get('LanguageCode'); $fallbacks = array(); foreach ($wgContLang->getFallbackLanguages() as $code) { $fallbacks[] = array('code' => $code); } $data['fallback'] = $fallbacks; ApiResult::setIndexedTagName($data['fallback'], 'lang'); if ($wgContLang->hasVariants()) { $variants = array(); foreach ($wgContLang->getVariants() as $code) { $variants[] = array('code' => $code, 'name' => $wgContLang->getVariantname($code)); } $data['variants'] = $variants; ApiResult::setIndexedTagName($data['variants'], 'lang'); } $data['rtl'] = $wgContLang->isRTL(); $data['fallback8bitEncoding'] = $wgContLang->fallback8bitEncoding(); $data['readonly'] = wfReadOnly(); if ($data['readonly']) { $data['readonlyreason'] = wfReadOnlyReason(); } $data['writeapi'] = (bool) $config->get('EnableWriteAPI'); $tz = $config->get('Localtimezone'); $offset = $config->get('LocalTZoffset'); if (is_null($tz)) { $tz = 'UTC'; $offset = 0; } elseif (is_null($offset)) { $offset = 0; } $data['timezone'] = $tz; $data['timeoffset'] = intval($offset); $data['articlepath'] = $config->get('ArticlePath'); $data['scriptpath'] = $config->get('ScriptPath'); $data['script'] = $config->get('Script'); $data['variantarticlepath'] = $config->get('VariantArticlePath'); $data[ApiResult::META_BC_BOOLS][] = 'variantarticlepath'; $data['server'] = $config->get('Server'); $data['servername'] = $config->get('ServerName'); $data['wikiid'] = wfWikiID(); $data['time'] = wfTimestamp(TS_ISO_8601, time()); $data['misermode'] = (bool) $config->get('MiserMode'); $data['maxuploadsize'] = UploadBase::getMaxUploadSize(); $data['minuploadchunksize'] = (int) $this->getConfig()->get('MinUploadChunkSize'); $data['thumblimits'] = $config->get('ThumbLimits'); ApiResult::setArrayType($data['thumblimits'], 'BCassoc'); ApiResult::setIndexedTagName($data['thumblimits'], 'limit'); $data['imagelimits'] = array(); ApiResult::setArrayType($data['imagelimits'], 'BCassoc'); ApiResult::setIndexedTagName($data['imagelimits'], 'limit'); foreach ($config->get('ImageLimits') as $k => $limit) { $data['imagelimits'][$k] = array('width' => $limit[0], 'height' => $limit[1]); } $favicon = $config->get('Favicon'); if (!empty($favicon)) { // wgFavicon can either be a relative or an absolute path // make sure we always return an absolute path $data['favicon'] = wfExpandUrl($favicon, PROTO_RELATIVE); } Hooks::run('APIQuerySiteInfoGeneralInfo', array($this, &$data)); return $this->getResult()->addValue('query', $property, $data); }
protected function appendGeneralInfo($property) { global $wgContLang, $wgDisableLangConversion, $wgDisableTitleConversion; $data = array(); $mainPage = Title::newMainPage(); $data['mainpage'] = $mainPage->getPrefixedText(); $data['base'] = wfExpandUrl($mainPage->getFullUrl(), PROTO_CURRENT); $data['sitename'] = $GLOBALS['wgSitename']; $data['generator'] = "MediaWiki {$GLOBALS['wgVersion']}"; $data['phpversion'] = phpversion(); $data['phpsapi'] = PHP_SAPI; $data['dbtype'] = $GLOBALS['wgDBtype']; $data['dbversion'] = $this->getDB()->getServerVersion(); if (!$wgDisableLangConversion) { $data['langconversion'] = ''; } if (!$wgDisableTitleConversion) { $data['titleconversion'] = ''; } if ($wgContLang->linkPrefixExtension()) { $data['linkprefix'] = wfMessage('linkprefix')->inContentLanguage()->text(); } else { $data['linkprefix'] = ''; } $linktrail = $wgContLang->linkTrail(); if ($linktrail) { $data['linktrail'] = $linktrail; } else { $data['linktrail'] = ''; } $git = SpecialVersion::getGitHeadSha1($GLOBALS['IP']); if ($git) { $data['git-hash'] = $git; } else { $svn = SpecialVersion::getSvnRevision($GLOBALS['IP']); if ($svn) { $data['rev'] = $svn; } } // 'case-insensitive' option is reserved for future $data['case'] = $GLOBALS['wgCapitalLinks'] ? 'first-letter' : 'case-sensitive'; if (isset($GLOBALS['wgRightsCode'])) { $data['rightscode'] = $GLOBALS['wgRightsCode']; } $data['rights'] = $GLOBALS['wgRightsText']; $data['lang'] = $GLOBALS['wgLanguageCode']; $fallbacks = array(); foreach ($wgContLang->getFallbackLanguages() as $code) { $fallbacks[] = array('code' => $code); } $data['fallback'] = $fallbacks; $this->getResult()->setIndexedTagName($data['fallback'], 'lang'); if ($wgContLang->hasVariants()) { $variants = array(); foreach ($wgContLang->getVariants() as $code) { $variants[] = array('code' => $code); } $data['variants'] = $variants; $this->getResult()->setIndexedTagName($data['variants'], 'lang'); } if ($wgContLang->isRTL()) { $data['rtl'] = ''; } $data['fallback8bitEncoding'] = $wgContLang->fallback8bitEncoding(); if (wfReadOnly()) { $data['readonly'] = ''; $data['readonlyreason'] = wfReadOnlyReason(); } if ($GLOBALS['wgEnableWriteAPI']) { $data['writeapi'] = ''; } $tz = $GLOBALS['wgLocaltimezone']; $offset = $GLOBALS['wgLocalTZoffset']; if (is_null($tz)) { $tz = 'UTC'; $offset = 0; } elseif (is_null($offset)) { $offset = 0; } $data['timezone'] = $tz; $data['timeoffset'] = intval($offset); $data['articlepath'] = $GLOBALS['wgArticlePath']; $data['scriptpath'] = $GLOBALS['wgScriptPath']; $data['script'] = $GLOBALS['wgScript']; $data['variantarticlepath'] = $GLOBALS['wgVariantArticlePath']; $data['server'] = $GLOBALS['wgServer']; $data['wikiid'] = wfWikiID(); $data['time'] = wfTimestamp(TS_ISO_8601, time()); if ($GLOBALS['wgMiserMode']) { $data['misermode'] = ''; } $data['maxuploadsize'] = UploadBase::getMaxUploadSize(); wfRunHooks('APIQuerySiteInfoGeneralInfo', array($this, &$data)); return $this->getResult()->addValue('query', $property, $data); }