当前位置: 首页>>代码示例>>PHP>>正文


PHP RequestContext::getLanguage方法代码示例

本文整理汇总了PHP中RequestContext::getLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestContext::getLanguage方法的具体用法?PHP RequestContext::getLanguage怎么用?PHP RequestContext::getLanguage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RequestContext的用法示例。


在下文中一共展示了RequestContext::getLanguage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getParsedConfig

 /**
  * Returns all config parameters, after parsing the wikitext based ones
  *
  * @since 1.3
  *
  * @return array
  */
 public function getParsedConfig($lang = null)
 {
     global $wgMemc;
     if ($lang === null) {
         $lang = $this->context->getLanguage();
     }
     // We check if the parsed config for this campaign is cached. If it is available in cache,
     // we then check to make sure that it is the latest version - by verifying that its
     // timestamp is greater than or equal to the timestamp of the last time an invalidate was
     // issued.
     $memKey = wfMemcKey('uploadwizard', 'campaign', $this->getName(), 'parsed-config', $lang->getCode());
     $memValue = $wgMemc->get($memKey);
     if ($memValue !== false) {
         $invalidateTimestamp = $wgMemc->get($this->makeInvalidateTimestampKey());
         if ($invalidateTimestamp === false || $memValue['timestamp'] >= $invalidateTimestamp) {
             $this->parsedConfig = $memValue['config'];
         }
     }
     wfProfileIn(__METHOD__);
     if ($this->parsedConfig === null) {
         $parsedConfig = array();
         foreach ($this->config as $key => $value) {
             switch ($key) {
                 case "title":
                 case "description":
                     $parsedConfig[$key] = $this->parseValue($value, $lang);
                     break;
                 case "display":
                     $parsedConfig['display'] = $this->parseArrayValues($value, $lang);
                     break;
                 case "fields":
                     $parsedConfig['fields'] = array();
                     foreach ($value as $field) {
                         $parsedConfig['fields'][] = $this->parseArrayValues($field, $lang, array('label'));
                     }
                     break;
                 default:
                     $parsedConfig[$key] = $value;
                     break;
             }
         }
         $this->parsedConfig = $parsedConfig;
         $wgMemc->set($memKey, array('timestamp' => time(), 'config' => $parsedConfig));
     }
     wfProfileOut(__METHOD__);
     return $this->parsedConfig;
 }
开发者ID:DanielDobre,项目名称:fossology,代码行数:54,代码来源:UploadWizardCampaign.php

示例2: setUp

 function setUp()
 {
     global $wgParser, $wgParserConf, $IP, $messageMemc, $wgMemc, $wgUser, $wgLang, $wgOut, $wgRequest, $wgStyleDirectory, $wgEnableParserCache, $wgNamespaceAliases, $wgNamespaceProtection, $parserMemc;
     $tmpGlobals = array();
     $tmpGlobals['wgScript'] = '/index.php';
     $tmpGlobals['wgScriptPath'] = '/';
     $tmpGlobals['wgArticlePath'] = '/wiki/$1';
     $tmpGlobals['wgStyleSheetPath'] = '/skins';
     $tmpGlobals['wgStylePath'] = '/skins';
     $tmpGlobals['wgThumbnailScriptPath'] = false;
     $tmpGlobals['wgLocalFileRepo'] = array('class' => 'LocalRepo', 'name' => 'local', 'url' => 'http://example.com/images', 'hashLevels' => 2, 'transformVia404' => false, 'backend' => new FSFileBackend(array('name' => 'local-backend', 'lockManager' => 'fsLockManager', 'containerPaths' => array('local-public' => wfTempDir() . '/test-repo/public', 'local-thumb' => wfTempDir() . '/test-repo/thumb', 'local-temp' => wfTempDir() . '/test-repo/temp', 'local-deleted' => wfTempDir() . '/test-repo/delete'))));
     foreach ($tmpGlobals as $var => $val) {
         if (array_key_exists($var, $GLOBALS)) {
             $this->savedGlobals[$var] = $GLOBALS[$var];
         }
         $GLOBALS[$var] = $val;
     }
     $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
     $wgNamespaceAliases['Image'] = NS_FILE;
     $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK;
     $wgEnableParserCache = false;
     DeferredUpdates::clearPendingUpdates();
     $wgMemc = wfGetMainCache();
     $messageMemc = wfGetMessageCacheStorage();
     $parserMemc = wfGetParserCacheStorage();
     // $wgContLang = new StubContLang;
     $wgUser = new User();
     $context = new RequestContext();
     $wgLang = $context->getLanguage();
     $wgOut = $context->getOutput();
     $wgParser = new StubObject('wgParser', $wgParserConf['class'], array($wgParserConf));
     $wgRequest = $context->getRequest();
     if ($wgStyleDirectory === false) {
         $wgStyleDirectory = "{$IP}/skins";
     }
     RepoGroup::destroySingleton();
     FileBackendGroup::destroySingleton();
 }
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:38,代码来源:UploadFromUrlTestSuite.php

