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


PHP ResourceLoaderModule类代码示例

本文整理汇总了PHP中ResourceLoaderModule的典型用法代码示例。如果您正苦于以下问题:PHP ResourceLoaderModule类的具体用法?PHP ResourceLoaderModule怎么用?PHP ResourceLoaderModule使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: preloadModuleInfo

 /**
  * Load information stored in the database about modules.
  *
  * This method grabs modules dependencies from the database and updates modules
  * objects.
  *
  * This is not inside the module code because it is much faster to
  * request all of the information at once than it is to have each module
  * requests its own information. This sacrifice of modularity yields a substantial
  * performance improvement.
  *
  * @param array $moduleNames List of module names to preload information for
  * @param ResourceLoaderContext $context Context to load the information within
  */
 public function preloadModuleInfo(array $moduleNames, ResourceLoaderContext $context)
 {
     if (!$moduleNames) {
         // Or else Database*::select() will explode, plus it's cheaper!
         return;
     }
     $dbr = wfGetDB(DB_SLAVE);
     $skin = $context->getSkin();
     $lang = $context->getLanguage();
     // Batched version of ResourceLoaderModule::getFileDependencies
     $vary = "{$skin}|{$lang}";
     $res = $dbr->select('module_deps', array('md_module', 'md_deps'), array('md_module' => $moduleNames, 'md_skin' => $vary), __METHOD__);
     // Prime in-object cache for file dependencies
     $modulesWithDeps = array();
     foreach ($res as $row) {
         $module = $this->getModule($row->md_module);
         if ($module) {
             $module->setFileDependencies($context, ResourceLoaderModule::expandRelativePaths(FormatJson::decode($row->md_deps, true)));
             $modulesWithDeps[] = $row->md_module;
         }
     }
     // Register the absence of a dependency row too
     foreach (array_diff($moduleNames, $modulesWithDeps) as $name) {
         $module = $this->getModule($name);
         if ($module) {
             $this->getModule($name)->setFileDependencies($context, array());
         }
     }
     // Prime in-object cache for message blobs for modules with messages
     $modules = array();
     foreach ($moduleNames as $name) {
         $module = $this->getModule($name);
         if ($module && $module->getMessages()) {
             $modules[$name] = $module;
         }
     }
     $store = $this->getMessageBlobStore();
     $blobs = $store->getBlobs($modules, $lang);
     foreach ($blobs as $name => $blob) {
         $modules[$name]->setMessageBlob($blob, $lang);
     }
 }
开发者ID:bkmls,项目名称:mediawiki,代码行数:56,代码来源:ResourceLoader.php

