Example #1
0
 /**
  * @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);
     }
 }
Example #2
0
 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";
 }
Example #3
0
 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";
 }
Example #4
0
 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);
 }
Example #5
0
 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);
 }
Example #6
0
 /**
  * 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 76196 2010-11-06 16:11:19Z reedy $';
     $vers[] = ApiBase::getBaseVersion();
     $vers[] = ApiFormatBase::getBaseVersion();
     $vers[] = ApiQueryBase::getBaseVersion();
     return $vers;
 }
Example #7
0
  --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);
}
 /**
  * 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;
 }
    /**
     * Globals: $wgContLang, $IP
     */
    function outputWiki()
    {
        global $wgContLang, $IP;
        $detailText = '';
        $rows[] = '! Language !! Code !! Total !! ' . implode(' !! ', $this->checks);
        foreach ($this->results as $code => $results) {
            $detailTextForLang = "=={$code}==\n";
            $numbers = array();
            $problems = 0;
            $detailTextForLangChecks = array();
            foreach ($results as $check => $messages) {
                $count = count($messages);
                if ($count) {
                    $problems += $count;
                    $messageDetails = array();
                    foreach ($messages as $key => $details) {
                        $messageDetails[] = $key;
                    }
                    $detailTextForLangChecks[] = "==={$code}-{$check}===\n* " . implode(', ', $messageDetails);
                    $numbers[] = "'''[[#{$code}-{$check}|{$count}]]'''";
                } else {
                    $numbers[] = $count;
                }
            }
            if (count($detailTextForLangChecks)) {
                $detailText .= $detailTextForLang . implode("\n", $detailTextForLangChecks) . "\n";
            }
            if (!$problems) {
                continue;
            }
            // Don't list languages without problems
            $language = $wgContLang->getLanguageName($code);
            $rows[] = "| {$language} || {$code} || {$problems} || " . implode(' || ', $numbers);
        }
        $tableRows = implode("\n|-\n", $rows);
        $version = SpecialVersion::getVersion($IP);
        echo <<<EOL
'''Check results are for:''' <code>{$version}</code>


{| class="sortable wikitable" border="2" cellpadding="4" cellspacing="0" style="background-color: #F9F9F9; border: 1px #AAAAAA solid; border-collapse: collapse; clear:both;"
{$tableRows}
|}

{$detailText}

EOL;
    }
