/** * @param $main ApiMain * @param $action string */ public function __construct($main, $action) { parent::__construct($main, $action); // Allow custom modules to be added in LocalSettings.php global $wgAPIPropModules, $wgAPIListModules, $wgAPIMetaModules, $wgMemc, $wgAPICacheHelpTimeout; self::appendUserModules($this->mQueryPropModules, $wgAPIPropModules); self::appendUserModules($this->mQueryListModules, $wgAPIListModules); self::appendUserModules($this->mQueryMetaModules, $wgAPIMetaModules); $this->mPropModuleNames = array_keys($this->mQueryPropModules); $this->mListModuleNames = array_keys($this->mQueryListModules); $this->mMetaModuleNames = array_keys($this->mQueryMetaModules); // Get array of query generators from cache if present $key = wfMemcKey('apiquerygenerators', SpecialVersion::getVersion('nodb')); if ($wgAPICacheHelpTimeout > 0) { $cached = $wgMemc->get($key); if ($cached) { $this->mAllowedGenerators = $cached; return; } } $this->makeGeneratorList($this->mQueryPropModules); $this->makeGeneratorList($this->mQueryListModules); if ($wgAPICacheHelpTimeout > 0) { $wgMemc->set($key, $this->mAllowedGenerators, $wgAPICacheHelpTimeout); } }
function heading() { $version = SpecialVersion::getVersion('nodb'); echo "'''Statistics are based on:''' <code>" . $version . "</code>\n\n"; echo "'''Note:''' These statistics can be generated by running <code>php maintenance/language/transstat.php</code>.\n\n"; echo "For additional information on specific languages (the message names, the actual problems, etc.), run <code>php maintenance/language/checkLanguage.php --lang=foo</code>.\n\n"; echo '{| class="sortable wikitable" border="2" cellpadding="4" cellspacing="0" style="background-color: #F9F9F9; border: 1px #AAAAAA solid; border-collapse: collapse; clear:both;" width="100%"' . "\n"; }
function formatCredits($extension) { $out = ''; $name = isset($extension['name']) ? $extension['name'] : '[no name]'; if (isset($extension['path'])) { $svnInfo = SpecialVersion::getSvnInfo(dirname($extension['path'])); $directoryRev = isset($svnInfo['directory-rev']) ? $svnInfo['directory-rev'] : null; $checkoutRev = isset($svnInfo['checkout-rev']) ? $svnInfo['checkout-rev'] : null; $viewvcUrl = isset($svnInfo['viewvc-url']) ? $svnInfo['viewvc-url'] : null; } else { $directoryRev = null; $checkoutRev = null; $viewvcUrl = null; } # Make main link (or just the name if there is no URL) if (isset($extension['url'])) { $mainLink = "[{$extension['url']} {$name}]"; } else { $mainLink = $name; } # Version if (isset($extension['version'])) { $versionText = '<span class="mw-version-ext-version"><em>' . wfMsg('version-version', $extension['version']) . '</em></span> | '; } else { $versionText = ''; } /* if ( $checkoutRev ) { $svnText = wfMsg( 'version-svn-revision', $directoryRev, $checkoutRev ); $svnText = isset( $viewvcUrl ) ? "[$viewvcUrl $svnText]" : $svnText; } else { $svnText = false; }*/ # Make description text $description = isset($extension['description']) ? $extension['description'] : ''; if (isset($extension['descriptionmsg'])) { # Look for a localized description $descriptionMsg = $extension['descriptionmsg']; if (is_array($descriptionMsg)) { $descriptionMsgKey = $descriptionMsg[0]; // Get the message key array_shift($descriptionMsg); // Shift out the message key to get the parameters only array_map("htmlspecialchars", $descriptionMsg); // For sanity $msg = wfMsg($descriptionMsgKey, $descriptionMsg); } else { $msg = wfMsg($descriptionMsg); } if (!wfEmptyMsg($descriptionMsg, $msg) && $msg != '') { $description = $msg; } } $author = isset($extension['author']) ? $extension['author'] : array(); $extDescAuthor = "<td>{$description} <br />" . $versionText . $this->listToText((array) $author, false) . "</td>\n\t\t\t</tr>\n"; $extNameVer = "<tr>\n\t\t\t\t<td><em>{$mainLink}</em></td>"; return $extNameVer . $extDescAuthor; }
/** * Adds ShoutWiki component into Special:Version and sets MW's version to $wgVersion * * @param $software Array: array of software information * @return Boolean: true */ function efAddShoutWikiInfo( &$software ) { global $wgVersion, $IP; // Set MW version to $wgVersion $software['[http://www.mediawiki.org/ MediaWiki]'] = $wgVersion; // Add ShoutWiki component (release branch name) and its revision number $software['[http://www.shoutwiki.com/ ShoutWiki]'] = efGetSvnURL( $IP ) . ' (r' . SpecialVersion::getSvnRevision( $IP ) . ')'; return true; }
/** * @return string */ public function execute() { if ($this->parent->request->wasPosted()) { if ($this->getVar('_Environment')) { return 'continue'; } } $this->parent->output->addWikiText(wfMessage('config-welcome')->plain()); $status = $this->parent->doEnvironmentChecks(); if ($status->isGood()) { $this->parent->output->addHTML('<span class="success-message">' . wfMessage('config-env-good')->escaped() . '</span>'); $this->parent->output->addWikiText(wfMessage('config-copyright', SpecialVersion::getCopyrightAndAuthorList())->plain()); $this->startForm(); $this->endForm(); } else { $this->parent->showStatusMessage($status); } return ''; }
function heading() { global $wgDummyLanguageCodes; $version = SpecialVersion::getVersion('nodb'); echo "'''Statistics are based on:''' <code>" . $version . "</code>\n\n"; echo "'''Note:''' These statistics can be generated by running " . "<code>php maintenance/language/transstat.php</code>.\n\n"; echo "For additional information on specific languages (the message names, the actual " . "problems, etc.), run <code>php maintenance/language/checkLanguage.php --lang=foo</code>.\n\n"; echo 'English (en) is excluded because it is the default localization'; if (is_array($wgDummyLanguageCodes)) { $dummyCodes = array(); foreach ($wgDummyLanguageCodes as $dummyCode => $correctCode) { $dummyCodes[] = Language::fetchLanguageName($dummyCode) . ' (' . $dummyCode . ')'; } echo ', as well as the following languages that are not intended for ' . 'system message translations, usually because they redirect to other ' . 'language codes: ' . implode(', ', $dummyCodes); } echo ".\n\n"; # dot to end sentence echo '{| class="sortable wikitable" border="2" style="background-color: #F9F9F9; ' . 'border: 1px #AAAAAA solid; border-collapse: collapse; clear:both; width:100%;"' . "\n"; }
function register() { global $wgContLang, $wgNamespaceAliases, $wgNonincludableNamespaces; $lib = array('loadSiteStats' => array($this, 'loadSiteStats'), 'getNsIndex' => array($this, 'getNsIndex'), 'pagesInCategory' => array($this, 'pagesInCategory'), 'pagesInNamespace' => array($this, 'pagesInNamespace'), 'usersInGroup' => array($this, 'usersInGroup')); $info = array('siteName' => $GLOBALS['wgSitename'], 'server' => $GLOBALS['wgServer'], 'scriptPath' => $GLOBALS['wgScriptPath'], 'stylePath' => $GLOBALS['wgStylePath'], 'currentVersion' => SpecialVersion::getVersion()); if (!self::$namespacesCache) { $namespaces = array(); $namespacesByName = array(); foreach ($wgContLang->getFormattedNamespaces() as $ns => $title) { $canonical = MWNamespace::getCanonicalName($ns); $namespaces[$ns] = array('id' => $ns, 'name' => $title, 'canonicalName' => strtr($canonical, '_', ' '), 'hasSubpages' => MWNamespace::hasSubpages($ns), 'hasGenderDistinction' => MWNamespace::hasGenderDistinction($ns), 'isCapitalized' => MWNamespace::isCapitalized($ns), 'isContent' => MWNamespace::isContent($ns), 'isIncludable' => !($wgNonincludableNamespaces && in_array($ns, $wgNonincludableNamespaces)), 'isMovable' => MWNamespace::isMovable($ns), 'isSubject' => MWNamespace::isSubject($ns), 'isTalk' => MWNamespace::isTalk($ns), 'aliases' => array()); if ($ns >= NS_MAIN) { $namespaces[$ns]['subject'] = MWNamespace::getSubject($ns); $namespaces[$ns]['talk'] = MWNamespace::getTalk($ns); $namespaces[$ns]['associated'] = MWNamespace::getAssociated($ns); } else { $namespaces[$ns]['subject'] = $ns; } $namespacesByName[strtr($title, ' ', '_')] = $ns; if ($canonical) { $namespacesByName[$canonical] = $ns; } } $aliases = array_merge($wgNamespaceAliases, $wgContLang->getNamespaceAliases()); foreach ($aliases as $title => $ns) { if (!isset($namespacesByName[$title])) { $ct = count($namespaces[$ns]['aliases']); $namespaces[$ns]['aliases'][$ct + 1] = $title; $namespacesByName[$title] = $ns; } } $namespaces[NS_MAIN]['displayName'] = wfMessage('blanknamespace')->text(); self::$namespacesCache = $namespaces; } $info['namespaces'] = self::$namespacesCache; if (self::$siteStatsLoaded) { $stats = $this->loadSiteStats(); $info['stats'] = $stats[0]; } $this->getEngine()->registerInterface('mw.site.lua', $lib, $info); }
function register() { global $wgContLang, $wgNamespaceAliases, $wgDisableCounters; $lib = array('getNsIndex' => array($this, 'getNsIndex'), 'pagesInCategory' => array($this, 'pagesInCategory'), 'pagesInNamespace' => array($this, 'pagesInNamespace'), 'usersInGroup' => array($this, 'usersInGroup'), 'interwikiMap' => array($this, 'interwikiMap')); $info = array('siteName' => $GLOBALS['wgSitename'], 'server' => $GLOBALS['wgServer'], 'scriptPath' => $GLOBALS['wgScriptPath'], 'stylePath' => $GLOBALS['wgStylePath'], 'currentVersion' => SpecialVersion::getVersion()); if (!self::$namespacesCache || self::$namespacesCacheLang !== $wgContLang->getCode()) { $namespaces = array(); $namespacesByName = array(); foreach ($wgContLang->getFormattedNamespaces() as $ns => $title) { $canonical = MWNamespace::getCanonicalName($ns); $namespaces[$ns] = array('id' => $ns, 'name' => $title, 'canonicalName' => strtr($canonical, '_', ' '), 'hasSubpages' => MWNamespace::hasSubpages($ns), 'hasGenderDistinction' => MWNamespace::hasGenderDistinction($ns), 'isCapitalized' => MWNamespace::isCapitalized($ns), 'isContent' => MWNamespace::isContent($ns), 'isIncludable' => !MWNamespace::isNonincludable($ns), 'isMovable' => MWNamespace::isMovable($ns), 'isSubject' => MWNamespace::isSubject($ns), 'isTalk' => MWNamespace::isTalk($ns), 'defaultContentModel' => MWNamespace::getNamespaceContentModel($ns), 'aliases' => array()); if ($ns >= NS_MAIN) { $namespaces[$ns]['subject'] = MWNamespace::getSubject($ns); $namespaces[$ns]['talk'] = MWNamespace::getTalk($ns); $namespaces[$ns]['associated'] = MWNamespace::getAssociated($ns); } else { $namespaces[$ns]['subject'] = $ns; } $namespacesByName[strtr($title, ' ', '_')] = $ns; if ($canonical) { $namespacesByName[$canonical] = $ns; } } $aliases = array_merge($wgNamespaceAliases, $wgContLang->getNamespaceAliases()); foreach ($aliases as $title => $ns) { if (!isset($namespacesByName[$title]) && isset($namespaces[$ns])) { $ct = count($namespaces[$ns]['aliases']); $namespaces[$ns]['aliases'][$ct + 1] = $title; $namespacesByName[$title] = $ns; } } $namespaces[NS_MAIN]['displayName'] = wfMessage('blanknamespace')->inContentLanguage()->text(); self::$namespacesCache = $namespaces; self::$namespacesCacheLang = $wgContLang->getCode(); } $info['namespaces'] = self::$namespacesCache; $info['stats'] = array('pages' => (int) SiteStats::pages(), 'articles' => (int) SiteStats::articles(), 'files' => (int) SiteStats::images(), 'edits' => (int) SiteStats::edits(), 'views' => $wgDisableCounters ? null : (int) SiteStats::views(), 'users' => (int) SiteStats::users(), 'activeUsers' => (int) SiteStats::activeUsers(), 'admins' => (int) SiteStats::numberingroup('sysop')); return $this->getEngine()->registerInterface('mw.site.lua', $lib, $info); }
protected function appendGeneralInfo($property) { global $wgSitename, $wgVersion, $wgCapitalLinks, $wgRightsCode, $wgRightsText, $wgLanguageCode, $IP; $data = array(); $mainPage = Title::newFromText(wfMsgForContent('mainpage')); $data['mainpage'] = $mainPage->getText(); $data['base'] = $mainPage->getFullUrl(); $data['sitename'] = $wgSitename; $data['generator'] = "MediaWiki {$wgVersion}"; $svn = SpecialVersion::getSvnRevision($IP); if ($svn) { $data['rev'] = $svn; } $data['case'] = $wgCapitalLinks ? 'first-letter' : 'case-sensitive'; // 'case-insensitive' option is reserved for future if (isset($wgRightsCode)) { $data['rightscode'] = $wgRightsCode; } $data['rights'] = $wgRightsText; $data['lang'] = $wgLanguageCode; $this->getResult()->addValue('query', $property, $data); }
/** * Return value of a magic variable (like PAGENAME) * * @private */ function getVariableValue($index) { global $wgContLang, $wgSitename, $wgServer, $wgServerName, $wgScriptPath; /** * Some of these require message or data lookups and can be * expensive to check many times. */ if (wfRunHooks('ParserGetVariableValueVarCache', array(&$this, &$this->mVarCache))) { if (isset($this->mVarCache[$index])) { return $this->mVarCache[$index]; } } $ts = wfTimestamp(TS_UNIX, $this->mOptions->getTimestamp()); wfRunHooks('ParserGetVariableValueTs', array(&$this, &$ts)); # Use the time zone global $wgLocaltimezone; if (isset($wgLocaltimezone)) { $oldtz = getenv('TZ'); putenv('TZ=' . $wgLocaltimezone); } wfSuppressWarnings(); // E_STRICT system time bitching $localTimestamp = date('YmdHis', $ts); $localMonth = date('m', $ts); $localMonthName = date('n', $ts); $localDay = date('j', $ts); $localDay2 = date('d', $ts); $localDayOfWeek = date('w', $ts); $localWeek = date('W', $ts); $localYear = date('Y', $ts); $localHour = date('H', $ts); if (isset($wgLocaltimezone)) { putenv('TZ=' . $oldtz); } wfRestoreWarnings(); switch ($index) { case 'currentmonth': return $this->mVarCache[$index] = $wgContLang->formatNum(gmdate('m', $ts)); case 'currentmonthname': return $this->mVarCache[$index] = $wgContLang->getMonthName(gmdate('n', $ts)); case 'currentmonthnamegen': return $this->mVarCache[$index] = $wgContLang->getMonthNameGen(gmdate('n', $ts)); case 'currentmonthabbrev': return $this->mVarCache[$index] = $wgContLang->getMonthAbbreviation(gmdate('n', $ts)); case 'currentday': return $this->mVarCache[$index] = $wgContLang->formatNum(gmdate('j', $ts)); case 'currentday2': return $this->mVarCache[$index] = $wgContLang->formatNum(gmdate('d', $ts)); case 'localmonth': return $this->mVarCache[$index] = $wgContLang->formatNum($localMonth); case 'localmonthname': return $this->mVarCache[$index] = $wgContLang->getMonthName($localMonthName); case 'localmonthnamegen': return $this->mVarCache[$index] = $wgContLang->getMonthNameGen($localMonthName); case 'localmonthabbrev': return $this->mVarCache[$index] = $wgContLang->getMonthAbbreviation($localMonthName); case 'localday': return $this->mVarCache[$index] = $wgContLang->formatNum($localDay); case 'localday2': return $this->mVarCache[$index] = $wgContLang->formatNum($localDay2); case 'pagename': return wfEscapeWikiText($this->mTitle->getText()); case 'pagenamee': return $this->mTitle->getPartialURL(); case 'fullpagename': return wfEscapeWikiText($this->mTitle->getPrefixedText()); case 'fullpagenamee': return $this->mTitle->getPrefixedURL(); case 'subpagename': return wfEscapeWikiText($this->mTitle->getSubpageText()); case 'subpagenamee': return $this->mTitle->getSubpageUrlForm(); case 'basepagename': return wfEscapeWikiText($this->mTitle->getBaseText()); case 'basepagenamee': return wfUrlEncode(str_replace(' ', '_', $this->mTitle->getBaseText())); case 'talkpagename': if ($this->mTitle->canTalk()) { $talkPage = $this->mTitle->getTalkPage(); return wfEscapeWikiText($talkPage->getPrefixedText()); } else { return ''; } case 'talkpagenamee': if ($this->mTitle->canTalk()) { $talkPage = $this->mTitle->getTalkPage(); return $talkPage->getPrefixedUrl(); } else { return ''; } case 'subjectpagename': $subjPage = $this->mTitle->getSubjectPage(); return wfEscapeWikiText($subjPage->getPrefixedText()); case 'subjectpagenamee': $subjPage = $this->mTitle->getSubjectPage(); return $subjPage->getPrefixedUrl(); case 'revisionid': // Let the edit saving system know we should parse the page // *after* a revision ID has been assigned. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONID}} used, setting vary-revision...\n"); return $this->mRevisionId; case 'revisionday': // Let the edit saving system know we should parse the page // *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONDAY}} used, setting vary-revision...\n"); return intval(substr($this->getRevisionTimestamp(), 6, 2)); case 'revisionday2': // Let the edit saving system know we should parse the page // *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONDAY2}} used, setting vary-revision...\n"); return substr($this->getRevisionTimestamp(), 6, 2); case 'revisionmonth': // Let the edit saving system know we should parse the page // *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONMONTH}} used, setting vary-revision...\n"); return intval(substr($this->getRevisionTimestamp(), 4, 2)); case 'revisionyear': // Let the edit saving system know we should parse the page // *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONYEAR}} used, setting vary-revision...\n"); return substr($this->getRevisionTimestamp(), 0, 4); case 'revisiontimestamp': // Let the edit saving system know we should parse the page // *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONTIMESTAMP}} used, setting vary-revision...\n"); return $this->getRevisionTimestamp(); case 'revisionuser': // Let the edit saving system know we should parse the page // *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONUSER}} used, setting vary-revision...\n"); return $this->getRevisionUser(); case 'namespace': return str_replace('_', ' ', $wgContLang->getNsText($this->mTitle->getNamespace())); case 'namespacee': return wfUrlencode($wgContLang->getNsText($this->mTitle->getNamespace())); case 'talkspace': return $this->mTitle->canTalk() ? str_replace('_', ' ', $this->mTitle->getTalkNsText()) : ''; case 'talkspacee': return $this->mTitle->canTalk() ? wfUrlencode($this->mTitle->getTalkNsText()) : ''; case 'subjectspace': return $this->mTitle->getSubjectNsText(); case 'subjectspacee': return wfUrlencode($this->mTitle->getSubjectNsText()); case 'currentdayname': return $this->mVarCache[$index] = $wgContLang->getWeekdayName(gmdate('w', $ts) + 1); case 'currentyear': return $this->mVarCache[$index] = $wgContLang->formatNum(gmdate('Y', $ts), true); case 'currenttime': return $this->mVarCache[$index] = $wgContLang->time(wfTimestamp(TS_MW, $ts), false, false); case 'currenthour': return $this->mVarCache[$index] = $wgContLang->formatNum(gmdate('H', $ts), true); case 'currentweek': // @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to // int to remove the padding return $this->mVarCache[$index] = $wgContLang->formatNum((int) gmdate('W', $ts)); case 'currentdow': return $this->mVarCache[$index] = $wgContLang->formatNum(gmdate('w', $ts)); case 'localdayname': return $this->mVarCache[$index] = $wgContLang->getWeekdayName($localDayOfWeek + 1); case 'localyear': return $this->mVarCache[$index] = $wgContLang->formatNum($localYear, true); case 'localtime': return $this->mVarCache[$index] = $wgContLang->time($localTimestamp, false, false); case 'localhour': return $this->mVarCache[$index] = $wgContLang->formatNum($localHour, true); case 'localweek': // @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to // int to remove the padding return $this->mVarCache[$index] = $wgContLang->formatNum((int) $localWeek); case 'localdow': return $this->mVarCache[$index] = $wgContLang->formatNum($localDayOfWeek); case 'numberofarticles': return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::articles()); case 'numberoffiles': return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::images()); case 'numberofusers': return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::users()); case 'numberofactiveusers': return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::activeUsers()); case 'numberofpages': return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::pages()); case 'numberofadmins': return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::numberingroup('sysop')); case 'numberofedits': return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::edits()); case 'numberofviews': return $this->mVarCache[$index] = $wgContLang->formatNum(SiteStats::views()); case 'currenttimestamp': return $this->mVarCache[$index] = wfTimestamp(TS_MW, $ts); case 'localtimestamp': return $this->mVarCache[$index] = $localTimestamp; case 'currentversion': return $this->mVarCache[$index] = SpecialVersion::getVersion(); case 'sitename': return $wgSitename; case 'server': return $wgServer; case 'servername': return $wgServerName; case 'scriptpath': return $wgScriptPath; case 'directionmark': return $wgContLang->getDirMark(); case 'contentlanguage': global $wgContLanguageCode; return $wgContLanguageCode; default: $ret = null; if (wfRunHooks('ParserGetVariableValueSwitch', array(&$this, &$this->mVarCache, &$index, &$ret))) { return $ret; } else { return null; } } }
[--help] Options: --quick Suppress diff output of failed tests --quiet Suppress notification of passed tests (shows only failed tests) --show-output Show expected and actual output --color Override terminal detection and force color output on or off 'light' option is similar to 'yes' but with color for dark backgrounds --regex Only run tests whose descriptions which match given regex --file Run test cases from a custom file instead of parserTests.txt --help Show this help message ENDS; exit(0); } # There is a convention that the parser should never # refer to $wgTitle directly, but instead use the title # passed to it. $wgTitle = Title::newFromText('Parser test script do not use'); $tester = new ParserTest(); if (isset($options['file'])) { $files = array($options['file']); } else { // Default parser tests and any set from extensions or local config $files = $wgParserTestFiles; } # Print out software version to assist with locating regressions $version = SpecialVersion::getVersion(); echo "This is MediaWiki version {$version}.\n"; $ok = $tester->runTestsFromFiles($files); exit($ok ? 0 : -1);
/** * Returns the version information of this file, plus it includes * the versions for all files that are not callable proper API modules */ public function getVersion() { $vers = array(); $vers[] = 'MediaWiki: ' . SpecialVersion::getVersion() . "\n http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/"; $vers[] = __CLASS__ . ': $Id: ApiMain.php 70066 2010-07-28 05:52:32Z tstarling $'; $vers[] = ApiBase::getBaseVersion(); $vers[] = ApiFormatBase::getBaseVersion(); $vers[] = ApiQueryBase::getBaseVersion(); return $vers; }
/** * Return value of a magic variable (like PAGENAME) * * @private * * @param $index integer * @param $frame PPFrame * * @return string */ function getVariableValue($index, $frame = false) { global $wgContLang, $wgSitename, $wgServer; global $wgArticlePath, $wgScriptPath, $wgStylePath; if (is_null($this->mTitle)) { // If no title set, bad things are going to happen // later. Title should always be set since this // should only be called in the middle of a parse // operation (but the unit-tests do funky stuff) throw new MWException(__METHOD__ . ' Should only be ' . ' called while parsing (no title set)'); } /** * Some of these require message or data lookups and can be * expensive to check many times. */ if (wfRunHooks('ParserGetVariableValueVarCache', array(&$this, &$this->mVarCache))) { if (isset($this->mVarCache[$index])) { return $this->mVarCache[$index]; } } $ts = wfTimestamp(TS_UNIX, $this->mOptions->getTimestamp()); wfRunHooks('ParserGetVariableValueTs', array(&$this, &$ts)); # Use the time zone global $wgLocaltimezone; if (isset($wgLocaltimezone)) { $oldtz = date_default_timezone_get(); date_default_timezone_set($wgLocaltimezone); } $localTimestamp = date('YmdHis', $ts); $localMonth = date('m', $ts); $localMonth1 = date('n', $ts); $localMonthName = date('n', $ts); $localDay = date('j', $ts); $localDay2 = date('d', $ts); $localDayOfWeek = date('w', $ts); $localWeek = date('W', $ts); $localYear = date('Y', $ts); $localHour = date('H', $ts); if (isset($wgLocaltimezone)) { date_default_timezone_set($oldtz); } $pageLang = $this->getFunctionLang(); switch ($index) { case 'currentmonth': $value = $pageLang->formatNum(gmdate('m', $ts)); break; case 'currentmonth1': $value = $pageLang->formatNum(gmdate('n', $ts)); break; case 'currentmonthname': $value = $pageLang->getMonthName(gmdate('n', $ts)); break; case 'currentmonthnamegen': $value = $pageLang->getMonthNameGen(gmdate('n', $ts)); break; case 'currentmonthabbrev': $value = $pageLang->getMonthAbbreviation(gmdate('n', $ts)); break; case 'currentday': $value = $pageLang->formatNum(gmdate('j', $ts)); break; case 'currentday2': $value = $pageLang->formatNum(gmdate('d', $ts)); break; case 'localmonth': $value = $pageLang->formatNum($localMonth); break; case 'localmonth1': $value = $pageLang->formatNum($localMonth1); break; case 'localmonthname': $value = $pageLang->getMonthName($localMonthName); break; case 'localmonthnamegen': $value = $pageLang->getMonthNameGen($localMonthName); break; case 'localmonthabbrev': $value = $pageLang->getMonthAbbreviation($localMonthName); break; case 'localday': $value = $pageLang->formatNum($localDay); break; case 'localday2': $value = $pageLang->formatNum($localDay2); break; case 'pagename': $value = wfEscapeWikiText($this->mTitle->getText()); break; case 'pagenamee': $value = wfEscapeWikiText($this->mTitle->getPartialURL()); break; case 'fullpagename': $value = wfEscapeWikiText($this->mTitle->getPrefixedText()); break; case 'fullpagenamee': $value = wfEscapeWikiText($this->mTitle->getPrefixedURL()); break; case 'subpagename': $value = wfEscapeWikiText($this->mTitle->getSubpageText()); break; case 'subpagenamee': $value = wfEscapeWikiText($this->mTitle->getSubpageUrlForm()); break; case 'basepagename': $value = wfEscapeWikiText($this->mTitle->getBaseText()); break; case 'basepagenamee': $value = wfEscapeWikiText(wfUrlEncode(str_replace(' ', '_', $this->mTitle->getBaseText()))); break; case 'talkpagename': if ($this->mTitle->canTalk()) { $talkPage = $this->mTitle->getTalkPage(); $value = wfEscapeWikiText($talkPage->getPrefixedText()); } else { $value = ''; } break; case 'talkpagenamee': if ($this->mTitle->canTalk()) { $talkPage = $this->mTitle->getTalkPage(); $value = wfEscapeWikiText($talkPage->getPrefixedUrl()); } else { $value = ''; } break; case 'subjectpagename': $subjPage = $this->mTitle->getSubjectPage(); $value = wfEscapeWikiText($subjPage->getPrefixedText()); break; case 'subjectpagenamee': $subjPage = $this->mTitle->getSubjectPage(); $value = wfEscapeWikiText($subjPage->getPrefixedUrl()); break; case 'revisionid': # Let the edit saving system know we should parse the page # *after* a revision ID has been assigned. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONID}} used, setting vary-revision...\n"); $value = $this->mRevisionId; break; case 'revisionday': # Let the edit saving system know we should parse the page # *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONDAY}} used, setting vary-revision...\n"); $value = intval(substr($this->getRevisionTimestamp(), 6, 2)); break; case 'revisionday2': # Let the edit saving system know we should parse the page # *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONDAY2}} used, setting vary-revision...\n"); $value = substr($this->getRevisionTimestamp(), 6, 2); break; case 'revisionmonth': # Let the edit saving system know we should parse the page # *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONMONTH}} used, setting vary-revision...\n"); $value = substr($this->getRevisionTimestamp(), 4, 2); break; case 'revisionmonth1': # Let the edit saving system know we should parse the page # *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONMONTH1}} used, setting vary-revision...\n"); $value = intval(substr($this->getRevisionTimestamp(), 4, 2)); break; case 'revisionyear': # Let the edit saving system know we should parse the page # *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONYEAR}} used, setting vary-revision...\n"); $value = substr($this->getRevisionTimestamp(), 0, 4); break; case 'revisiontimestamp': # Let the edit saving system know we should parse the page # *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONTIMESTAMP}} used, setting vary-revision...\n"); $value = $this->getRevisionTimestamp(); break; case 'revisionuser': # Let the edit saving system know we should parse the page # *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONUSER}} used, setting vary-revision...\n"); $value = $this->getRevisionUser(); break; case 'namespace': $value = str_replace('_', ' ', $wgContLang->getNsText($this->mTitle->getNamespace())); break; case 'namespacee': $value = wfUrlencode($wgContLang->getNsText($this->mTitle->getNamespace())); break; case 'talkspace': $value = $this->mTitle->canTalk() ? str_replace('_', ' ', $this->mTitle->getTalkNsText()) : ''; break; case 'talkspacee': $value = $this->mTitle->canTalk() ? wfUrlencode($this->mTitle->getTalkNsText()) : ''; break; case 'subjectspace': $value = $this->mTitle->getSubjectNsText(); break; case 'subjectspacee': $value = wfUrlencode($this->mTitle->getSubjectNsText()); break; case 'currentdayname': $value = $pageLang->getWeekdayName(gmdate('w', $ts) + 1); break; case 'currentyear': $value = $pageLang->formatNum(gmdate('Y', $ts), true); break; case 'currenttime': $value = $pageLang->time(wfTimestamp(TS_MW, $ts), false, false); break; case 'currenthour': $value = $pageLang->formatNum(gmdate('H', $ts), true); break; case 'currentweek': # @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to # int to remove the padding $value = $pageLang->formatNum((int) gmdate('W', $ts)); break; case 'currentdow': $value = $pageLang->formatNum(gmdate('w', $ts)); break; case 'localdayname': $value = $pageLang->getWeekdayName($localDayOfWeek + 1); break; case 'localyear': $value = $pageLang->formatNum($localYear, true); break; case 'localtime': $value = $pageLang->time($localTimestamp, false, false); break; case 'localhour': $value = $pageLang->formatNum($localHour, true); break; case 'localweek': # @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to # int to remove the padding $value = $pageLang->formatNum((int) $localWeek); break; case 'localdow': $value = $pageLang->formatNum($localDayOfWeek); break; case 'numberofarticles': $value = $pageLang->formatNum(SiteStats::articles()); break; case 'numberoffiles': $value = $pageLang->formatNum(SiteStats::images()); break; case 'numberofusers': $value = $pageLang->formatNum(SiteStats::users()); break; case 'numberofactiveusers': $value = $pageLang->formatNum(SiteStats::activeUsers()); break; case 'numberofpages': $value = $pageLang->formatNum(SiteStats::pages()); break; case 'numberofadmins': $value = $pageLang->formatNum(SiteStats::numberingroup('sysop')); break; case 'numberofedits': $value = $pageLang->formatNum(SiteStats::edits()); break; case 'numberofviews': $value = $pageLang->formatNum(SiteStats::views()); break; case 'currenttimestamp': $value = wfTimestamp(TS_MW, $ts); break; case 'localtimestamp': $value = $localTimestamp; break; case 'currentversion': $value = SpecialVersion::getVersion(); break; case 'articlepath': return $wgArticlePath; case 'sitename': return $wgSitename; case 'server': return $wgServer; case 'servername': $serverParts = wfParseUrl($wgServer); return $serverParts && isset($serverParts['host']) ? $serverParts['host'] : $wgServer; case 'scriptpath': return $wgScriptPath; case 'stylepath': return $wgStylePath; case 'directionmark': return $pageLang->getDirMark(); case 'contentlanguage': global $wgLanguageCode; return $wgLanguageCode; default: $ret = null; if (wfRunHooks('ParserGetVariableValueSwitch', array(&$this, &$this->mVarCache, &$index, &$ret, &$frame))) { return $ret; } else { return null; } } if ($index) { $this->mVarCache[$index] = $value; } return $value; }
/** * Override the parent to generate help messages for all available modules. * * @deprecated since 1.25 * @return string */ public function makeHelpMsg() { wfDeprecated(__METHOD__, '1.25'); global $wgMemc; $this->setHelp(); // Get help text from cache if present $key = wfMemcKey('apihelp', $this->getModuleName(), str_replace(' ', '_', SpecialVersion::getVersion('nodb'))); $cacheHelpTimeout = $this->getConfig()->get('APICacheHelpTimeout'); if ($cacheHelpTimeout > 0) { $cached = $wgMemc->get($key); if ($cached) { return $cached; } } $retval = $this->reallyMakeHelpMsg(); if ($cacheHelpTimeout > 0) { $wgMemc->set($key, $retval, $cacheHelpTimeout); } return $retval; }
/** * @param $view CodeView * */ function __construct($view) { global $IP; $this->mView = $view; $this->mRepo = $view->mRepo; $this->mDefaultDirection = true; $this->mCurSVN = SpecialVersion::getSvnRevision($IP); parent::__construct(); }
/** * Returns an array with the base extension types. * Type is stored as array key, the message as array value. * * TODO: ideally this would return all extension types, including * those added by SpecialVersionExtensionTypes. This is not possible * since this hook is passing along $this though. * * @since 1.17 * * @return array */ public static function getExtensionTypes() { if (self::$extensionTypes === false) { self::$extensionTypes = array('specialpage' => wfMessage('version-specialpages')->text(), 'parserhook' => wfMessage('version-parserhooks')->text(), 'variable' => wfMessage('version-variables')->text(), 'media' => wfMessage('version-mediahandlers')->text(), 'antispam' => wfMessage('version-antispam')->text(), 'skin' => wfMessage('version-skins')->text(), 'api' => wfMessage('version-api')->text(), 'other' => wfMessage('version-other')->text()); wfRunHooks('ExtensionTypes', array(&self::$extensionTypes)); } return self::$extensionTypes; }
/** * Returns the version information of this file, plus it includes * the versions for all files that are not callable proper API modules * * @return array */ public function getVersion() { $vers = array(); $vers[] = 'MediaWiki: ' . SpecialVersion::getVersion() . "\n https://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/"; $vers[] = __CLASS__ . ': $Id$'; $vers[] = ApiBase::getBaseVersion(); $vers[] = ApiFormatBase::getBaseVersion(); $vers[] = ApiQueryBase::getBaseVersion(); return $vers; }
/** * Creates and outputs the filter control. * * @since 0.1 */ protected function displayFilterControl() { global $wgOut, $wgExtensionCredits; $extensionAmount = 0; $filterSegments = array(); $extensionTypes = SpecialVersion::getExtensionTypes(); foreach ($extensionTypes as $type => $message) { if (!array_key_exists($type, $wgExtensionCredits)) { continue; } $amount = count($wgExtensionCredits[$type]); if ($amount > 0) { $filterSegments[] = $this->getTypeLink($type, $message, $amount); $extensionAmount += $amount; } } $all = array($this->getTypeLink('all', wfMsg('extension-type-all'), $extensionAmount)); $wgOut->addHTML(implode(' | ', array_merge($all, $filterSegments))); }
/** * Returns the version information of this file, plus it includes * the versions for all files that are not callable proper API modules */ public function getVersion() { $vers = array(); $vers[] = 'MediaWiki ' . SpecialVersion::getVersion(); $vers[] = __CLASS__ . ': $Id: ApiMain.php 24494 2007-07-31 17:53:37Z yurik $'; $vers[] = ApiBase::getBaseVersion(); $vers[] = ApiFormatBase::getBaseVersion(); $vers[] = ApiQueryBase::getBaseVersion(); $vers[] = ApiFormatFeedWrapper::getVersion(); // not accessible with format=xxx return $vers; }
--run-disabled run disabled tests --run-parsoid run parsoid tests (normally disabled) ENDS; exit(0); } # Cases of weird db corruption were encountered when running tests on earlyish # versions of SQLite if ($wgDBtype == 'sqlite') { $db = wfGetDB(DB_MASTER); $version = $db->getServerVersion(); if (version_compare($version, '3.6') < 0) { die("Parser tests require SQLite version 3.6 or later, you have {$version}\n"); } } $tester = new ParserTest($options); if (isset($options['file'])) { $files = array($options['file']); } else { // Default parser tests and any set from extensions or local config $files = $wgParserTestFiles; } # Print out software version to assist with locating regressions $version = SpecialVersion::getVersion('nodb'); echo "This is MediaWiki version {$version}.\n\n"; if (isset($options['fuzz'])) { $tester->fuzzTest($files); } else { $ok = $tester->runTestsFromFiles($files); exit($ok ? 0 : 1); }
/** * constructor */ function wfSpecialVersion() { $version = new SpecialVersion(); $version->execute(); }
/** * Override the parent to generate help messages for all available modules. * * @deprecated since 1.25 * @return string */ public function makeHelpMsg() { wfDeprecated(__METHOD__, '1.25'); $this->setHelp(); $cacheHelpTimeout = $this->getConfig()->get('APICacheHelpTimeout'); return ObjectCache::getMainWANInstance()->getWithSetCallback(wfMemcKey('apihelp', $this->getModuleName(), str_replace(' ', '_', SpecialVersion::getVersion('nodb'))), $cacheHelpTimeout > 0 ? $cacheHelpTimeout : WANObjectCache::TTL_UNCACHEABLE, array($this, 'reallyMakeHelpMsg')); }
/** * Returns the version information of this file, plus it includes * the versions for all files that are not callable proper API modules */ public function getVersion() { $vers = array(); $vers[] = 'MediaWiki: ' . SpecialVersion::getVersion() . "\n http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/"; $vers[] = __CLASS__ . ': $Id: ApiMain.php 69990 2010-07-27 08:44:08Z tstarling $'; $vers[] = ApiBase::getBaseVersion(); $vers[] = ApiFormatBase::getBaseVersion(); $vers[] = ApiQueryBase::getBaseVersion(); $vers[] = ApiFormatFeedWrapper::getVersion(); // not accessible with format=xxx return $vers; }
protected function appendGeneralInfo($property) { global $wgSitename, $wgVersion, $wgCapitalLinks, $wgRightsCode, $wgRightsText, $wgContLang; global $wgLanguageCode, $IP, $wgEnableWriteAPI, $wgLang, $wgLocaltimezone, $wgLocalTZoffset; $data = array(); $mainPage = Title::newFromText(wfMsgForContent('mainpage')); $data['mainpage'] = $mainPage->getPrefixedText(); $data['base'] = $mainPage->getFullUrl(); $data['sitename'] = $wgSitename; $data['generator'] = "MediaWiki {$wgVersion}"; $svn = SpecialVersion::getSvnRevision($IP); if ($svn) { $data['rev'] = $svn; } $data['case'] = $wgCapitalLinks ? 'first-letter' : 'case-sensitive'; // 'case-insensitive' option is reserved for future if (isset($wgRightsCode)) { $data['rightscode'] = $wgRightsCode; } $data['rights'] = $wgRightsText; $data['lang'] = $wgLanguageCode; if ($wgContLang->isRTL()) { $data['rtl'] = ''; } $data['fallback8bitEncoding'] = $wgLang->fallback8bitEncoding(); if (wfReadOnly()) { $data['readonly'] = ''; } if ($wgEnableWriteAPI) { $data['writeapi'] = ''; } $tz = $wgLocaltimezone; $offset = $wgLocalTZoffset; if (is_null($tz)) { $tz = 'UTC'; $offset = 0; } elseif (is_null($offset)) { $offset = 0; } $data['timezone'] = $tz; $data['timeoffset'] = intval($offset); return $this->getResult()->addValue('query', $property, $data); }
/** * Return value of a magic variable (like PAGENAME) * * @private * * @param $index integer * @param bool|\PPFrame $frame * * @throws MWException * @return string */ function getVariableValue($index, $frame = false) { global $wgContLang, $wgSitename, $wgServer; global $wgArticlePath, $wgScriptPath, $wgStylePath; if (is_null($this->mTitle)) { // If no title set, bad things are going to happen // later. Title should always be set since this // should only be called in the middle of a parse // operation (but the unit-tests do funky stuff) throw new MWException(__METHOD__ . ' Should only be ' . ' called while parsing (no title set)'); } /** * Some of these require message or data lookups and can be * expensive to check many times. */ if (wfRunHooks('ParserGetVariableValueVarCache', array(&$this, &$this->mVarCache))) { if (isset($this->mVarCache[$index])) { return $this->mVarCache[$index]; } } $ts = wfTimestamp(TS_UNIX, $this->mOptions->getTimestamp()); wfRunHooks('ParserGetVariableValueTs', array(&$this, &$ts)); $pageLang = $this->getFunctionLang(); switch ($index) { case 'currentmonth': $value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('m')); break; case 'currentmonth1': $value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('n')); break; case 'currentmonthname': $value = $pageLang->getMonthName(MWTimestamp::getInstance($ts)->format('n')); break; case 'currentmonthnamegen': $value = $pageLang->getMonthNameGen(MWTimestamp::getInstance($ts)->format('n')); break; case 'currentmonthabbrev': $value = $pageLang->getMonthAbbreviation(MWTimestamp::getInstance($ts)->format('n')); break; case 'currentday': $value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('j')); break; case 'currentday2': $value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('d')); break; case 'localmonth': $value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('m')); break; case 'localmonth1': $value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('n')); break; case 'localmonthname': $value = $pageLang->getMonthName(MWTimestamp::getLocalInstance($ts)->format('n')); break; case 'localmonthnamegen': $value = $pageLang->getMonthNameGen(MWTimestamp::getLocalInstance($ts)->format('n')); break; case 'localmonthabbrev': $value = $pageLang->getMonthAbbreviation(MWTimestamp::getLocalInstance($ts)->format('n')); break; case 'localday': $value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('j')); break; case 'localday2': $value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('d')); break; case 'pagename': $value = wfEscapeWikiText($this->mTitle->getText()); break; case 'pagenamee': $value = wfEscapeWikiText($this->mTitle->getPartialURL()); break; case 'fullpagename': $value = wfEscapeWikiText($this->mTitle->getPrefixedText()); break; case 'fullpagenamee': $value = wfEscapeWikiText($this->mTitle->getPrefixedURL()); break; case 'subpagename': $value = wfEscapeWikiText($this->mTitle->getSubpageText()); break; case 'subpagenamee': $value = wfEscapeWikiText($this->mTitle->getSubpageUrlForm()); break; case 'rootpagename': $value = wfEscapeWikiText($this->mTitle->getRootText()); break; case 'rootpagenamee': $value = wfEscapeWikiText(wfUrlEncode(str_replace(' ', '_', $this->mTitle->getRootText()))); break; case 'basepagename': $value = wfEscapeWikiText($this->mTitle->getBaseText()); break; case 'basepagenamee': $value = wfEscapeWikiText(wfUrlEncode(str_replace(' ', '_', $this->mTitle->getBaseText()))); break; case 'talkpagename': if ($this->mTitle->canTalk()) { $talkPage = $this->mTitle->getTalkPage(); $value = wfEscapeWikiText($talkPage->getPrefixedText()); } else { $value = ''; } break; case 'talkpagenamee': if ($this->mTitle->canTalk()) { $talkPage = $this->mTitle->getTalkPage(); $value = wfEscapeWikiText($talkPage->getPrefixedURL()); } else { $value = ''; } break; case 'subjectpagename': $subjPage = $this->mTitle->getSubjectPage(); $value = wfEscapeWikiText($subjPage->getPrefixedText()); break; case 'subjectpagenamee': $subjPage = $this->mTitle->getSubjectPage(); $value = wfEscapeWikiText($subjPage->getPrefixedURL()); break; case 'pageid': // requested in bug 23427 $pageid = $this->getTitle()->getArticleID(); if ($pageid == 0) { # 0 means the page doesn't exist in the database, # which means the user is previewing a new page. # The vary-revision flag must be set, because the magic word # will have a different value once the page is saved. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{PAGEID}} used in a new page, setting vary-revision...\n"); } $value = $pageid ? $pageid : null; break; case 'revisionid': # Let the edit saving system know we should parse the page # *after* a revision ID has been assigned. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONID}} used, setting vary-revision...\n"); $value = $this->mRevisionId; break; case 'revisionday': # Let the edit saving system know we should parse the page # *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONDAY}} used, setting vary-revision...\n"); $value = intval(substr($this->getRevisionTimestamp(), 6, 2)); break; case 'revisionday2': # Let the edit saving system know we should parse the page # *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONDAY2}} used, setting vary-revision...\n"); $value = substr($this->getRevisionTimestamp(), 6, 2); break; case 'revisionmonth': # Let the edit saving system know we should parse the page # *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONMONTH}} used, setting vary-revision...\n"); $value = substr($this->getRevisionTimestamp(), 4, 2); break; case 'revisionmonth1': # Let the edit saving system know we should parse the page # *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONMONTH1}} used, setting vary-revision...\n"); $value = intval(substr($this->getRevisionTimestamp(), 4, 2)); break; case 'revisionyear': # Let the edit saving system know we should parse the page # *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONYEAR}} used, setting vary-revision...\n"); $value = substr($this->getRevisionTimestamp(), 0, 4); break; case 'revisiontimestamp': # Let the edit saving system know we should parse the page # *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONTIMESTAMP}} used, setting vary-revision...\n"); $value = $this->getRevisionTimestamp(); break; case 'revisionuser': # Let the edit saving system know we should parse the page # *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONUSER}} used, setting vary-revision...\n"); $value = $this->getRevisionUser(); break; case 'revisionsize': # Let the edit saving system know we should parse the page # *after* a revision ID has been assigned. This is for null edits. $this->mOutput->setFlag('vary-revision'); wfDebug(__METHOD__ . ": {{REVISIONSIZE}} used, setting vary-revision...\n"); $value = $this->getRevisionSize(); break; case 'namespace': $value = str_replace('_', ' ', $wgContLang->getNsText($this->mTitle->getNamespace())); break; case 'namespacee': $value = wfUrlencode($wgContLang->getNsText($this->mTitle->getNamespace())); break; case 'namespacenumber': $value = $this->mTitle->getNamespace(); break; case 'talkspace': $value = $this->mTitle->canTalk() ? str_replace('_', ' ', $this->mTitle->getTalkNsText()) : ''; break; case 'talkspacee': $value = $this->mTitle->canTalk() ? wfUrlencode($this->mTitle->getTalkNsText()) : ''; break; case 'subjectspace': $value = str_replace('_', ' ', $this->mTitle->getSubjectNsText()); break; case 'subjectspacee': $value = wfUrlencode($this->mTitle->getSubjectNsText()); break; case 'currentdayname': $value = $pageLang->getWeekdayName((int) MWTimestamp::getInstance($ts)->format('w') + 1); break; case 'currentyear': $value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('Y'), true); break; case 'currenttime': $value = $pageLang->time(wfTimestamp(TS_MW, $ts), false, false); break; case 'currenthour': $value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('H'), true); break; case 'currentweek': # @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to # int to remove the padding $value = $pageLang->formatNum((int) MWTimestamp::getInstance($ts)->format('W')); break; case 'currentdow': $value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('w')); break; case 'localdayname': $value = $pageLang->getWeekdayName((int) MWTimestamp::getLocalInstance($ts)->format('w') + 1); break; case 'localyear': $value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('Y'), true); break; case 'localtime': $value = $pageLang->time(MWTimestamp::getLocalInstance($ts)->format('YmdHis'), false, false); break; case 'localhour': $value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('H'), true); break; case 'localweek': # @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to # int to remove the padding $value = $pageLang->formatNum((int) MWTimestamp::getLocalInstance($ts)->format('W')); break; case 'localdow': $value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('w')); break; case 'numberofarticles': $value = $pageLang->formatNum(SiteStats::articles()); break; case 'numberoffiles': $value = $pageLang->formatNum(SiteStats::images()); break; case 'numberofusers': $value = $pageLang->formatNum(SiteStats::users()); break; case 'numberofactiveusers': $value = $pageLang->formatNum(SiteStats::activeUsers()); break; case 'numberofpages': $value = $pageLang->formatNum(SiteStats::pages()); break; case 'numberofadmins': $value = $pageLang->formatNum(SiteStats::numberingroup('sysop')); break; case 'numberofedits': $value = $pageLang->formatNum(SiteStats::edits()); break; case 'numberofviews': global $wgDisableCounters; $value = !$wgDisableCounters ? $pageLang->formatNum(SiteStats::views()) : ''; break; case 'currenttimestamp': $value = wfTimestamp(TS_MW, $ts); break; case 'localtimestamp': $value = MWTimestamp::getLocalInstance($ts)->format('YmdHis'); break; case 'currentversion': $value = SpecialVersion::getVersion(); break; case 'articlepath': return $wgArticlePath; case 'sitename': return $wgSitename; case 'server': return $wgServer; case 'servername': $serverParts = wfParseUrl($wgServer); return $serverParts && isset($serverParts['host']) ? $serverParts['host'] : $wgServer; case 'scriptpath': return $wgScriptPath; case 'stylepath': return $wgStylePath; case 'directionmark': return $pageLang->getDirMark(); case 'contentlanguage': global $wgLanguageCode; return $wgLanguageCode; case 'cascadingsources': $value = CoreParserFunctions::cascadingsources($this); break; default: $ret = null; wfRunHooks('ParserGetVariableValueSwitch', array(&$this, &$this->mVarCache, &$index, &$ret, &$frame)); return $ret; } if ($index) { $this->mVarCache[$index] = $value; } return $value; }
protected function getGenerator() { return 'MediaWiki ' . SpecialVersion::getVersion() . "; Translate extension (" . TRANSLATE_VERSION . ")"; }
protected function appendGeneralInfo($property) { global $wgContLang; $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_name(); $data['dbtype'] = $GLOBALS['wgDBtype']; $data['dbversion'] = $this->getDB()->getServerVersion(); $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->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'] = ''; } wfRunHooks('APIQuerySiteInfoGeneralInfo', array($this, &$data)); return $this->getResult()->addValue('query', $property, $data); }
/** * Returns the version information of this file, plus it includes * the versions for all files that are not callable proper API modules */ public function getVersion() { $vers = array(); $vers[] = 'MediaWiki: ' . SpecialVersion::getVersion() . "\n http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/"; $vers[] = __CLASS__ . ': $Id: ApiMain.php 50834 2009-05-20 20:10:47Z catrope $'; $vers[] = ApiBase::getBaseVersion(); $vers[] = ApiFormatBase::getBaseVersion(); $vers[] = ApiQueryBase::getBaseVersion(); $vers[] = ApiFormatFeedWrapper::getVersion(); // not accessible with format=xxx return $vers; }
/** * Recursively-called function to actually construct the help * * @param IContextSource $context * @param ApiBase[] $modules * @param array $options * @param array &$haveModules * @return string */ private static function getHelpInternal(IContextSource $context, array $modules, array $options, &$haveModules) { $out = ''; $level = empty($options['headerlevel']) ? 2 : $options['headerlevel']; if (empty($options['tocnumber'])) { $tocnumber = array(2 => 0); } else { $tocnumber =& $options['tocnumber']; } foreach ($modules as $module) { $tocnumber[$level]++; $path = $module->getModulePath(); $module->setContext($context); $help = array('header' => '', 'flags' => '', 'description' => '', 'help-urls' => '', 'parameters' => '', 'examples' => '', 'submodules' => ''); if (empty($options['noheader']) || !empty($options['toc'])) { $anchor = $path; $i = 1; while (isset($haveModules[$anchor])) { $anchor = $path . '|' . ++$i; } if ($module->isMain()) { $header = $context->msg('api-help-main-header')->parse(); } else { $name = $module->getModuleName(); $header = $module->getParent()->getModuleManager()->getModuleGroup($name) . "={$name}"; if ($module->getModulePrefix() !== '') { $header .= ' ' . $context->msg('parentheses', $module->getModulePrefix())->parse(); } } $haveModules[$anchor] = array('toclevel' => count($tocnumber), 'level' => $level, 'anchor' => $anchor, 'line' => $header, 'number' => join('.', $tocnumber), 'index' => false); if (empty($options['noheader'])) { $help['header'] .= Html::element('h' . min(6, $level), array('id' => $anchor, 'class' => 'apihelp-header'), $header); } } else { $haveModules[$path] = true; } $links = array(); $any = false; for ($m = $module; $m !== null; $m = $m->getParent()) { $name = $m->getModuleName(); if ($name === 'main_int') { $name = 'main'; } if (count($modules) === 1 && $m === $modules[0] && !(!empty($options['submodules']) && $m->getModuleManager())) { $link = Html::element('b', null, $name); } else { $link = SpecialPage::getTitleFor('ApiHelp', $m->getModulePath())->getLocalURL(); $link = Html::element('a', array('href' => $link, 'class' => 'apihelp-linktrail'), $name); $any = true; } array_unshift($links, $link); } if ($any) { $help['header'] .= self::wrap($context->msg('parentheses')->rawParams($context->getLanguage()->pipeList($links)), 'apihelp-linktrail', 'div'); } $flags = $module->getHelpFlags(); $help['flags'] .= Html::openElement('div', array('class' => 'apihelp-block apihelp-flags')); $msg = $context->msg('api-help-flags'); if (!$msg->isDisabled()) { $help['flags'] .= self::wrap($msg->numParams(count($flags)), 'apihelp-block-head', 'div'); } $help['flags'] .= Html::openElement('ul'); foreach ($flags as $flag) { $help['flags'] .= Html::rawElement('li', null, self::wrap($context->msg("api-help-flag-{$flag}"), "apihelp-flag-{$flag}")); } $sourceInfo = $module->getModuleSourceInfo(); if ($sourceInfo) { if (isset($sourceInfo['namemsg'])) { $extname = $context->msg($sourceInfo['namemsg'])->text(); } else { $extname = $sourceInfo['name']; } $help['flags'] .= Html::rawElement('li', null, self::wrap($context->msg('api-help-source', $extname, $sourceInfo['name']), 'apihelp-source')); $link = SpecialPage::getTitleFor('Version', 'License/' . $sourceInfo['name']); if (isset($sourceInfo['license-name'])) { $msg = $context->msg('api-help-license', $link, $sourceInfo['license-name']); } elseif (SpecialVersion::getExtLicenseFileName(dirname($sourceInfo['path']))) { $msg = $context->msg('api-help-license-noname', $link); } else { $msg = $context->msg('api-help-license-unknown'); } $help['flags'] .= Html::rawElement('li', null, self::wrap($msg, 'apihelp-license')); } else { $help['flags'] .= Html::rawElement('li', null, self::wrap($context->msg('api-help-source-unknown'), 'apihelp-source')); $help['flags'] .= Html::rawElement('li', null, self::wrap($context->msg('api-help-license-unknown'), 'apihelp-license')); } $help['flags'] .= Html::closeElement('ul'); $help['flags'] .= Html::closeElement('div'); foreach ($module->getFinalDescription() as $msg) { $msg->setContext($context); $help['description'] .= $msg->parseAsBlock(); } $urls = $module->getHelpUrls(); if ($urls) { $help['help-urls'] .= Html::openElement('div', array('class' => 'apihelp-block apihelp-help-urls')); $msg = $context->msg('api-help-help-urls'); if (!$msg->isDisabled()) { $help['help-urls'] .= self::wrap($msg->numParams(count($urls)), 'apihelp-block-head', 'div'); } if (!is_array($urls)) { $urls = array($urls); } $help['help-urls'] .= Html::openElement('ul'); foreach ($urls as $url) { $help['help-urls'] .= Html::rawElement('li', null, Html::element('a', array('href' => $url), $url)); } $help['help-urls'] .= Html::closeElement('ul'); $help['help-urls'] .= Html::closeElement('div'); } $params = $module->getFinalParams(ApiBase::GET_VALUES_FOR_HELP); $dynamicParams = $module->dynamicParameterDocumentation(); $groups = array(); if ($params || $dynamicParams !== null) { $help['parameters'] .= Html::openElement('div', array('class' => 'apihelp-block apihelp-parameters')); $msg = $context->msg('api-help-parameters'); if (!$msg->isDisabled()) { $help['parameters'] .= self::wrap($msg->numParams(count($params)), 'apihelp-block-head', 'div'); } $help['parameters'] .= Html::openElement('dl'); $descriptions = $module->getFinalParamDescription(); foreach ($params as $name => $settings) { if (!is_array($settings)) { $settings = array(ApiBase::PARAM_DFLT => $settings); } $help['parameters'] .= Html::element('dt', null, $module->encodeParamName($name)); // Add description $description = array(); if (isset($descriptions[$name])) { foreach ($descriptions[$name] as $msg) { $msg->setContext($context); $description[] = $msg->parseAsBlock(); } } // Add usage info $info = array(); // Required? if (!empty($settings[ApiBase::PARAM_REQUIRED])) { $info[] = $context->msg('api-help-param-required')->parse(); } // Custom info? if (!empty($settings[ApiBase::PARAM_HELP_MSG_INFO])) { foreach ($settings[ApiBase::PARAM_HELP_MSG_INFO] as $i) { $tag = array_shift($i); $info[] = $context->msg("apihelp-{$path}-paraminfo-{$tag}")->numParams(count($i))->params($context->getLanguage()->commaList($i))->params($module->getModulePrefix())->parse(); } } // Type documentation if (!isset($settings[ApiBase::PARAM_TYPE])) { $dflt = isset($settings[ApiBase::PARAM_DFLT]) ? $settings[ApiBase::PARAM_DFLT] : null; if (is_bool($dflt)) { $settings[ApiBase::PARAM_TYPE] = 'boolean'; } elseif (is_string($dflt) || is_null($dflt)) { $settings[ApiBase::PARAM_TYPE] = 'string'; } elseif (is_int($dflt)) { $settings[ApiBase::PARAM_TYPE] = 'integer'; } } if (isset($settings[ApiBase::PARAM_TYPE])) { $type = $settings[ApiBase::PARAM_TYPE]; $multi = !empty($settings[ApiBase::PARAM_ISMULTI]); $hintPipeSeparated = true; $count = ApiBase::LIMIT_SML2 + 1; if (is_array($type)) { $count = count($type); $links = isset($settings[ApiBase::PARAM_VALUE_LINKS]) ? $settings[ApiBase::PARAM_VALUE_LINKS] : array(); $type = array_map(function ($v) use($links) { $ret = wfEscapeWikiText($v); if (isset($links[$v])) { $ret = "[[{$links[$v]}|{$ret}]]"; } return $ret; }, $type); $i = array_search('', $type, true); if ($i === false) { $type = $context->getLanguage()->commaList($type); } else { unset($type[$i]); $type = $context->msg('api-help-param-list-can-be-empty')->numParams(count($type))->params($context->getLanguage()->commaList($type))->parse(); } $info[] = $context->msg('api-help-param-list')->params($multi ? 2 : 1)->params($type)->parse(); $hintPipeSeparated = false; } else { switch ($type) { case 'submodule': $groups[] = $name; if (isset($settings[ApiBase::PARAM_SUBMODULE_MAP])) { $map = $settings[ApiBase::PARAM_SUBMODULE_MAP]; ksort($map); $submodules = array(); foreach ($map as $v => $m) { $submodules[] = "[[Special:ApiHelp/{$m}|{$v}]]"; } } else { $submodules = $module->getModuleManager()->getNames($name); sort($submodules); $prefix = $module->isMain() ? '' : $module->getModulePath() . '+'; $submodules = array_map(function ($name) use($prefix) { return "[[Special:ApiHelp/{$prefix}{$name}|{$name}]]"; }, $submodules); } $count = count($submodules); $info[] = $context->msg('api-help-param-list')->params($multi ? 2 : 1)->params($context->getLanguage()->commaList($submodules))->parse(); $hintPipeSeparated = false; // No type message necessary, we have a list of values. $type = null; break; case 'namespace': $namespaces = MWNamespace::getValidNamespaces(); $count = count($namespaces); $info[] = $context->msg('api-help-param-list')->params($multi ? 2 : 1)->params($context->getLanguage()->commaList($namespaces))->parse(); $hintPipeSeparated = false; // No type message necessary, we have a list of values. $type = null; break; case 'limit': if (isset($settings[ApiBase::PARAM_MAX2])) { $info[] = $context->msg('api-help-param-limit2')->numParams($settings[ApiBase::PARAM_MAX])->numParams($settings[ApiBase::PARAM_MAX2])->parse(); } else { $info[] = $context->msg('api-help-param-limit')->numParams($settings[ApiBase::PARAM_MAX])->parse(); } break; case 'integer': // Possible messages: // api-help-param-integer-min, // api-help-param-integer-max, // api-help-param-integer-minmax $suffix = ''; $min = $max = 0; if (isset($settings[ApiBase::PARAM_MIN])) { $suffix .= 'min'; $min = $settings[ApiBase::PARAM_MIN]; } if (isset($settings[ApiBase::PARAM_MAX])) { $suffix .= 'max'; $max = $settings[ApiBase::PARAM_MAX]; } if ($suffix !== '') { $info[] = $context->msg("api-help-param-integer-{$suffix}")->params($multi ? 2 : 1)->numParams($min, $max)->parse(); } break; case 'upload': $info[] = $context->msg('api-help-param-upload')->parse(); // No type message necessary, api-help-param-upload should handle it. $type = null; break; case 'string': case 'text': // Displaying a type message here would be useless. $type = null; break; } } // Add type. Messages for grep: api-help-param-type-limit // api-help-param-type-integer api-help-param-type-boolean // api-help-param-type-timestamp api-help-param-type-user // api-help-param-type-password if (is_string($type)) { $msg = $context->msg("api-help-param-type-{$type}"); if (!$msg->isDisabled()) { $info[] = $msg->params($multi ? 2 : 1)->parse(); } } if ($multi) { $extra = array(); if ($hintPipeSeparated) { $extra[] = $context->msg('api-help-param-multi-separate')->parse(); } if ($count > ApiBase::LIMIT_SML1) { $extra[] = $context->msg('api-help-param-multi-max')->numParams(ApiBase::LIMIT_SML1, ApiBase::LIMIT_SML2)->parse(); } if ($extra) { $info[] = join(' ', $extra); } } } // Add default $default = isset($settings[ApiBase::PARAM_DFLT]) ? $settings[ApiBase::PARAM_DFLT] : null; if ($default === '') { $info[] = $context->msg('api-help-param-default-empty')->parse(); } elseif ($default !== null && $default !== false) { $info[] = $context->msg('api-help-param-default')->params(wfEscapeWikiText($default))->parse(); } if (!array_filter($description)) { $description = array(self::wrap($context->msg('api-help-param-no-description'), 'apihelp-empty')); } // Add "deprecated" flag if (!empty($settings[ApiBase::PARAM_DEPRECATED])) { $help['parameters'] .= Html::openElement('dd', array('class' => 'info')); $help['parameters'] .= self::wrap($context->msg('api-help-param-deprecated'), 'apihelp-deprecated', 'strong'); $help['parameters'] .= Html::closeElement('dd'); } if ($description) { $description = join('', $description); $description = preg_replace('!\\s*</([oud]l)>\\s*<\\1>\\s*!', "\n", $description); $help['parameters'] .= Html::rawElement('dd', array('class' => 'description'), $description); } foreach ($info as $i) { $help['parameters'] .= Html::rawElement('dd', array('class' => 'info'), $i); } } if ($dynamicParams !== null) { $dynamicParams = ApiBase::makeMessage($dynamicParams, $context, array($module->getModulePrefix(), $module->getModuleName(), $module->getModulePath())); $help['parameters'] .= Html::element('dt', null, '*'); $help['parameters'] .= Html::rawElement('dd', array('class' => 'description'), $dynamicParams->parse()); } $help['parameters'] .= Html::closeElement('dl'); $help['parameters'] .= Html::closeElement('div'); } $examples = $module->getExamplesMessages(); if ($examples) { $help['examples'] .= Html::openElement('div', array('class' => 'apihelp-block apihelp-examples')); $msg = $context->msg('api-help-examples'); if (!$msg->isDisabled()) { $help['examples'] .= self::wrap($msg->numParams(count($examples)), 'apihelp-block-head', 'div'); } $help['examples'] .= Html::openElement('dl'); foreach ($examples as $qs => $msg) { $msg = ApiBase::makeMessage($msg, $context, array($module->getModulePrefix(), $module->getModuleName(), $module->getModulePath())); $link = wfAppendQuery(wfScript('api'), $qs); $help['examples'] .= Html::rawElement('dt', null, $msg->parse()); $help['examples'] .= Html::rawElement('dd', null, Html::element('a', array('href' => $link), "api.php?{$qs}")); } $help['examples'] .= Html::closeElement('dl'); $help['examples'] .= Html::closeElement('div'); } $subtocnumber = $tocnumber; $subtocnumber[$level + 1] = 0; $suboptions = array('submodules' => $options['recursivesubmodules'], 'headerlevel' => $level + 1, 'tocnumber' => &$subtocnumber, 'noheader' => false) + $options; if ($options['submodules'] && $module->getModuleManager()) { $manager = $module->getModuleManager(); $submodules = array(); foreach ($groups as $group) { $names = $manager->getNames($group); sort($names); foreach ($names as $name) { $submodules[] = $manager->getModule($name); } } $help['submodules'] .= self::getHelpInternal($context, $submodules, $suboptions, $haveModules); } $module->modifyHelp($help, $suboptions, $haveModules); Hooks::run('APIHelpModifyOutput', array($module, &$help, $suboptions, &$haveModules)); $out .= join("\n", $help); } return $out; }
protected function appendExtensions($property) { global $wgExtensionCredits; $data = array(); foreach ($wgExtensionCredits as $type => $extensions) { foreach ($extensions as $ext) { $ret = array(); $ret['type'] = $type; if (isset($ext['name'])) { $ret['name'] = $ext['name']; } if (isset($ext['description'])) { $ret['description'] = $ext['description']; } if (isset($ext['descriptionmsg'])) { // Can be a string or array( key, param1, param2, ... ) if (is_array($ext['descriptionmsg'])) { $ret['descriptionmsg'] = $ext['descriptionmsg'][0]; $ret['descriptionmsgparams'] = array_slice($ext['descriptionmsg'], 1); $this->getResult()->setIndexedTagName($ret['descriptionmsgparams'], 'param'); } else { $ret['descriptionmsg'] = $ext['descriptionmsg']; } } if (isset($ext['author'])) { $ret['author'] = is_array($ext['author']) ? implode(', ', $ext['author']) : $ext['author']; } if (isset($ext['url'])) { $ret['url'] = $ext['url']; } if (isset($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]; } if (isset($ext['path'])) { $extensionPath = dirname($ext['path']); $gitInfo = new GitInfo($extensionPath); $vcsVersion = $gitInfo->getHeadSHA1(); if ($vcsVersion !== false) { $ret['vcs-system'] = 'git'; $ret['vcs-version'] = $vcsVersion; $ret['vcs-url'] = $gitInfo->getHeadViewUrl(); $vcsDate = $gitInfo->getHeadCommitDate(); if ($vcsDate !== false) { $ret['vcs-date'] = wfTimestamp(TS_ISO_8601, $vcsDate); } } else { $svnInfo = SpecialVersion::getSvnInfo($extensionPath); if ($svnInfo !== false) { $ret['vcs-system'] = 'svn'; $ret['vcs-version'] = $svnInfo['checkout-rev']; $ret['vcs-url'] = isset($svnInfo['viewvc-url']) ? $svnInfo['viewvc-url'] : ''; } } if (SpecialVersion::getExtLicenseFileName($extensionPath)) { $ret['license-name'] = isset($ext['license-name']) ? $ext['license-name'] : ''; $ret['license'] = SpecialPage::getTitleFor('Version', "License/{$ext['name']}")->getLinkURL(); } if (SpecialVersion::getExtAuthorsFileName($extensionPath)) { $ret['credits'] = SpecialPage::getTitleFor('Version', "Credits/{$ext['name']}")->getLinkURL(); } } $data[] = $ret; } } $this->getResult()->setIndexedTagName($data, 'ext'); return $this->getResult()->addValue('query', $property, $data); }