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


PHP ResourceLoader::inDebugMode方法代码示例

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


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

示例1: getScript

 public function getScript(ResourceLoaderContext $context)
 {
     // Messages
     $msgInfo = $this->getMessageInfo();
     $parsedMessages = array();
     $messages = array();
     foreach ($msgInfo['args'] as $msgKey => $msgArgs) {
         $parsedMessages[$msgKey] = call_user_func_array('wfMessage', $msgArgs)->inLanguage($context->getLanguage())->parse();
     }
     foreach ($msgInfo['vals'] as $msgKey => $msgVal) {
         $messages[$msgKey] = $msgVal;
     }
     return 've.init.platform.addParsedMessages(' . FormatJson::encode($parsedMessages, ResourceLoader::inDebugMode()) . ');' . 've.init.platform.addMessages(' . FormatJson::encode($messages, ResourceLoader::inDebugMode()) . ');';
 }
开发者ID:sammykumar,项目名称:TheVRForums,代码行数:14,代码来源:VisualEditorDataModule.php

示例2: getScript

 public function getScript(ResourceLoaderContext $context)
 {
     // Messages
     $msgInfo = $this->getMessageInfo();
     $parsedMessages = array();
     $messages = array();
     foreach ($msgInfo['args'] as $msgKey => $msgArgs) {
         $parsedMessages[$msgKey] = call_user_func_array('wfMessage', $msgArgs)->inLanguage($context->getLanguage())->parse();
     }
     foreach ($msgInfo['vals'] as $msgKey => $msgVal) {
         $messages[$msgKey] = $msgVal;
     }
     // Version information
     $language = Language::factory($context->getLanguage());
     $hash = $this->getGitHeadHash();
     $id = $hash ? substr($this->getGitHeadHash(), 0, 7) : false;
     $url = $this->gitInfo->getHeadViewUrl();
     $date = $this->gitInfo->getHeadCommitDate();
     $dateString = $date ? $language->timeanddate($date, true) : '';
     return 've.init.platform.addParsedMessages(' . FormatJson::encode($parsedMessages, ResourceLoader::inDebugMode()) . ');' . 've.init.platform.addMessages(' . FormatJson::encode($messages, ResourceLoader::inDebugMode()) . ');' . 've.version = ' . FormatJson::encode(array('id' => $id, 'url' => $url, 'timestamp' => $date, 'dateString' => $dateString), ResourceLoader::inDebugMode()) . ';';
 }
开发者ID:eliagbayani,项目名称:eoearth,代码行数:21,代码来源:VisualEditorDataModule.php