Example #10
0
 /**
  * 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'));
 }
Example #11
0
 /**
  * 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;
 }
Example #12
0
 /**
  * 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;
 }
Example #13
0
 /**
  * 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;
 }
Example #14
0
                           [--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);
Example #15
0
	protected function getGenerator() {
		return 'MediaWiki ' . SpecialVersion::getVersion() .
			"; Translate extension (" . TRANSLATE_VERSION . ")";
	}
Example #16
0
 public function execute()
 {
     global $wgParserTestFiles, $wgDBtype;
     // 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");
         }
     }
     // Print out software version to assist with locating regressions
     $version = SpecialVersion::getVersion('nodb');
     echo "This is MediaWiki version {$version}.\n\n";
     // Only colorize output if stdout is a terminal.
     $color = !wfIsWindows() && Maintenance::posix_isatty(1);
     if ($this->hasOption('color')) {
         switch ($this->getOption('color')) {
             case 'no':
                 $color = false;
                 break;
             case 'yes':
             default:
                 $color = true;
                 break;
         }
     }
     $record = $this->hasOption('record');
     $compare = $this->hasOption('compare');
     $regex = $this->getOption('filter', $this->getOption('regex', false));
     if ($regex !== false) {
         $regex = "/{$regex}/i";
         if ($record) {
             echo "Warning: --record cannot be used with --regex, disabling --record\n";
             $record = false;
         }
     }
     $term = $color ? new AnsiTermColorer() : new DummyTermColorer();
     $recorder = new MultiTestRecorder();
     $recorder->addRecorder(new ParserTestPrinter($term, ['showDiffs' => !$this->hasOption('quick'), 'showProgress' => !$this->hasOption('quiet'), 'showFailure' => !$this->hasOption('quiet') || !$record && !$compare, 'showOutput' => $this->hasOption('show-output'), 'useDwdiff' => $this->hasOption('dwdiff'), 'markWhitespace' => $this->hasOption('mark-ws')]));
     $recorderLB = false;
     if ($record || $compare) {
         $recorderLB = wfGetLBFactory()->newMainLB();
         // This connection will have the wiki's table prefix, not parsertest_
         $recorderDB = $recorderLB->getConnection(DB_MASTER);
         // Add recorder before previewer because recorder will create the
         // DB table if it doesn't exist
         if ($record) {
             $recorder->addRecorder(new DbTestRecorder($recorderDB));
         }
         $recorder->addRecorder(new DbTestPreviewer($recorderDB, function ($name) use($regex) {
             // Filter reports of old tests by the filter regex
             if ($regex === false) {
                 return true;
             } else {
                 return (bool) preg_match($regex, $name);
             }
         }));
     }
     // Default parser tests and any set from extensions or local config
     $files = $this->getOption('file', $wgParserTestFiles);
     $norm = $this->hasOption('norm') ? explode(',', $this->getOption('norm')) : [];
     $tester = new ParserTestRunner($recorder, ['norm' => $norm, 'regex' => $regex, 'keep-uploads' => $this->hasOption('keep-uploads'), 'run-disabled' => $this->hasOption('run-disabled'), 'run-parsoid' => $this->hasOption('run-parsoid'), 'use-tidy-config' => $this->hasOption('use-tidy-config'), 'file-backend' => $this->getOption('file-backend'), 'upload-dir' => $this->getOption('upload-dir')]);
     $ok = $tester->runTestsFromFiles($files);
     if ($recorderLB) {
         $recorderLB->closeAll();
     }
     if (!$ok) {
         exit(1);
     }
 }
Example #17
0
 /**
  * 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.
      */
     static $varCache = array();
     if (wfRunHooks('ParserGetVariableValueVarCache', array(&$this, &$varCache))) {
         if (isset($varCache[$index])) {
             return $varCache[$index];
         }
     }
     $ts = time();
     wfRunHooks('ParserGetVariableValueTs', array(&$this, &$ts));
     # Use the time zone
     global $wgLocaltimezone;
     if (isset($wgLocaltimezone)) {
         $oldtz = getenv('TZ');
         putenv('TZ=' . $wgLocaltimezone);
     }
     $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);
     }
     switch ($index) {
         case 'currentmonth':
             return $varCache[$index] = $wgContLang->formatNum(date('m', $ts));
         case 'currentmonthname':
             return $varCache[$index] = $wgContLang->getMonthName(date('n', $ts));
         case 'currentmonthnamegen':
             return $varCache[$index] = $wgContLang->getMonthNameGen(date('n', $ts));
         case 'currentmonthabbrev':
             return $varCache[$index] = $wgContLang->getMonthAbbreviation(date('n', $ts));
         case 'currentday':
             return $varCache[$index] = $wgContLang->formatNum(date('j', $ts));
         case 'currentday2':
             return $varCache[$index] = $wgContLang->formatNum(date('d', $ts));
         case 'localmonth':
             return $varCache[$index] = $wgContLang->formatNum($localMonth);
         case 'localmonthname':
             return $varCache[$index] = $wgContLang->getMonthName($localMonthName);
         case 'localmonthnamegen':
             return $varCache[$index] = $wgContLang->getMonthNameGen($localMonthName);
         case 'localmonthabbrev':
             return $varCache[$index] = $wgContLang->getMonthAbbreviation($localMonthName);
         case 'localday':
             return $varCache[$index] = $wgContLang->formatNum($localDay);
         case 'localday2':
             return $varCache[$index] = $wgContLang->formatNum($localDay2);
         case 'pagename':
             return $this->mTitle->getText();
         case 'pagenamee':
             return $this->mTitle->getPartialURL();
         case 'fullpagename':
             return $this->mTitle->getPrefixedText();
         case 'fullpagenamee':
             return $this->mTitle->getPrefixedURL();
         case 'subpagename':
             return $this->mTitle->getSubpageText();
         case 'subpagenamee':
             return $this->mTitle->getSubpageUrlForm();
         case 'basepagename':
             return $this->mTitle->getBaseText();
         case 'basepagenamee':
             return wfUrlEncode(str_replace(' ', '_', $this->mTitle->getBaseText()));
         case 'talkpagename':
             if ($this->mTitle->canTalk()) {
                 $talkPage = $this->mTitle->getTalkPage();
                 return $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 $subjPage->getPrefixedText();
         case 'subjectpagenamee':
             $subjPage = $this->mTitle->getSubjectPage();
             return $subjPage->getPrefixedUrl();
         case 'revisionid':
             return $this->mRevisionId;
         case 'revisionday':
             return intval(substr(wfRevisionTimestamp($this->mRevisionId), 6, 2));
         case 'revisionday2':
             return substr(wfRevisionTimestamp($this->mRevisionId), 6, 2);
         case 'revisionmonth':
             return intval(substr(wfRevisionTimestamp($this->mRevisionId), 4, 2));
         case 'revisionyear':
             return substr(wfRevisionTimestamp($this->mRevisionId), 0, 4);
         case 'revisiontimestamp':
             return wfRevisionTimestamp($this->mRevisionId);
         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 $varCache[$index] = $wgContLang->getWeekdayName(date('w', $ts) + 1);
         case 'currentyear':
             return $varCache[$index] = $wgContLang->formatNum(date('Y', $ts), true);
         case 'currenttime':
             return $varCache[$index] = $wgContLang->time(wfTimestamp(TS_MW, $ts), false, false);
         case 'currenthour':
             return $varCache[$index] = $wgContLang->formatNum(date('H', $ts), true);
         case 'currentweek':
             // @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to
             // int to remove the padding
             return $varCache[$index] = $wgContLang->formatNum((int) date('W', $ts));
         case 'currentdow':
             return $varCache[$index] = $wgContLang->formatNum(date('w', $ts));
         case 'localdayname':
             return $varCache[$index] = $wgContLang->getWeekdayName($localDayOfWeek + 1);
         case 'localyear':
             return $varCache[$index] = $wgContLang->formatNum($localYear, true);
         case 'localtime':
             return $varCache[$index] = $wgContLang->time($localTimestamp, false, false);
         case 'localhour':
             return $varCache[$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 $varCache[$index] = $wgContLang->formatNum((int) $localWeek);
         case 'localdow':
             return $varCache[$index] = $wgContLang->formatNum($localDayOfWeek);
         case 'numberofarticles':
             return $varCache[$index] = $wgContLang->formatNum(wfNumberOfArticles());
         case 'numberoffiles':
             return $varCache[$index] = $wgContLang->formatNum(wfNumberOfFiles());
         case 'numberofusers':
             return $varCache[$index] = $wgContLang->formatNum(wfNumberOfUsers());
         case 'numberofpages':
             return $varCache[$index] = $wgContLang->formatNum(wfNumberOfPages());
         case 'numberofadmins':
             return $varCache[$index] = $wgContLang->formatNum(wfNumberOfAdmins());
         case 'currenttimestamp':
             return $varCache[$index] = wfTimestampNow();
         case 'localtimestamp':
             return $varCache[$index] = $localTimestamp;
         case 'currentversion':
             return $varCache[$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, &$varCache, &$index, &$ret))) {
                 return $ret;
             } else {
                 return null;
             }
     }
 }
 public function prepareVariables()
 {
     global $wgContLang, $wgSitename, $wgServer, $wgServerName, $wgScriptPath;
     global $wgContLanguageCode;
     global $wgTitle;
     $this->mRevisionId = $this->mTitle->getLatestRevID();
     $ts = time();
     # 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();
     // some simpler ones...
     $w2lVars = array('currentmonth' => $wgContLang->formatNum(gmdate('m', $ts)), 'currentmonthname' => $wgContLang->getMonthName(gmdate('n', $ts)), 'currentmonthnamegen' => $wgContLang->getMonthNameGen(gmdate('n', $ts)), 'currentmonthabbrev' => $wgContLang->getMonthAbbreviation(gmdate('n', $ts)), 'currentday' => $wgContLang->formatNum(gmdate('j', $ts)), 'currentday2' => $wgContLang->formatNum(gmdate('d', $ts)), 'localmonth' => $wgContLang->formatNum($localMonth), 'localmonthname' => $wgContLang->getMonthName($localMonthName), 'localmonthnamegen' => $wgContLang->getMonthNameGen($localMonthName), 'localmonthabbrev' => $wgContLang->getMonthAbbreviation($localMonthName), 'localday' => $wgContLang->formatNum($localDay), 'localday2' => $wgContLang->formatNum($localDay2), 'pagename' => wfEscapeWikiText($this->mTitle->getText()), 'pagenamee' => $this->mTitle->getPartialURL(), 'fullpagename' => wfEscapeWikiText($this->mTitle->getPrefixedText()), 'fullpagenamee' => $this->mTitle->getPrefixedURL(), 'subpagename' => wfEscapeWikiText($this->mTitle->getSubpageText()), 'subpagenamee' => $this->mTitle->getSubpageUrlForm(), 'basepagename' => wfEscapeWikiText($this->mTitle->getBaseText()), 'basepagenamee' => wfUrlEncode(str_replace(' ', '_', $this->mTitle->getBaseText())), 'revisionid' => $this->mRevisionId, 'revisionday' => intval(substr($this->getRevisionTimestamp(), 6, 2)), 'revisionday2' => substr($this->getRevisionTimestamp(), 6, 2), 'revisionmonth' => substr($this->getRevisionTimestamp(), 4, 2), 'revisionmonth1' => intval(substr($this->getRevisionTimestamp(), 4, 2)), 'revisionyear' => substr($this->getRevisionTimestamp(), 0, 4), 'revisiontimestamp' => $this->getRevisionTimestamp(), 'namespace' => str_replace('_', ' ', $wgContLang->getNsText($this->mTitle->getNamespace())), 'namespacee' => wfUrlencode($wgContLang->getNsText($this->mTitle->getNamespace())), 'talkspace' => $this->mTitle->canTalk() ? str_replace('_', ' ', $this->mTitle->getTalkNsText()) : '', 'talkspacee' => $this->mTitle->canTalk() ? wfUrlencode($this->mTitle->getTalkNsText()) : '', 'subjectspace' => $this->mTitle->getSubjectNsText(), 'subjectspacee' => wfUrlencode($this->mTitle->getSubjectNsText()), 'currentdayname' => $wgContLang->getWeekdayName(gmdate('w', $ts) + 1), 'currentyear' => $wgContLang->formatNum(gmdate('Y', $ts), true), 'currenttime' => $wgContLang->time(wfTimestamp(TS_MW, $ts), false, false), 'currenthour' => $wgContLang->formatNum(gmdate('H', $ts), true), 'currentweek' => $wgContLang->formatNum((int) gmdate('W', $ts)), 'currentdow' => $wgContLang->formatNum(gmdate('w', $ts)), 'localdayname' => $wgContLang->getWeekdayName($localDayOfWeek + 1), 'localyear' => $wgContLang->formatNum($localYear, true), 'localtime' => $wgContLang->time($localTimestamp, false, false), 'localhour' => $wgContLang->formatNum($localHour, true), 'localweek' => $wgContLang->formatNum((int) $localWeek), 'localdow' => $wgContLang->formatNum($localDayOfWeek), 'numberofarticles' => $wgContLang->formatNum(SiteStats::articles()), 'numberoffiles' => $wgContLang->formatNum(SiteStats::images()), 'numberofusers' => $wgContLang->formatNum(SiteStats::users()), 'numberofpages' => $wgContLang->formatNum(SiteStats::pages()), 'numberofadmins' => $wgContLang->formatNum(SiteStats::numberingroup('sysop')), 'numberofedits' => $wgContLang->formatNum(SiteStats::edits()), 'currenttimestamp' => wfTimestampNow(), 'localtimestamp' => $localTimestamp, 'currentversion' => SpecialVersion::getVersion(), 'sitename' => $wgSitename, 'server' => $wgServer, 'servername' => $wgServerName, 'scriptpath' => $wgScriptPath, 'directionmark' => $wgContLang->getDirMark(), 'contentlanguage' => $wgContLanguageCode, 'pageid' => $this->mTitle->getArticleID(), 'namespacenumber' => $this->mTitle->getNamespace(), 'numberofactiveusers' => $wgContLang->formatNum(SiteStats::activeUsers()), 'revisionuser' => $this->mRevision->getUserText(), 'stylepath' => $wgStylePath);
     // These are a bit more complicated...
     //case 'talkpagename':
     if ($this->mTitle->canTalk()) {
         $talkPage = $this->mTitle->getTalkPage();
         $talkpagename = wfEscapeWikiText($talkPage->getPrefixedText());
     } else {
         $talkpagename = '';
     }
     $w2lVars['talkpagename'] = $talkpagename;
     //case 'talkpagenamee':
     if ($this->mTitle->canTalk()) {
         $talkPage = $this->mTitle->getTalkPage();
         $talkpagenamee = $talkPage->getPrefixedUrl();
     } else {
         $talkpagenamee = '';
     }
     $w2lVars['talkpagenamee'] = $talkpagenamee;
     //case 'subjectpagename':
     $subjPage = $this->mTitle->getSubjectPage();
     $w2lVars['subjectpagename'] = wfEscapeWikiText($subjPage->getPrefixedText());
     $w2lVars['subjectpagenamee'] = $subjPage->getPrefixedUrl();
     wfRunHooks('w2lTemplateVars', array(&$this, &$w2lVars));
     $w2lVars = array_change_key_case($w2lVars, CASE_UPPER);
     return $w2lVars;
 }
 /**
  * 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 31484 2008-03-03 05:46:20Z brion $';
     $vers[] = ApiBase::getBaseVersion();
     $vers[] = ApiFormatBase::getBaseVersion();
     $vers[] = ApiQueryBase::getBaseVersion();
     $vers[] = ApiFormatFeedWrapper::getVersion();
     // not accessible with format=xxx
     return $vers;
 }
Example #20
0
 /**
  * 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;
 }
	/**
	 * Show the special page
	 *
	 * @param $par Mixed: parameter passed to the page or null
	 */
	function execute( $par ) {

		global $wgOut, $wgUser;
		global $wgOpenIDShowUrlOnUserPage;
		global $wgOpenIDTrustEmailAddress;
		global $wgOpenIDAllowExistingAccountSelection;
		global $wgOpenIDAllowNewAccountname;
		global $wgOpenIDUseEmailAsNickname;
		global $wgOpenIDProposeUsernameFromSREG;
		global $wgOpenIDAllowAutomaticUsername;
		global $wgOpenIDOnly;
		global $wgOpenIDClientOnly;
		global $wgOpenIDAllowServingOpenIDUserAccounts;
		global $wgOpenIDShowProviderIcons;

		if ( !$this->userCanExecute( $wgUser ) ) {
			$this->displayRestrictionError();
			return;
		}

		$totalUsers = SiteStats::users();
		$OpenIDdistinctUsers = $this->getOpenIDUsers( 'distinctusers' );
		$OpenIDUsers = $this->getOpenIDUsers();

		$this->setHeaders();
		$this->outputHeader();

		$wgOut->addWikiMsg( 'openid-dashboard-introduction', 'http://www.mediawiki.org/wiki/Extension:OpenID' );

		$wgOut->addHTML(
			Html::openElement( 'table', array( 'style' => 'width:50%;', 'class' => 'mw-openiddashboard-table wikitable' ) )
		);

		# Here we show some basic version infos. Retrieval of SVN revision number of OpenID appears to be too difficult
		$out  = $this->show( 'OpenID ' . wfMsg( 'version-software-version' ), MEDIAWIKI_OPENID_VERSION );
		$out .= $this->show( 'MediaWiki ' . wfMsg( 'version-software-version' ), SpecialVersion::getVersion() );
		$out .= $this->show( '$wgOpenIDOnly', $wgOpenIDOnly );
		$out .= $this->show( '$wgOpenIDClientOnly', $wgOpenIDClientOnly );
		$out .= $this->show( '$wgOpenIDAllowServingOpenIDUserAccounts', $wgOpenIDAllowServingOpenIDUserAccounts );
		$out .= $this->show( '$wgOpenIDTrustEmailAddress', $wgOpenIDTrustEmailAddress );
		$out .= $this->show( '$wgOpenIDAllowExistingAccountSelection', $wgOpenIDAllowExistingAccountSelection );
		$out .= $this->show( '$wgOpenIDAllowAutomaticUsername', $wgOpenIDAllowAutomaticUsername );
		$out .= $this->show( '$wgOpenIDAllowNewAccountname', $wgOpenIDAllowNewAccountname );
		$out .= $this->show( '$wgOpenIDUseEmailAsNickname', $wgOpenIDUseEmailAsNickname );
		$out .= $this->show( '$wgOpenIDProposeUsernameFromSREG', $wgOpenIDProposeUsernameFromSREG );
		$out .= $this->show( '$wgOpenIDShowUrlOnUserPage', $wgOpenIDShowUrlOnUserPage );
		$out .= $this->show( '$wgOpenIDShowProviderIcons', $wgOpenIDShowProviderIcons );
		$out .= $this->show( wfMsgExt( 'statistics-users', array( 'parseinline' ) ), $totalUsers );
		$out .= $this->show( wfMsg( 'openid-dashboard-number-openid-users' ), $OpenIDdistinctUsers  );
		$out .= $this->show( wfMsg( 'openid-dashboard-number-openids-in-database' ), $OpenIDUsers );
		$out .= $this->show( wfMsg( 'openid-dashboard-number-users-without-openid' ), $totalUsers - $OpenIDdistinctUsers );

		$wgOut->addHTML( $out . Html::closeElement( 'table' ) . "\n" );

	}