示例3: setupGlobals

 /**
  * Set up the global variables for a consistent environment for each test.
  * Ideally this should replace the global configuration entirely.
  */
 protected function setupGlobals($opts = '', $config = '')
 {
     global $wgFileBackends;
     # Find out values for some special options.
     $lang = self::getOptionValue('language', $opts, 'en');
     $variant = self::getOptionValue('variant', $opts, false);
     $maxtoclevel = self::getOptionValue('wgMaxTocLevel', $opts, 999);
     $linkHolderBatchSize = self::getOptionValue('wgLinkHolderBatchSize', $opts, 1000);
     $uploadDir = $this->getUploadDir();
     if ($this->getCliArg('use-filebackend=')) {
         if (self::$backendToUse) {
             $backend = self::$backendToUse;
         } else {
             $name = $this->getCliArg('use-filebackend=');
             $useConfig = array();
             foreach ($wgFileBackends as $conf) {
                 if ($conf['name'] == $name) {
                     $useConfig = $conf;
                 }
             }
             $useConfig['name'] = 'local-backend';
             // swap name
             $class = $conf['class'];
             self::$backendToUse = new $class($useConfig);
             $backend = self::$backendToUse;
         }
     } else {
         $backend = new FSFileBackend(array('name' => 'local-backend', 'lockManager' => 'nullLockManager', 'containerPaths' => array('local-public' => "{$uploadDir}", 'local-thumb' => "{$uploadDir}/thumb")));
     }
     $settings = array('wgServer' => 'http://Britney-Spears', 'wgScript' => '/index.php', 'wgScriptPath' => '/', 'wgArticlePath' => '/wiki/$1', 'wgExtensionAssetsPath' => '/extensions', 'wgActionPaths' => array(), 'wgLocalFileRepo' => array('class' => 'LocalRepo', 'name' => 'local', 'url' => 'http://example.com/images', 'hashLevels' => 2, 'transformVia404' => false, 'backend' => $backend), 'wgEnableUploads' => self::getOptionValue('wgEnableUploads', $opts, true), 'wgStylePath' => '/skins', 'wgStyleSheetPath' => '/skins', 'wgSitename' => 'MediaWiki', 'wgLanguageCode' => $lang, 'wgDBprefix' => $this->db->getType() != 'oracle' ? 'unittest_' : 'ut_', 'wgRawHtml' => isset($opts['rawhtml']), 'wgLang' => null, 'wgContLang' => null, 'wgNamespacesWithSubpages' => array(0 => isset($opts['subpage'])), 'wgMaxTocLevel' => $maxtoclevel, 'wgCapitalLinks' => true, 'wgNoFollowLinks' => true, 'wgNoFollowDomainExceptions' => array(), 'wgThumbnailScriptPath' => false, 'wgUseImageResize' => false, 'wgUseTeX' => isset($opts['math']), 'wgMathDirectory' => $uploadDir . '/math', 'wgLocaltimezone' => 'UTC', 'wgAllowExternalImages' => true, 'wgUseTidy' => false, 'wgDefaultLanguageVariant' => $variant, 'wgVariantArticlePath' => false, 'wgGroupPermissions' => array('*' => array('createaccount' => true, 'read' => true, 'edit' => true, 'createpage' => true, 'createtalk' => true)), 'wgNamespaceProtection' => array(NS_MEDIAWIKI => 'editinterface'), 'wgDefaultExternalStore' => array(), 'wgForeignFileRepos' => array(), 'wgLinkHolderBatchSize' => $linkHolderBatchSize, 'wgExperimentalHtmlIds' => false, 'wgExternalLinkTarget' => false, 'wgAlwaysUseTidy' => false, 'wgHtml5' => true, 'wgCleanupPresentationalAttributes' => true, 'wgWellFormedXml' => true, 'wgAllowMicrodataAttributes' => true, 'wgAdaptiveMessageCache' => true, 'wgUseDatabaseMessages' => true);
     if ($config) {
         $configLines = explode("\n", $config);
         foreach ($configLines as $line) {
             list($var, $value) = explode('=', $line, 2);
             $settings[$var] = eval("return {$value};");
             //???
         }
     }
     $this->savedGlobals = array();
     foreach ($settings as $var => $val) {
         if (array_key_exists($var, $GLOBALS)) {
             $this->savedGlobals[$var] = $GLOBALS[$var];
         }
         $GLOBALS[$var] = $val;
     }
     $langObj = Language::factory($lang);
     $GLOBALS['wgContLang'] = $langObj;
     $context = new RequestContext();
     $GLOBALS['wgLang'] = $context->getLanguage();
     $GLOBALS['wgMemc'] = new EmptyBagOStuff();
     $GLOBALS['wgOut'] = $context->getOutput();
     $GLOBALS['wgUser'] = $context->getUser();
     global $wgHooks;
     $wgHooks['ParserTestParser'][] = 'ParserTestParserHook::setup';
     $wgHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp';
     MagicWord::clearCache();
     RepoGroup::destroySingleton();
     FileBackendGroup::destroySingleton();
     # Create dummy files in storage
     $this->setupUploads();
     # Publish the articles after we have the final language set
     $this->publishTestArticles();
     # The entries saved into RepoGroup cache with previous globals will be wrong.
     RepoGroup::destroySingleton();
     FileBackendGroup::destroySingleton();
     MessageCache::singleton()->destroyInstance();
     return $context;
 }