示例3: getScript

 /**
  * @param ResourceLoaderContext $context
  * @return string
  */
 public function getScript(ResourceLoaderContext $context)
 {
     return Xml::encodeJsCall('mw.user.options.set', [$context->getUserObj()->getOptions(User::GETOPTIONS_EXCLUDE_DEFAULTS)], ResourceLoader::inDebugMode());
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:8,代码来源:ResourceLoaderUserOptionsModule.php

示例4: getScript

 /**
  * @param ResourceLoaderContext $context
  * @return string JavaScript code
  */
 public function getScript(ResourceLoaderContext $context)
 {
     return Xml::encodeJsCall('mw.language.setData', array($context->getLanguage(), $this->getData($context)), ResourceLoader::inDebugMode());
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:8,代码来源:ResourceLoaderLanguageDataModule.php

示例5: makeConfigSetScript

 /**
  * Returns JS code which will set the MediaWiki configuration array to
  * the given value.
  *
  * @param array $configuration List of configuration values keyed by variable name
  * @return string
  */
 public static function makeConfigSetScript(array $configuration)
 {
     return Xml::encodeJsCall('mw.config.set', [$configuration], ResourceLoader::inDebugMode());
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:11,代码来源:ResourceLoader.php

示例6: getScript

 /**
  * @param ResourceLoaderContext $context
  * @return string JavaScript code
  */
 public function getScript(ResourceLoaderContext $context)
 {
     return Xml::encodeJsCall('mw.language.setSpecialCharacters', array($this->getData()), ResourceLoader::inDebugMode());
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:8,代码来源:ResourceLoaderSpecialCharacterDataModule.php

示例7: makeConfigSetScript

 /**
  * Returns JS code which will set the MediaWiki configuration array to
  * the given value.
  *
  * @param array $configuration List of configuration values keyed by variable name
  * @return string
  */
 public static function makeConfigSetScript(array $configuration)
 {
     return Xml::encodeJsCall('mw.config.set', array($configuration), ResourceLoader::inDebugMode()) . ResourceLoader::FILTER_NOMIN;
 }
开发者ID:agothro,项目名称:mediawiki,代码行数:11,代码来源:ResourceLoader.php

示例8: getScript

 /**
  * @param ResourceLoaderContext $context
  * @return string
  */
 public function getScript(ResourceLoaderContext $context)
 {
     global $IP;
     if ($context->getOnly() !== 'scripts') {
         return '/* Requires only=script */';
     }
     $out = file_get_contents("{$IP}/resources/src/startup.js");
     $pairs = array_map(function ($value) {
         $value = FormatJson::encode($value, ResourceLoader::inDebugMode(), FormatJson::ALL_OK);
         // Fix indentation
         $value = str_replace("\n", "\n\t", $value);
         return $value;
     }, ['$VARS.wgLegacyJavaScriptGlobals' => $this->getConfig()->get('LegacyJavaScriptGlobals'), '$VARS.configuration' => $this->getConfigSettings($context), '$VARS.baseModulesUri' => self::getStartupModulesUrl($context)]);
     $pairs['$CODE.registrations()'] = str_replace("\n", "\n\t", trim($this->getModuleRegistrations($context)));
     return strtr($out, $pairs);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:20,代码来源:ResourceLoaderStartUpModule.php

示例9: getScript

 /**
  * @param ResourceLoaderContext $context
  * @return string
  */
 public function getScript(ResourceLoaderContext $context)
 {
     global $wgUser;
     return Xml::encodeJsCall('mw.user.options.set', array($wgUser->getOptions()), ResourceLoader::inDebugMode());
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:9,代码来源:ResourceLoaderUserOptionsModule.php

示例10: getRlClientContext

 private function getRlClientContext()
 {
     if (!$this->rlClientContext) {
         $query = ResourceLoader::makeLoaderQuery([], $this->getLanguage()->getCode(), $this->getSkin()->getSkinName(), $this->getUser()->isLoggedIn() ? $this->getUser()->getName() : null, null, ResourceLoader::inDebugMode(), null, $this->isPrintable(), $this->getRequest()->getBool('handheld'));
         $this->rlClientContext = new ResourceLoaderContext($this->getResourceLoader(), new FauxRequest($query));
     }
     return $this->rlClientContext;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:8,代码来源:OutputPage.php

示例11: makeConfigSetScript

 /**
  * Returns JS code which will set the MediaWiki configuration array to
  * the given value.
  *
  * @param array $configuration List of configuration values keyed by variable name
  * @param bool $pretty Pretty-print with extra whitespace
  * @return string
  */
 public static function makeConfigSetScript(array $configuration, $pretty = null)
 {
     return Xml::encodeJsCall('mw.config.set', [$configuration], $pretty === null ? ResourceLoader::inDebugMode() : $pretty);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:12,代码来源:ResourceLoader.php

示例12: makeResourceLoaderLink

 /**
  * TODO: Document
  * @param $modules Array/string with the module name(s)
  * @param $only String ResourceLoaderModule TYPE_ class constant
  * @param $useESI boolean
  * @param $extraQuery Array with extra query parameters to add to each request. array( param => value )
  * @param $loadCall boolean If true, output an (asynchronous) mw.loader.load() call rather than a <script src="..."> tag
  * @return string html <script> and <style> tags
  */
 protected function makeResourceLoaderLink($modules, $only, $useESI = false, array $extraQuery = array(), $loadCall = false)
 {
     global $wgResourceLoaderUseESI;
     if (!count($modules)) {
         return '';
     }
     if (count($modules) > 1) {
         // Remove duplicate module requests
         $modules = array_unique((array) $modules);
         // Sort module names so requests are more uniform
         sort($modules);
         if (ResourceLoader::inDebugMode()) {
             // Recursively call us for every item
             $links = '';
             foreach ($modules as $name) {
                 $links .= $this->makeResourceLoaderLink($name, $only, $useESI);
             }
             return $links;
         }
     }
     // Create keyed-by-group list of module objects from modules list
     $groups = array();
     $resourceLoader = $this->getResourceLoader();
     foreach ((array) $modules as $name) {
         $module = $resourceLoader->getModule($name);
         # Check that we're allowed to include this module on this page
         if (!$module || $module->getOrigin() > $this->getAllowedModules(ResourceLoaderModule::TYPE_SCRIPTS) && $only == ResourceLoaderModule::TYPE_SCRIPTS || $module->getOrigin() > $this->getAllowedModules(ResourceLoaderModule::TYPE_STYLES) && $only == ResourceLoaderModule::TYPE_STYLES) {
             continue;
         }
         $group = $module->getGroup();
         if (!isset($groups[$group])) {
             $groups[$group] = array();
         }
         $groups[$group][$name] = $module;
     }
     $links = '';
     foreach ($groups as $group => $modules) {
         // Special handling for user-specific groups
         $user = null;
         if (($group === 'user' || $group === 'private') && $this->getUser()->isLoggedIn()) {
             $user = $this->getUser()->getName();
         }
         // Create a fake request based on the one we are about to make so modules return
         // correct timestamp and emptiness data
         $query = ResourceLoader::makeLoaderQuery(array(), $this->getLanguage()->getCode(), $this->getSkin()->getSkinName(), $user, null, ResourceLoader::inDebugMode(), $only === ResourceLoaderModule::TYPE_COMBINED ? null : $only, $this->isPrintable(), $this->getRequest()->getBool('handheld'), $extraQuery);
         $context = new ResourceLoaderContext($resourceLoader, new FauxRequest($query));
         // Drop modules that know they're empty
         foreach ($modules as $key => $module) {
             if ($module->isKnownEmpty($context)) {
                 unset($modules[$key]);
             }
         }
         // If there are no modules left, skip this group
         if ($modules === array()) {
             continue;
         }
         // Inline private modules. These can't be loaded through load.php for security
         // reasons, see bug 34907. Note that these modules should be loaded from
         // getHeadScripts() before the first loader call. Otherwise other modules can't
         // properly use them as dependencies (bug 30914)
         if ($group === 'private') {
             if ($only == ResourceLoaderModule::TYPE_STYLES) {
                 $links .= Html::inlineStyle($resourceLoader->makeModuleResponse($context, $modules));
             } else {
                 $links .= Html::inlineScript(ResourceLoader::makeLoaderConditionalScript($resourceLoader->makeModuleResponse($context, $modules)));
             }
             $links .= "\n";
             continue;
         }
         // Special handling for the user group; because users might change their stuff
         // on-wiki like user pages, or user preferences; we need to find the highest
         // timestamp of these user-changable modules so we can ensure cache misses on change
         // This should NOT be done for the site group (bug 27564) because anons get that too
         // and we shouldn't be putting timestamps in Squid-cached HTML
         $version = null;
         if ($group === 'user') {
             // Get the maximum timestamp
             $timestamp = 1;
             foreach ($modules as $module) {
                 $timestamp = max($timestamp, $module->getModifiedTime($context));
             }
             // Add a version parameter so cache will break when things change
             $version = wfTimestamp(TS_ISO_8601_BASIC, $timestamp);
         }
         $url = ResourceLoader::makeLoaderURL(array_keys($modules), $this->getLanguage()->getCode(), $this->getSkin()->getSkinName(), $user, $version, ResourceLoader::inDebugMode(), $only === ResourceLoaderModule::TYPE_COMBINED ? null : $only, $this->isPrintable(), $this->getRequest()->getBool('handheld'), $extraQuery);
         if ($useESI && $wgResourceLoaderUseESI) {
             $esi = Xml::element('esi:include', array('src' => $url));
             if ($only == ResourceLoaderModule::TYPE_STYLES) {
                 $link = Html::inlineStyle($esi);
             } else {
                 $link = Html::inlineScript($esi);
//.........这里部分代码省略.........
开发者ID:schwarer2006,项目名称:wikia,代码行数:101,代码来源:OutputPage.php

示例13: getScript

 /**
  * @param ResourceLoaderContext $context
  * @return string
  */
 public function getScript(ResourceLoaderContext $context)
 {
     global $IP;
     $out = file_get_contents("{$IP}/resources/src/startup.js");
     if ($context->getOnly() === 'scripts') {
         // Startup function
         $configuration = $this->getConfigSettings($context);
         $registrations = $this->getModuleRegistrations($context);
         // Fix indentation
         $registrations = str_replace("\n", "\n\t", trim($registrations));
         $mwMapJsCall = Xml::encodeJsCall('mw.Map', array($this->getConfig()->get('LegacyJavaScriptGlobals')));
         $mwConfigSetJsCall = Xml::encodeJsCall('mw.config.set', array($configuration), ResourceLoader::inDebugMode());
         $out .= "var startUp = function () {\n" . "\tmw.config = new " . $mwMapJsCall . "\n" . "\t{$registrations}\n" . "\t" . $mwConfigSetJsCall . "};\n";
         // Conditional script injection
         $scriptTag = Html::linkedScript(self::getStartupModulesUrl($context));
         $out .= "if ( isCompatible() ) {\n" . "\t" . Xml::encodeJsCall('document.write', array($scriptTag)) . "\n}";
     }
     return $out;
 }
开发者ID:D66Ha,项目名称:mediawiki,代码行数:23,代码来源:ResourceLoaderStartUpModule.php

示例14: getModuleRegistrations

 /**
  * Get registration code for all modules.
  *
  * @param ResourceLoaderContext $context
  * @return string JavaScript code for registering all modules with the client loader
  */
 public function getModuleRegistrations(ResourceLoaderContext $context)
 {
     wfProfileIn(__METHOD__);
     $resourceLoader = $context->getResourceLoader();
     $target = $context->getRequest()->getVal('target', 'desktop');
     $out = '';
     $registryData = array();
     // Get registry data
     foreach ($resourceLoader->getModuleNames() as $name) {
         $module = $resourceLoader->getModule($name);
         $moduleTargets = $module->getTargets();
         if (!in_array($target, $moduleTargets)) {
             continue;
         }
         if ($module->isRaw()) {
             // Don't register "raw" modules (like 'jquery' and 'mediawiki') client-side because
             // depending on them is illegal anyway and would only lead to them being reloaded
             // causing any state to be lost (like jQuery plugins, mw.config etc.)
             continue;
         }
         // getModifiedTime() is supposed to return a UNIX timestamp, but it doesn't always
         // seem to do that, and custom implementations might forget. Coerce it to TS_UNIX
         $moduleMtime = wfTimestamp(TS_UNIX, $module->getModifiedTime($context));
         $mtime = max($moduleMtime, wfTimestamp(TS_UNIX, $this->getConfig()->get('CacheEpoch')));
         // FIXME: Convert to numbers, wfTimestamp always gives us stings, even for TS_UNIX
         $skipFunction = $module->getSkipFunction();
         if ($skipFunction !== null && !ResourceLoader::inDebugMode()) {
             $skipFunction = $resourceLoader->filter('minify-js', $skipFunction, false);
         }
         $registryData[$name] = array('version' => $mtime, 'dependencies' => $module->getDependencies(), 'group' => $module->getGroup(), 'source' => $module->getSource(), 'loader' => $module->getLoaderScript(), 'skip' => $skipFunction);
     }
     self::compileUnresolvedDependencies($registryData);
     // Register sources
     $out .= ResourceLoader::makeLoaderSourcesScript($resourceLoader->getSources());
     // Concatenate module loader scripts and figure out the different call
     // signatures for mw.loader.register
     $registrations = array();
     foreach ($registryData as $name => $data) {
         if ($data['loader'] !== false) {
             $out .= ResourceLoader::makeCustomLoaderScript($name, wfTimestamp(TS_ISO_8601_BASIC, $data['version']), $data['dependencies'], $data['group'], $data['source'], $data['loader']);
             continue;
         }
         if (!count($data['dependencies']) && $data['group'] === null && $data['source'] === 'local' && $data['skip'] === null) {
             // Modules with no dependencies, group, foreign source or skip function;
             // call mw.loader.register(name, timestamp)
             $registrations[] = array($name, $data['version']);
         } elseif ($data['group'] === null && $data['source'] === 'local' && $data['skip'] === null) {
             // Modules with dependencies but no group, foreign source or skip function;
             // call mw.loader.register(name, timestamp, dependencies)
             $registrations[] = array($name, $data['version'], $data['dependencies']);
         } elseif ($data['source'] === 'local' && $data['skip'] === null) {
             // Modules with a group but no foreign source or skip function;
             // call mw.loader.register(name, timestamp, dependencies, group)
             $registrations[] = array($name, $data['version'], $data['dependencies'], $data['group']);
         } elseif ($data['skip'] === null) {
             // Modules with a foreign source but no skip function;
             // call mw.loader.register(name, timestamp, dependencies, group, source)
             $registrations[] = array($name, $data['version'], $data['dependencies'], $data['group'], $data['source']);
         } else {
             // Modules with a skip function;
             // call mw.loader.register(name, timestamp, dependencies, group, source, skip)
             $registrations[] = array($name, $data['version'], $data['dependencies'], $data['group'], $data['source'], $data['skip']);
         }
     }
     // Register modules
     $out .= ResourceLoader::makeLoaderRegisterScript($registrations);
     wfProfileOut(__METHOD__);
     return $out;
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:75,代码来源:ResourceLoaderStartUpModule.php

示例15: getScript

 /**
  * Generate the JavaScript content of this module.
  *
  * Add FILTER_NOMIN annotation to prevent needless minification and caching (T84960).
  *
  * @param ResourceLoaderContext $context
  * @return string
  */
 public function getScript(ResourceLoaderContext $context)
 {
     return Xml::encodeJsCall('mw.user.tokens.set', [$this->contextUserTokens($context)], ResourceLoader::inDebugMode()) . ResourceLoader::FILTER_NOMIN;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:12,代码来源:ResourceLoaderUserTokensModule.php


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