Example #22
0
 /**
  * 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;
 }
Example #23
0
 /**
  * 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 83302 2011-03-05 17:23:35Z btongminh $';
     $vers[] = ApiBase::getBaseVersion();
     $vers[] = ApiFormatBase::getBaseVersion();
     $vers[] = ApiQueryBase::getBaseVersion();
     return $vers;
 }
Example #24
0
 /**
  * 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;
             }
     }
 }
Example #25
0
 /**
  * Override the parent to generate help messages for all available modules.
  *
  * @return string
  */
 public function makeHelpMsg()
 {
     global $wgMemc, $wgAPICacheHelpTimeout;
     $this->setHelp();
     // Get help text from cache if present
     $key = wfMemcKey('apihelp', $this->getModuleName(), SpecialVersion::getVersion('nodb'));
     if ($wgAPICacheHelpTimeout > 0) {
         $cached = $wgMemc->get($key);
         if ($cached) {
             return $cached;
         }
     }
     $retval = $this->reallyMakeHelpMsg();
     if ($wgAPICacheHelpTimeout > 0) {
         $wgMemc->set($key, $retval, $wgAPICacheHelpTimeout);
     }
     return $retval;
 }
Example #26
0
 /**
  * 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;
 }
Example #27
0
 /**
  * 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;
 }
Example #28
0
 /**
  * Generate help for the specified modules
  *
  * Help is placed into the OutputPage object returned by
  * $context->getOutput().
  *
  * Recognized options include:
  *  - headerlevel: (int) Header tag level
  *  - nolead: (bool) Skip the inclusion of api-help-lead
  *  - noheader: (bool) Skip the inclusion of the top-level section headers
  *  - submodules: (bool) Include help for submodules of the current module
  *  - recursivesubmodules: (bool) Include help for submodules recursively
  *  - helptitle: (string) Title to link for additional modules' help. Should contain $1.
  *  - toc: (bool) Include a table of contents
  *
  * @param IContextSource $context
  * @param ApiBase[]|ApiBase $modules
  * @param array $options Formatting options (described above)
  * @return string
  */
 public static function getHelp(IContextSource $context, $modules, array $options)
 {
     global $wgContLang;
     if (!is_array($modules)) {
         $modules = array($modules);
     }
     $out = $context->getOutput();
     $out->addModuleStyles('mediawiki.hlist');
     $out->addModuleStyles('mediawiki.apihelp');
     if (!empty($options['toc'])) {
         $out->addModules('mediawiki.toc');
     }
     $out->setPageTitle($context->msg('api-help-title'));
     $cache = ObjectCache::getMainWANInstance();
     $cacheKey = null;
     if (count($modules) == 1 && $modules[0] instanceof ApiMain && $options['recursivesubmodules'] && $context->getLanguage() === $wgContLang) {
         $cacheHelpTimeout = $context->getConfig()->get('APICacheHelpTimeout');
         if ($cacheHelpTimeout > 0) {
             // Get help text from cache if present
             $cacheKey = wfMemcKey('apihelp', $modules[0]->getModulePath(), (int) (!empty($options['toc'])), str_replace(' ', '_', SpecialVersion::getVersion('nodb')));
             $cached = $cache->get($cacheKey);
             if ($cached) {
                 $out->addHTML($cached);
                 return;
             }
         }
     }
     if ($out->getHTML() !== '') {
         // Don't save to cache, there's someone else's content in the page
         // already
         $cacheKey = null;
     }
     $options['recursivesubmodules'] = !empty($options['recursivesubmodules']);
     $options['submodules'] = $options['recursivesubmodules'] || !empty($options['submodules']);
     // Prepend lead
     if (empty($options['nolead'])) {
         $msg = $context->msg('api-help-lead');
         if (!$msg->isDisabled()) {
             $out->addHTML($msg->parseAsBlock());
         }
     }
     $haveModules = array();
     $html = self::getHelpInternal($context, $modules, $options, $haveModules);
     if (!empty($options['toc']) && $haveModules) {
         $out->addHTML(Linker::generateTOC($haveModules, $context->getLanguage()));
     }
     $out->addHTML($html);
     $helptitle = isset($options['helptitle']) ? $options['helptitle'] : null;
     $html = self::fixHelpLinks($out->getHTML(), $helptitle, $haveModules);
     $out->clearHTML();
     $out->addHTML($html);
     if ($cacheKey !== null) {
         $cache->set($cacheKey, $out->getHTML(), $cacheHelpTimeout);
     }
 }
Example #29
0
 /**
  * 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,v 1.1.1.1 2009/11/04 00:04:42 vu Exp $';
     $vers[] = ApiBase::getBaseVersion();
     $vers[] = ApiFormatBase::getBaseVersion();
     $vers[] = ApiQueryBase::getBaseVersion();
     $vers[] = ApiFormatFeedWrapper::getVersion();
     // not accessible with format=xxx
     return $vers;
 }