开发者ID:laiello,项目名称:media-wiki-law,代码行数:72,代码来源:NewParserTest.php

示例4: getParsedConfig

 /**
  * Returns all config parameters, after parsing the wikitext based ones
  *
  * @since 1.3
  *
  * @return array
  */
 public function getParsedConfig($lang = null)
 {
     if ($lang === null) {
         $lang = $this->context->getLanguage();
     }
     // We check if the parsed config for this campaign is cached. If it is available in cache,
     // we then check to make sure that it is the latest version - by verifying that its
     // timestamp is greater than or equal to the timestamp of the last time an invalidate was
     // issued.
     $cache = ObjectCache::getMainWANInstance();
     $memKey = wfMemcKey('uploadwizard', 'campaign', $this->getName(), 'parsed-config', $lang->getCode());
     $depKeys = array($this->makeInvalidateTimestampKey());
     $curTTL = null;
     $memValue = $cache->get($memKey, $curTTL, $depKeys);
     if (is_array($memValue) && $curTTL > 0) {
         $this->parsedConfig = $memValue['config'];
     }
     if ($this->parsedConfig === null) {
         $parsedConfig = array();
         foreach ($this->config as $key => $value) {
             switch ($key) {
                 case "title":
                 case "description":
                     $parsedConfig[$key] = $this->parseValue($value, $lang);
                     break;
                 case "display":
                     foreach ($value as $option => $optionValue) {
                         if (is_array($optionValue)) {
                             $parsedConfig['display'][$option] = $this->parseArrayValues($optionValue, $lang, array('label'));
                         } else {
                             $parsedConfig['display'][$option] = $this->parseValue($optionValue, $lang);
                         }
                     }
                     break;
                 case "fields":
                     $parsedConfig['fields'] = array();
                     foreach ($value as $field) {
                         $parsedConfig['fields'][] = $this->parseArrayValues($field, $lang, array('label', 'options'));
                     }
                     break;
                 case "whileActive":
                 case "afterActive":
                 case "beforeActive":
                     if (array_key_exists('display', $value)) {
                         $value['display'] = $this->parseArrayValues($value['display'], $lang);
                     }
                     $parsedConfig[$key] = $value;
                     break;
                 default:
                     $parsedConfig[$key] = $value;
                     break;
             }
         }
         $this->parsedConfig = $parsedConfig;
         $cache->set($memKey, array('timestamp' => time(), 'config' => $parsedConfig));
     }
     $uwDefaults = UploadWizardConfig::getSetting('defaults');
     if (array_key_exists('objref', $uwDefaults)) {
         $this->applyObjectReferenceToButtons($uwDefaults['objref']);
     }
     $this->modifyIfNecessary();
     return $this->parsedConfig;
 }
开发者ID:robksawyer,项目名称:lathe.tools,代码行数:70,代码来源:UploadWizardCampaign.php


注:本文中的RequestContext::getLanguage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。