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


PHP ResourceLoaderModule::expandRelativePaths方法代码示例

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


在下文中一共展示了ResourceLoaderModule::expandRelativePaths方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 $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

示例2: 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


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