示例2: getScriptURLsForDebug

 /**
  * @param ResourceLoaderContext $context
  * @return array
  */
 public function getScriptURLsForDebug(ResourceLoaderContext $context)
 {
     // Bypass file module urls
     return ResourceLoaderModule::getScriptURLsForDebug($context);
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:9,代码来源:ResourceLoaderJqueryMsgModule.php

示例3: generateMessageBlob

 /**
  * Generate the message blob for a given module in a given language.
  *
  * @param ResourceLoaderModule $module
  * @param string $lang Language code
  * @return string JSON object
  */
 private function generateMessageBlob(ResourceLoaderModule $module, $lang)
 {
     $messages = array();
     foreach ($module->getMessages() as $key) {
         $messages[$key] = wfMessage($key)->inLanguage($lang)->plain();
     }
     return FormatJson::encode((object) $messages);
 }
开发者ID:junjiemars,项目名称:mediawiki,代码行数:15,代码来源:MessageBlobStore.php

示例4: generateMessageBlob

 /**
  * Generate the message blob for a given module in a given language.
  *
  * @param ResourceLoaderModule $module
  * @param string $lang Language code
  * @return string JSON blob
  */
 private function generateMessageBlob(ResourceLoaderModule $module, $lang)
 {
     $messages = [];
     foreach ($module->getMessages() as $key) {
         $messages[$key] = $this->fetchMessage($key, $lang);
     }
     $json = FormatJson::encode((object) $messages);
     if ($json === false) {
         $this->logger->warning('Failed to encode message blob for {module} ({lang})', ['module' => $module->getName(), 'lang' => $lang]);
         $json = '{}';
     }
     return $json;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:20,代码来源:MessageBlobStore.php

示例5: generateMessageBlob

 /**
  * Generate the message blob for a given module in a given language.
  *
  * @param ResourceLoaderModule $module
  * @param string $lang Language code
  * @return string JSON blob
  */
 private function generateMessageBlob(ResourceLoaderModule $module, $lang)
 {
     $messages = array();
     foreach ($module->getMessages() as $key) {
         $messages[$key] = $this->fetchMessage($key, $lang);
     }
     return FormatJson::encode((object) $messages);
 }
开发者ID:huatuoorg,项目名称:mediawiki,代码行数:15,代码来源:MessageBlobStore.php

示例6: generateMessageBlob

 /**
  * Generate the message blob for a given module in a given language.
  *
  * @param $module ResourceLoaderModule object
  * @param $lang String: language code
  * @return String: JSON object
  */
 private static function generateMessageBlob(ResourceLoaderModule $module, $lang)
 {
     $messages = array();
     foreach ($module->getMessages() as $key) {
         $messages[$key] = wfMsgExt($key, array('language' => $lang));
     }
     return FormatJson::encode((object) $messages);
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:15,代码来源:MessageBlobStore.php

示例7: getModifiedTime

 public function getModifiedTime(ResourceLoaderContext $context)
 {
     return max($this->getGitHeadModifiedTime($context), $this->getMsgBlobMtime($context->getLanguage()), ResourceLoaderModule::safeFilemtime(__FILE__));
 }
开发者ID:brandonphuong,项目名称:mediawiki,代码行数:4,代码来源:VisualEditorDataModule.php

示例8: preloadModuleInfo

 /**
  * Load information stored in the database about modules.
  *
  * This method grabs modules dependencies from the database and updates modules
  * objects.
  *
  * This is not inside the module code because it is much faster to
  * request all of the information at once than it is to have each module
  * requests its own information. This sacrifice of modularity yields a substantial
  * performance improvement.
  *
  * @param array $modules List of module names to preload information for
  * @param ResourceLoaderContext $context Context to load the information within
  */
 public function preloadModuleInfo(array $modules, ResourceLoaderContext $context)
 {
     if (!count($modules)) {
         // Or else Database*::select() will explode, plus it's cheaper!
         return;
     }
     $dbr = wfGetDB(DB_SLAVE);
     $skin = $context->getSkin();
     $lang = $context->getLanguage();
     // Batched version of ResourceLoaderModule::getFileDependencies
     $vary = "{$skin}|{$lang}";
     $res = $dbr->select('module_deps', array('md_module', 'md_deps'), array('md_module' => $modules, 'md_skin' => $vary), __METHOD__);
     // Prime in-object cache values for each module
     $modulesWithDeps = array();
     foreach ($res as $row) {
         $module = $this->getModule($row->md_module);
         if ($module) {
             $module->setFileDependencies($context, ResourceLoaderModule::expandRelativePaths(FormatJson::decode($row->md_deps, true)));
             $modulesWithDeps[] = $row->md_module;
         }
     }
     // Register the absence of a dependency row too
     foreach (array_diff($modules, $modulesWithDeps) as $name) {
         $module = $this->getModule($name);
         if ($module) {
             $this->getModule($name)->setFileDependencies($context, array());
         }
     }
     // Get message blob mtimes. Only do this for modules with messages
     $modulesWithMessages = array();
     foreach ($modules as $name) {
         $module = $this->getModule($name);
         if ($module && count($module->getMessages())) {
             $modulesWithMessages[] = $name;
         }
     }
     $modulesWithoutMessages = array_flip($modules);
     // Will be trimmed down by the loop below
     if (count($modulesWithMessages)) {
         $res = $dbr->select('msg_resource', array('mr_resource', 'mr_timestamp'), array('mr_resource' => $modulesWithMessages, 'mr_lang' => $lang), __METHOD__);
         foreach ($res as $row) {
             $module = $this->getModule($row->mr_resource);
             if ($module) {
                 $module->setMsgBlobMtime($lang, wfTimestamp(TS_UNIX, $row->mr_timestamp));
                 unset($modulesWithoutMessages[$row->mr_resource]);
             }
         }
     }
     foreach (array_keys($modulesWithoutMessages) as $name) {
         $module = $this->getModule($name);
         if ($module) {
             $module->setMsgBlobMtime($lang, 1);
         }
     }
 }
开发者ID:agothro,项目名称:mediawiki,代码行数:69,代码来源:ResourceLoader.php

示例9: getDefinitionSummary

 /**
  * Get the definition summary for this module.
  *
  * @param ResourceLoaderContext $context
  * @return array
  */
 public function getDefinitionSummary(ResourceLoaderContext $context)
 {
     global $IP;
     $summary = parent::getDefinitionSummary($context);
     $summary[] = ['vars' => $this->getConfigSettings($context), 'wgLegacyJavaScriptGlobals' => $this->getConfig()->get('LegacyJavaScriptGlobals'), 'moduleHashes' => $this->getAllModuleHashes($context), 'fileMtimes' => [filemtime("{$IP}/resources/src/startup.js")]];
     return $summary;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:13,代码来源:ResourceLoaderStartUpModule.php

示例10: getDefinitionSummary

 /**
  * Get the definition summary for this module.
  *
  * @param ResourceLoaderContext $context
  * @return array
  */
 public function getDefinitionSummary(ResourceLoaderContext $context)
 {
     $summary = parent::getDefinitionSummary($context);
     $options = array();
     foreach (array('scripts', 'debugScripts', 'loaderScripts', 'styles', 'languageScripts', 'skinScripts', 'skinStyles', 'messages', 'templates', 'skipFunction', 'debugRaw', 'raw') as $member) {
         $options[$member] = $this->{$member};
     }
     $summary[] = array('options' => $options, 'fileHashes' => $this->getFileHashes($context), 'msgBlobMtime' => $this->getMsgBlobMtime($context->getLanguage()));
     return $summary;
 }
开发者ID:jpena88,项目名称:mediawiki-dokku-deploy,代码行数:16,代码来源:ResourceLoaderFileModule.php

示例11: javaScriptParser

 /**
  * @return JSParser
  */
 protected static function javaScriptParser()
 {
     if (!self::$jsParser) {
         self::$jsParser = new JSParser();
     }
     return self::$jsParser;
 }
开发者ID:tempbottle,项目名称:Work,代码行数:10,代码来源:ResourceLoaderModule.php

示例12: isPositionDefault

 public function isPositionDefault()
 {
     $this->loadFromDefinition();
     return parent::isPositionDefault();
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:5,代码来源:ResourceLoaderImageModule.php

示例13: getDefinitionSummary

 /**
  * Get the definition summary for this module.
  *
  * @param ResourceLoaderContext $context
  * @return array
  */
 public function getDefinitionSummary(ResourceLoaderContext $context)
 {
     $this->loadFromDefinition();
     $summary = parent::getDefinitionSummary($context);
     $options = [];
     foreach (['localBasePath', 'images', 'variants', 'prefix', 'selectorWithoutVariant', 'selectorWithVariant'] as $member) {
         $options[$member] = $this->{$member};
     }
     $summary[] = ['options' => $options, 'fileHashes' => $this->getFileHashes($context)];
     return $summary;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:17,代码来源:ResourceLoaderImageModule.php

示例14: getDefinitionSummary

 /**
  * @param $context ResourceLoaderContext
  * @return array
  */
 public function getDefinitionSummary(ResourceLoaderContext $context)
 {
     $r = parent::getDefinitionSummary($context);
     return $r + array('class' => get_class($this), 'lang' => $this->lang, 'geshi' => GESHI_VERSION);
 }
开发者ID:mediawiki4intranet,项目名称:SyntaxHighlight_GeSHi,代码行数:9,代码来源:ResourceLoaderGeSHiModule.php

示例15: getDefinitionSummary

 /**
  * Get the definition summary for this module.
  *
  * @param ResourceLoaderContext $context
  * @return array
  */
 public function getDefinitionSummary(ResourceLoaderContext $context)
 {
     $summary = parent::getDefinitionSummary($context);
     foreach (array('scripts', 'debugScripts', 'loaderScripts', 'styles', 'languageScripts', 'skinScripts', 'skinStyles', 'dependencies', 'messages', 'targets', 'templates', 'group', 'position', 'skipFunction', 'localBasePath', 'remoteBasePath', 'debugRaw', 'raw') as $member) {
         $summary[$member] = $this->{$member};
     }
     return $summary;
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:14,代码来源:ResourceLoaderFileModule.php


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