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


PHP ResourceLoaderContext::getDebug方法代码示例

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


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

示例1: getConfig

 /**
  * @param ResourceLoaderContext $context
  * @return array
  */
 protected function getConfig($context)
 {
     $hash = $context->getHash();
     if (isset($this->configVars[$hash])) {
         return $this->configVars[$hash];
     }
     global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension, $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgVariantArticlePath, $wgActionPaths, $wgVersion, $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgCookiePrefix, $wgResourceLoaderMaxQueryLength, $wgResourceLoaderStorageEnabled, $wgResourceLoaderStorageVersion, $wgSearchType;
     $mainPage = Title::newMainPage();
     /**
      * Namespace related preparation
      * - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
      * - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
      */
     $namespaceIds = $wgContLang->getNamespaceIds();
     $caseSensitiveNamespaces = array();
     foreach (MWNamespace::getCanonicalNamespaces() as $index => $name) {
         $namespaceIds[$wgContLang->lc($name)] = $index;
         if (!MWNamespace::isCapitalized($index)) {
             $caseSensitiveNamespaces[] = $index;
         }
     }
     // Build list of variables
     $vars = array('wgLoadScript' => $wgLoadScript, 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $wgStylePath, 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScriptExtension' => $wgScriptExtension, 'wgScript' => $wgScript, 'wgSearchType' => $wgSearchType, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => (object) $wgActionPaths, 'wgServer' => $wgServer, 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgVersion' => $wgVersion, 'wgEnableAPI' => $wgEnableAPI, 'wgEnableWriteAPI' => $wgEnableWriteAPI, 'wgMainPageTitle' => $mainPage->getPrefixedText(), 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgContentNamespaces' => MWNamespace::getContentNamespaces(), 'wgSiteName' => $wgSitename, 'wgFileExtensions' => array_values(array_unique($wgFileExtensions)), 'wgDBname' => $wgDBname, 'wgFileCanRotate' => BitmapHandler::canRotate(), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $wgExtensionAssetsPath, 'wgCookiePrefix' => $wgCookiePrefix, 'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength, 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass(Title::legalChars()), 'wgResourceLoaderStorageVersion' => $wgResourceLoaderStorageVersion, 'wgResourceLoaderStorageEnabled' => $wgResourceLoaderStorageEnabled);
     wfRunHooks('ResourceLoaderGetConfigVars', array(&$vars));
     $this->configVars[$hash] = $vars;
     return $this->configVars[$hash];
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:31,代码来源:ResourceLoaderStartUpModule.php

示例2: getDebug

 public function getDebug()
 {
     if ($this->debug === self::INHERIT_VALUE) {
         return $this->context->getDebug();
     }
     return $this->debug;
 }
开发者ID:mb720,项目名称:mediawiki,代码行数:7,代码来源:DerivativeResourceLoaderContext.php

示例3: getConfigSettings

 /**
  * @param ResourceLoaderContext $context
  * @return array
  */
 protected function getConfigSettings($context)
 {
     $hash = $context->getHash();
     if (isset($this->configVars[$hash])) {
         return $this->configVars[$hash];
     }
     global $wgContLang;
     $mainPage = Title::newMainPage();
     /**
      * Namespace related preparation
      * - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
      * - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
      */
     $namespaceIds = $wgContLang->getNamespaceIds();
     $caseSensitiveNamespaces = array();
     foreach (MWNamespace::getCanonicalNamespaces() as $index => $name) {
         $namespaceIds[$wgContLang->lc($name)] = $index;
         if (!MWNamespace::isCapitalized($index)) {
             $caseSensitiveNamespaces[] = $index;
         }
     }
     $conf = $this->getConfig();
     // Build list of variables
     $vars = array('wgLoadScript' => wfScript('load'), 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $conf->get('StylePath'), 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $conf->get('ArticlePath'), 'wgScriptPath' => $conf->get('ScriptPath'), 'wgScriptExtension' => $conf->get('ScriptExtension'), 'wgScript' => wfScript(), 'wgSearchType' => $conf->get('SearchType'), 'wgVariantArticlePath' => $conf->get('VariantArticlePath'), 'wgActionPaths' => (object) $conf->get('ActionPaths'), 'wgServer' => $conf->get('Server'), 'wgServerName' => $conf->get('ServerName'), 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgTranslateNumerals' => $conf->get('TranslateNumerals'), 'wgVersion' => $conf->get('Version'), 'wgEnableAPI' => $conf->get('EnableAPI'), 'wgEnableWriteAPI' => $conf->get('EnableWriteAPI'), 'wgMainPageTitle' => $mainPage->getPrefixedText(), 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgContentNamespaces' => MWNamespace::getContentNamespaces(), 'wgSiteName' => $conf->get('Sitename'), 'wgDBname' => $conf->get('DBname'), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $conf->get('ExtensionAssetsPath'), 'wgCookiePrefix' => $conf->get('CookiePrefix'), 'wgCookieDomain' => $conf->get('CookieDomain'), 'wgCookiePath' => $conf->get('CookiePath'), 'wgCookieExpiration' => $conf->get('CookieExpiration'), 'wgResourceLoaderMaxQueryLength' => $conf->get('ResourceLoaderMaxQueryLength'), 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass(Title::legalChars()), 'wgResourceLoaderStorageVersion' => $conf->get('ResourceLoaderStorageVersion'), 'wgResourceLoaderStorageEnabled' => $conf->get('ResourceLoaderStorageEnabled'));
     Hooks::run('ResourceLoaderGetConfigVars', array(&$vars));
     $this->configVars[$hash] = $vars;
     return $this->configVars[$hash];
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:32,代码来源:ResourceLoaderStartUpModule.php

示例4: getDebug

 public function getDebug()
 {
     if (!is_null($this->debug)) {
         return $this->debug;
     } else {
         return $this->context->getDebug();
     }
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:8,代码来源:DerivativeResourceLoaderContext.php

示例5: testTypicalRequest

 public function testTypicalRequest()
 {
     $ctx = new ResourceLoaderContext($this->getResourceLoader(), new FauxRequest(['debug' => 'false', 'lang' => 'zh', 'modules' => 'foo|foo.quux,baz,bar|baz.quux', 'only' => 'styles', 'skin' => 'fallback']));
     // Request parameters
     $this->assertEquals($ctx->getModules(), ['foo', 'foo.quux', 'foo.baz', 'foo.bar', 'baz.quux']);
     $this->assertEquals(false, $ctx->getDebug());
     $this->assertEquals('zh', $ctx->getLanguage());
     $this->assertEquals('styles', $ctx->getOnly());
     $this->assertEquals('fallback', $ctx->getSkin());
     $this->assertEquals(null, $ctx->getUser());
     // Misc
     $this->assertEquals('ltr', $ctx->getDirection());
     $this->assertEquals('zh|fallback|||styles|||||', $ctx->getHash());
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:14,代码来源:ResourceLoaderContextTest.php

示例6: getConfigSettings

 /**
  * @param ResourceLoaderContext $context
  * @return array
  */
 protected function getConfigSettings($context)
 {
     $hash = $context->getHash();
     if (isset($this->configVars[$hash])) {
         return $this->configVars[$hash];
     }
     global $wgContLang;
     $conf = $this->getConfig();
     // We can't use Title::newMainPage() if 'mainpage' is in
     // $wgForceUIMsgAsContentMsg because that will try to use the session
     // user's language and we have no session user. This does the
     // equivalent but falling back to our ResourceLoaderContext language
     // instead.
     $mainPage = Title::newFromText($context->msg('mainpage')->inContentLanguage()->text());
     if (!$mainPage) {
         $mainPage = Title::newFromText('Main Page');
     }
     /**
      * Namespace related preparation
      * - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
      * - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
      */
     $namespaceIds = $wgContLang->getNamespaceIds();
     $caseSensitiveNamespaces = [];
     foreach (MWNamespace::getCanonicalNamespaces() as $index => $name) {
         $namespaceIds[$wgContLang->lc($name)] = $index;
         if (!MWNamespace::isCapitalized($index)) {
             $caseSensitiveNamespaces[] = $index;
         }
     }
     $illegalFileChars = $conf->get('IllegalFileChars');
     // Build list of variables
     $vars = ['wgLoadScript' => wfScript('load'), 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $conf->get('StylePath'), 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $conf->get('ArticlePath'), 'wgScriptPath' => $conf->get('ScriptPath'), 'wgScriptExtension' => '.php', 'wgScript' => wfScript(), 'wgSearchType' => $conf->get('SearchType'), 'wgVariantArticlePath' => $conf->get('VariantArticlePath'), 'wgActionPaths' => (object) $conf->get('ActionPaths'), 'wgServer' => $conf->get('Server'), 'wgServerName' => $conf->get('ServerName'), 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgTranslateNumerals' => $conf->get('TranslateNumerals'), 'wgVersion' => $conf->get('Version'), 'wgEnableAPI' => $conf->get('EnableAPI'), 'wgEnableWriteAPI' => $conf->get('EnableWriteAPI'), 'wgMainPageTitle' => $mainPage->getPrefixedText(), 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgContentNamespaces' => MWNamespace::getContentNamespaces(), 'wgSiteName' => $conf->get('Sitename'), 'wgDBname' => $conf->get('DBname'), 'wgExtraSignatureNamespaces' => $conf->get('ExtraSignatureNamespaces'), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $conf->get('ExtensionAssetsPath'), 'wgCookiePrefix' => $conf->get('CookiePrefix'), 'wgCookieDomain' => $conf->get('CookieDomain'), 'wgCookiePath' => $conf->get('CookiePath'), 'wgCookieExpiration' => $conf->get('CookieExpiration'), 'wgResourceLoaderMaxQueryLength' => $conf->get('ResourceLoaderMaxQueryLength'), 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass(Title::legalChars()), 'wgIllegalFileChars' => Title::convertByteClassToUnicodeClass($illegalFileChars), 'wgResourceLoaderStorageVersion' => $conf->get('ResourceLoaderStorageVersion'), 'wgResourceLoaderStorageEnabled' => $conf->get('ResourceLoaderStorageEnabled'), 'wgResourceLoaderLegacyModules' => self::getLegacyModules(), 'wgForeignUploadTargets' => $conf->get('ForeignUploadTargets'), 'wgEnableUploads' => $conf->get('EnableUploads')];
     Hooks::run('ResourceLoaderGetConfigVars', [&$vars]);
     $this->configVars[$hash] = $vars;
     return $this->configVars[$hash];
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:41,代码来源:ResourceLoaderStartUpModule.php

示例7: makeModuleResponse

 /**
  * Generates code for a response
  *
  * @param $context ResourceLoaderContext: Context in which to generate a response
  * @param $modules Array: List of module objects keyed by module name
  * @param $missing Array: List of unavailable modules (optional)
  * @return String: Response data
  */
 public function makeModuleResponse(ResourceLoaderContext $context, array $modules, $missing = array())
 {
     $out = '';
     $exceptions = '';
     if ($modules === array() && $missing === array()) {
         return '/* No modules requested. Max made me put this here */';
     }
     wfProfileIn(__METHOD__);
     // Pre-fetch blobs
     if ($context->shouldIncludeMessages()) {
         try {
             $blobs = MessageBlobStore::get($this, $modules, $context->getLanguage());
         } catch (Exception $e) {
             // Add exception to the output as a comment
             $exceptions .= $this->formatException($e);
         }
     } else {
         $blobs = array();
     }
     // Generate output
     foreach ($modules as $name => $module) {
         /**
          * @var $module ResourceLoaderModule
          */
         wfProfileIn(__METHOD__ . '-' . $name);
         try {
             $scripts = '';
             if ($context->shouldIncludeScripts()) {
                 // If we are in debug mode, we'll want to return an array of URLs if possible
                 // However, we can't do this if the module doesn't support it
                 // We also can't do this if there is an only= parameter, because we have to give
                 // the module a way to return a load.php URL without causing an infinite loop
                 if ($context->getDebug() && !$context->getOnly() && $module->supportsURLLoading()) {
                     $scripts = $module->getScriptURLsForDebug($context);
                 } else {
                     $scripts = $module->getScript($context);
                     if (is_string($scripts)) {
                         // bug 27054: Append semicolon to prevent weird bugs
                         // caused by files not terminating their statements right
                         $scripts .= ";\n";
                     }
                 }
             }
             // Styles
             $styles = array();
             if ($context->shouldIncludeStyles()) {
                 // If we are in debug mode, we'll want to return an array of URLs
                 // See comment near shouldIncludeScripts() for more details
                 if ($context->getDebug() && !$context->getOnly() && $module->supportsURLLoading()) {
                     $styles = $module->getStyleURLsForDebug($context);
                 } else {
                     $styles = $module->getStyles($context);
                 }
             }
             // Messages
             $messagesBlob = isset($blobs[$name]) ? $blobs[$name] : '{}';
             // Append output
             switch ($context->getOnly()) {
                 case 'scripts':
                     if (is_string($scripts)) {
                         // Load scripts raw...
                         $out .= $scripts;
                     } elseif (is_array($scripts)) {
                         // ...except when $scripts is an array of URLs
                         $out .= self::makeLoaderImplementScript($name, $scripts, array(), array());
                     }
                     break;
                 case 'styles':
                     $out .= self::makeCombinedStyles($styles);
                     break;
                 case 'messages':
                     $out .= self::makeMessageSetScript(new XmlJsCode($messagesBlob));
                     break;
                 default:
                     // Minify CSS before embedding in mw.loader.implement call
                     // (unless in debug mode)
                     if (!$context->getDebug()) {
                         foreach ($styles as $media => $style) {
                             if (is_string($style)) {
                                 $styles[$media] = $this->filter('minify-css', $style);
                             }
                         }
                     }
                     $out .= self::makeLoaderImplementScript($name, $scripts, $styles, new XmlJsCode($messagesBlob));
                     break;
             }
         } catch (Exception $e) {
             // Add exception to the output as a comment
             $exceptions .= $this->formatException($e);
             // Register module as missing
             $missing[] = $name;
             unset($modules[$name]);
//.........这里部分代码省略.........
开发者ID:Tjorriemorrie,项目名称:app,代码行数:101,代码来源:ResourceLoader.php

示例8: getScriptFiles

 /**
  * Gets a list of file paths for all scripts in this module, in order of propper execution.
  *
  * @param $context ResourceLoaderContext: Context
  * @return Array: List of file paths
  */
 protected function getScriptFiles(ResourceLoaderContext $context)
 {
     $files = array_merge($this->scripts, self::tryForKey($this->languageScripts, $context->getLanguage()), self::tryForKey($this->skinScripts, $context->getSkin(), 'default'));
     if ($context->getDebug()) {
         $files = array_merge($files, $this->debugScripts);
     }
     return array_unique($files);
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:14,代码来源:ResourceLoaderFileModule.php

示例9: getStartupModulesUrl

 /**
  * Get the load URL of the startup modules.
  *
  * This is a helper for getScript(), but can also be called standalone, such
  * as when generating an AppCache manifest.
  *
  * @param ResourceLoaderContext $context
  * @return string
  */
 public static function getStartupModulesUrl(ResourceLoaderContext $context)
 {
     $rl = $context->getResourceLoader();
     $moduleNames = self::getStartupModules();
     $query = ['modules' => ResourceLoader::makePackedModulesString($moduleNames), 'only' => 'scripts', 'lang' => $context->getLanguage(), 'skin' => $context->getSkin(), 'debug' => $context->getDebug() ? 'true' : 'false', 'version' => $rl->getCombinedVersion($context, $moduleNames)];
     // Ensure uniform query order
     ksort($query);
     return wfAppendQuery(wfScript('load'), $query);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:18,代码来源:ResourceLoaderStartUpModule.php

示例10: buildContent

 /**
  * Bundle all resources attached to this module into an array.
  *
  * @since 1.26
  * @param ResourceLoaderContext $context
  * @return array
  */
 protected final function buildContent(ResourceLoaderContext $context)
 {
     $rl = $context->getResourceLoader();
     $stats = RequestContext::getMain()->getStats();
     $statStart = microtime(true);
     // Only include properties that are relevant to this context (e.g. only=scripts)
     // and that are non-empty (e.g. don't include "templates" for modules without
     // templates). This helps prevent invalidating cache for all modules when new
     // optional properties are introduced.
     $content = array();
     // Scripts
     if ($context->shouldIncludeScripts()) {
         // If we are in debug mode, we'll want to return an array of URLs if possible
         // However, we can't do this if the module doesn't support it
         // We also can't do this if there is an only= parameter, because we have to give
         // the module a way to return a load.php URL without causing an infinite loop
         if ($context->getDebug() && !$context->getOnly() && $this->supportsURLLoading()) {
             $scripts = $this->getScriptURLsForDebug($context);
         } else {
             $scripts = $this->getScript($context);
             // rtrim() because there are usually a few line breaks
             // after the last ';'. A new line at EOF, a new line
             // added by ResourceLoaderFileModule::readScriptFiles, etc.
             if (is_string($scripts) && strlen($scripts) && substr(rtrim($scripts), -1) !== ';') {
                 // Append semicolon to prevent weird bugs caused by files not
                 // terminating their statements right (bug 27054)
                 $scripts .= ";\n";
             }
         }
         $content['scripts'] = $scripts;
     }
     // Styles
     if ($context->shouldIncludeStyles()) {
         $styles = array();
         // Don't create empty stylesheets like array( '' => '' ) for modules
         // that don't *have* any stylesheets (bug 38024).
         $stylePairs = $this->getStyles($context);
         if (count($stylePairs)) {
             // If we are in debug mode without &only= set, we'll want to return an array of URLs
             // See comment near shouldIncludeScripts() for more details
             if ($context->getDebug() && !$context->getOnly() && $this->supportsURLLoading()) {
                 $styles = array('url' => $this->getStyleURLsForDebug($context));
             } else {
                 // Minify CSS before embedding in mw.loader.implement call
                 // (unless in debug mode)
                 if (!$context->getDebug()) {
                     foreach ($stylePairs as $media => $style) {
                         // Can be either a string or an array of strings.
                         if (is_array($style)) {
                             $stylePairs[$media] = array();
                             foreach ($style as $cssText) {
                                 if (is_string($cssText)) {
                                     $stylePairs[$media][] = $rl->filter('minify-css', $cssText);
                                 }
                             }
                         } elseif (is_string($style)) {
                             $stylePairs[$media] = $rl->filter('minify-css', $style);
                         }
                     }
                 }
                 // Wrap styles into @media groups as needed and flatten into a numerical array
                 $styles = array('css' => $rl->makeCombinedStyles($stylePairs));
             }
         }
         $content['styles'] = $styles;
     }
     // Messages
     $blobs = $rl->getMessageBlobStore()->get($rl, array($this->getName() => $this), $context->getLanguage());
     if (isset($blobs[$this->getName()])) {
         $content['messagesBlob'] = $blobs[$this->getName()];
     }
     $templates = $this->getTemplates();
     if ($templates) {
         $content['templates'] = $templates;
     }
     $statTiming = microtime(true) - $statStart;
     $statName = strtr($this->getName(), '.', '_');
     $stats->timing("resourceloader_build.all", 1000 * $statTiming);
     $stats->timing("resourceloader_build.{$statName}", 1000 * $statTiming);
     return $content;
 }
开发者ID:kynikos,项目名称:archlinux-mediawiki,代码行数:88,代码来源:ResourceLoaderModule.php

示例11: getTitleMtimes

 /**
  * Get the modification times of all titles that would be loaded for
  * a given context.
  * Caches data from underlying layers.
  *
  * @param $context ResourceLoaderContext: Context object
  * @return array( prefixed DB key => UNIX timestamp ), nonexistent titles are dropped
  */
 protected function getTitleMtimes(ResourceLoaderContext $context)
 {
     global $wgMemc;
     wfProfileIn(__METHOD__);
     $hash = $context->getHash();
     if (isset($this->titleMtimes[$hash])) {
         wfProfileOut(__METHOD__);
         return $this->titleMtimes[$hash];
     }
     // Wikia change - begin - @author: wladek
     $memcKey = null;
     // silence PHPStorm
     if (!$context->getDebug()) {
         $memcKey = wfMemcKey('ResourceLoaderWikiModule', 'mtimes', $this->getName(), md5($hash));
         $mtimes = $wgMemc->get($memcKey);
         if (is_array($mtimes)) {
             wfProfileOut(__METHOD__);
             return $mtimes;
         }
     }
     // Wikia change - end
     $this->titleMtimes[$hash] = $this->reallyGetTitleMtimes($context);
     // Wikia change - begin - @author: wladek
     if (!$context->getDebug()) {
         $wgMemc->set($memcKey, $this->titleMtimes[$hash], self::MTIMES_CACHE_TTL);
     }
     // Wikia change - end
     wfProfileOut(__METHOD__);
     return $this->titleMtimes[$hash];
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:38,代码来源:ResourceLoaderWikiModule.php

示例12: makeLoad

 /**
  * Explicily load or embed modules on a page.
  *
  * @param ResourceLoaderContext $mainContext
  * @param array $modules One or more module names
  * @param string $only ResourceLoaderModule TYPE_ class constant
  * @param array $extraQuery [optional] Array with extra query parameters for the request
  * @return string|WrappedStringList HTML
  */
 public static function makeLoad(ResourceLoaderContext $mainContext, array $modules, $only, array $extraQuery = [])
 {
     $rl = $mainContext->getResourceLoader();
     $chunks = [];
     if ($mainContext->getDebug() && count($modules) > 1) {
         $chunks = [];
         // Recursively call us for every item
         foreach ($modules as $name) {
             $chunks[] = self::makeLoad($mainContext, [$name], $only, $extraQuery);
         }
         return new WrappedStringList("\n", $chunks);
     }
     // Sort module names so requests are more uniform
     sort($modules);
     // Create keyed-by-source and then keyed-by-group list of module objects from modules list
     $sortedModules = [];
     foreach ($modules as $name) {
         $module = $rl->getModule($name);
         if (!$module) {
             $rl->getLogger()->warning('Unknown module "{module}"', ['module' => $name]);
             continue;
         }
         $sortedModules[$module->getSource()][$module->getGroup()][$name] = $module;
     }
     foreach ($sortedModules as $source => $groups) {
         foreach ($groups as $group => $grpModules) {
             $context = self::makeContext($mainContext, $group, $only, $extraQuery);
             $context->setModules(array_keys($grpModules));
             if ($group === 'private') {
                 // Decide whether to use style or script element
                 if ($only == ResourceLoaderModule::TYPE_STYLES) {
                     $chunks[] = Html::inlineStyle($rl->makeModuleResponse($context, $grpModules));
                 } else {
                     $chunks[] = ResourceLoader::makeInlineScript($rl->makeModuleResponse($context, $grpModules));
                 }
                 continue;
             }
             // See if we have one or more raw modules
             $isRaw = false;
             foreach ($grpModules as $key => $module) {
                 $isRaw |= $module->isRaw();
             }
             // 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-changeable 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 CDN-cached HTML
             if ($group === 'user') {
                 // Must setModules() before makeVersionQuery()
                 $context->setVersion($rl->makeVersionQuery($context));
             }
             $url = $rl->createLoaderURL($source, $context, $extraQuery);
             // Decide whether to use 'style' or 'script' element
             if ($only === ResourceLoaderModule::TYPE_STYLES) {
                 $chunk = Html::linkedStyle($url);
             } else {
                 if ($context->getRaw() || $isRaw) {
                     $chunk = Html::element('script', ['async' => !isset($extraQuery['sync']), 'src' => $url]);
                 } else {
                     $chunk = ResourceLoader::makeInlineScript(Xml::encodeJsCall('mw.loader.load', [$url]));
                 }
             }
             if ($group == 'noscript') {
                 $chunks[] = Html::rawElement('noscript', [], $chunk);
             } else {
                 $chunks[] = $chunk;
             }
         }
     }
     return new WrappedStringList("\n", $chunks);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:80,代码来源:ResourceLoaderClientHtml.php

示例13: getScript

 public function getScript(ResourceLoaderContext $context)
 {
     global $IP, $wgLoadScript;
     $out = file_get_contents("{$IP}/resources/startup.js");
     if ($context->getOnly() === 'scripts') {
         // Build load query for jquery and mediawiki modules
         $query = array('modules' => implode('|', array('jquery', 'mediawiki')), 'only' => 'scripts', 'lang' => $context->getLanguage(), 'skin' => $context->getSkin(), 'debug' => $context->getDebug() ? 'true' : 'false', 'version' => wfTimestamp(TS_ISO_8601_BASIC, round(max($context->getResourceLoader()->getModule('jquery')->getModifiedTime($context), $context->getResourceLoader()->getModule('mediawiki')->getModifiedTime($context)), -2)));
         // Ensure uniform query order
         ksort($query);
         // Startup function
         $configuration = $this->getConfig($context);
         $registrations = self::getModuleRegistrations($context);
         $out .= "var startUp = function() {\n" . "\t{$registrations}\n" . "\t" . Xml::encodeJsCall('mediaWiki.config.set', array($configuration)) . "};\n";
         // Conditional script injection
         $scriptTag = Html::linkedScript($wgLoadScript . '?' . wfArrayToCGI($query));
         $out .= "if ( isCompatible() ) {\n" . "\t" . Xml::encodeJsCall('document.write', array($scriptTag)) . "}\n" . "delete isCompatible;";
     }
     return $out;
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:19,代码来源:ResourceLoaderStartUpModule.php

示例14: makeModuleResponse

 /**
  * Generate code for a response.
  *
  * @param $context ResourceLoaderContext Context in which to generate a response
  * @param array $modules List of module objects keyed by module name
  * @param array $missing List of requested module names that are unregistered (optional)
  * @return string Response data
  */
 public function makeModuleResponse(ResourceLoaderContext $context, array $modules, array $missing = array())
 {
     $out = '';
     $exceptions = '';
     $states = array();
     if (!count($modules) && !count($missing)) {
         return "/* This file is the Web entry point for MediaWiki's ResourceLoader:\n   <https://www.mediawiki.org/wiki/ResourceLoader>. In this request,\n   no modules were requested. Max made me put this here. */";
     }
     wfProfileIn(__METHOD__);
     // Pre-fetch blobs
     if ($context->shouldIncludeMessages()) {
         try {
             $blobs = MessageBlobStore::get($this, $modules, $context->getLanguage());
         } catch (Exception $e) {
             MWExceptionHandler::logException($e);
             wfDebugLog('resourceloader', __METHOD__ . ": pre-fetching blobs from MessageBlobStore failed: {$e}");
             $this->hasErrors = true;
             // Add exception to the output as a comment
             $exceptions .= self::formatException($e);
         }
     } else {
         $blobs = array();
     }
     foreach ($missing as $name) {
         $states[$name] = 'missing';
     }
     // Generate output
     $isRaw = false;
     foreach ($modules as $name => $module) {
         /**
          * @var $module ResourceLoaderModule
          */
         wfProfileIn(__METHOD__ . '-' . $name);
         try {
             $scripts = '';
             if ($context->shouldIncludeScripts()) {
                 // If we are in debug mode, we'll want to return an array of URLs if possible
                 // However, we can't do this if the module doesn't support it
                 // We also can't do this if there is an only= parameter, because we have to give
                 // the module a way to return a load.php URL without causing an infinite loop
                 if ($context->getDebug() && !$context->getOnly() && $module->supportsURLLoading()) {
                     $scripts = $module->getScriptURLsForDebug($context);
                 } else {
                     $scripts = $module->getScript($context);
                     // rtrim() because there are usually a few line breaks after the last ';'.
                     // A new line at EOF, a new line added by ResourceLoaderFileModule::readScriptFiles, etc.
                     if (is_string($scripts) && strlen($scripts) && substr(rtrim($scripts), -1) !== ';') {
                         // Append semicolon to prevent weird bugs caused by files not
                         // terminating their statements right (bug 27054)
                         $scripts .= ";\n";
                     }
                 }
             }
             // Styles
             $styles = array();
             if ($context->shouldIncludeStyles()) {
                 // Don't create empty stylesheets like array( '' => '' ) for modules
                 // that don't *have* any stylesheets (bug 38024).
                 $stylePairs = $module->getStyles($context);
                 if (count($stylePairs)) {
                     // If we are in debug mode without &only= set, we'll want to return an array of URLs
                     // See comment near shouldIncludeScripts() for more details
                     if ($context->getDebug() && !$context->getOnly() && $module->supportsURLLoading()) {
                         $styles = array('url' => $module->getStyleURLsForDebug($context));
                     } else {
                         // Minify CSS before embedding in mw.loader.implement call
                         // (unless in debug mode)
                         if (!$context->getDebug()) {
                             foreach ($stylePairs as $media => $style) {
                                 // Can be either a string or an array of strings.
                                 if (is_array($style)) {
                                     $stylePairs[$media] = array();
                                     foreach ($style as $cssText) {
                                         if (is_string($cssText)) {
                                             $stylePairs[$media][] = $this->filter('minify-css', $cssText);
                                         }
                                     }
                                 } elseif (is_string($style)) {
                                     $stylePairs[$media] = $this->filter('minify-css', $style);
                                 }
                             }
                         }
                         // Wrap styles into @media groups as needed and flatten into a numerical array
                         $styles = array('css' => self::makeCombinedStyles($stylePairs));
                     }
                 }
             }
             // Messages
             $messagesBlob = isset($blobs[$name]) ? $blobs[$name] : '{}';
             // Append output
             switch ($context->getOnly()) {
                 case 'scripts':
//.........这里部分代码省略.........
开发者ID:Tarendai,项目名称:spring-website,代码行数:101,代码来源:ResourceLoader.php

示例15: makeModuleResponse

 /**
  * Generates code for a response
  *
  * @param $context ResourceLoaderContext: Context in which to generate a response
  * @param $modules Array: List of module objects keyed by module name
  * @param $missing Array: List of unavailable modules (optional)
  * @return String: Response data
  */
 public function makeModuleResponse(ResourceLoaderContext $context, array $modules, $missing = array())
 {
     $out = '';
     $exceptions = '';
     if ($modules === array() && $missing === array()) {
         return '/* No modules requested. Max made me put this here */';
     }
     wfProfileIn(__METHOD__);
     // Pre-fetch blobs
     if ($context->shouldIncludeMessages()) {
         try {
             $blobs = MessageBlobStore::get($this, $modules, $context->getLanguage());
         } catch (Exception $e) {
             // Add exception to the output as a comment
             $exceptions .= $this->makeComment($e->__toString());
         }
     } else {
         $blobs = array();
     }
     // Generate output
     $isRaw = false;
     foreach ($modules as $name => $module) {
         /**
          * @var $module ResourceLoaderModule
          */
         wfProfileIn(__METHOD__ . '-' . $name);
         try {
             $scripts = '';
             if ($context->shouldIncludeScripts()) {
                 // If we are in debug mode, we'll want to return an array of URLs if possible
                 // However, we can't do this if the module doesn't support it
                 // We also can't do this if there is an only= parameter, because we have to give
                 // the module a way to return a load.php URL without causing an infinite loop
                 if ($context->getDebug() && !$context->getOnly() && $module->supportsURLLoading()) {
                     $scripts = $module->getScriptURLsForDebug($context);
                 } else {
                     $scripts = $module->getScript($context);
                     if (is_string($scripts) && strlen($scripts) && substr($scripts, -1) !== ';') {
                         // bug 27054: Append semicolon to prevent weird bugs
                         // caused by files not terminating their statements right
                         $scripts .= ";\n";
                     }
                 }
             }
             // Styles
             $styles = array();
             if ($context->shouldIncludeStyles()) {
                 // Don't create empty stylesheets like array( '' => '' ) for modules
                 // that don't *have* any stylesheets (bug 38024).
                 $stylePairs = $module->getStyles($context);
                 if (count($stylePairs)) {
                     // If we are in debug mode without &only= set, we'll want to return an array of URLs
                     // See comment near shouldIncludeScripts() for more details
                     if ($context->getDebug() && !$context->getOnly() && $module->supportsURLLoading()) {
                         $styles = array('url' => $module->getStyleURLsForDebug($context));
                     } else {
                         // Minify CSS before embedding in mw.loader.implement call
                         // (unless in debug mode)
                         if (!$context->getDebug()) {
                             foreach ($stylePairs as $media => $style) {
                                 // Can be either a string or an array of strings.
                                 if (is_array($style)) {
                                     $stylePairs[$media] = array();
                                     foreach ($style as $cssText) {
                                         if (is_string($cssText)) {
                                             $stylePairs[$media][] = $this->filter('minify-css', $cssText);
                                         }
                                     }
                                 } elseif (is_string($style)) {
                                     $stylePairs[$media] = $this->filter('minify-css', $style);
                                 }
                             }
                         }
                         // Wrap styles into @media groups as needed and flatten into a numerical array
                         $styles = array('css' => self::makeCombinedStyles($stylePairs));
                     }
                 }
             }
             // Messages
             $messagesBlob = isset($blobs[$name]) ? $blobs[$name] : '{}';
             // Append output
             switch ($context->getOnly()) {
                 case 'scripts':
                     if (is_string($scripts)) {
                         // Load scripts raw...
                         $out .= $scripts;
                     } elseif (is_array($scripts)) {
                         // ...except when $scripts is an array of URLs
                         $out .= self::makeLoaderImplementScript($name, $scripts, array(), array());
                     }
                     break;
                 case 'styles':
//.........这里部分代码省略.........
开发者ID:seedbank,项目名称:old-repo,代码行数:101,代码来源:ResourceLoader.php


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