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


PHP ResourceLoader::makeCustomLoaderScript方法代码示例

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


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

示例1: getModuleRegistrations

 /**
  * Gets registration code for all modules
  *
  * @param $context ResourceLoaderContext object
  * @return String: JavaScript code for registering all modules with the client loader
  */
 public static function getModuleRegistrations(ResourceLoaderContext $context)
 {
     global $wgCacheEpoch;
     wfProfileIn(__METHOD__);
     $out = '';
     $registrations = array();
     $resourceLoader = $context->getResourceLoader();
     foreach ($resourceLoader->getModuleNames() as $name) {
         $module = $resourceLoader->getModule($name);
         // Support module loader scripts
         $loader = $module->getLoaderScript();
         if ($loader !== false) {
             $deps = $module->getDependencies();
             $group = $module->getGroup();
             $version = wfTimestamp(TS_ISO_8601_BASIC, round($module->getModifiedTime($context), -2));
             $out .= ResourceLoader::makeCustomLoaderScript($name, $version, $deps, $group, $loader);
         } else {
             $mtime = max($module->getModifiedTime($context), wfTimestamp(TS_UNIX, $wgCacheEpoch));
             // Modules without dependencies or a group pass two arguments (name, timestamp) to
             // mediaWiki.loader.register()
             if (!count($module->getDependencies() && $module->getGroup() === null)) {
                 $registrations[] = array($name, $mtime);
             } else {
                 if ($module->getGroup() === null) {
                     $registrations[] = array($name, $mtime, $module->getDependencies());
                 } else {
                     $registrations[] = array($name, $mtime, $module->getDependencies(), $module->getGroup());
                 }
             }
         }
     }
     $out .= ResourceLoader::makeLoaderRegisterScript($registrations);
     wfProfileOut(__METHOD__);
     return $out;
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:41,代码来源:ResourceLoaderStartUpModule.php

示例2: getModuleRegistrations

 /**
  * Gets registration code for all modules
  *
  * @param $context ResourceLoaderContext object
  * @return String: JavaScript code for registering all modules with the client loader
  */
 public static function getModuleRegistrations(ResourceLoaderContext $context)
 {
     global $wgCacheEpoch;
     wfProfileIn(__METHOD__);
     $out = '';
     $registrations = array();
     $resourceLoader = $context->getResourceLoader();
     // Register sources
     $out .= ResourceLoader::makeLoaderSourcesScript($resourceLoader->getSources());
     // Register modules
     foreach ($resourceLoader->getModuleNames() as $name) {
         $module = $resourceLoader->getModule($name);
         // Support module loader scripts
         $loader = $module->getLoaderScript();
         if ($loader !== false) {
             $deps = $module->getDependencies();
             $group = $module->getGroup();
             $source = $module->getSource();
             $version = wfTimestamp(TS_ISO_8601_BASIC, $module->getModifiedTime($context));
             $out .= ResourceLoader::makeCustomLoaderScript($name, $version, $deps, $group, $source, $loader);
         } else {
             // 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, $wgCacheEpoch));
             // Wikia - change begin - @author: wladek
             $flags = $module->getFlag($module->getFlagNames());
             if (!empty($flags)) {
                 $registrations[] = array($name, $mtime, $module->getDependencies(), $module->getGroup(), $module->getSource(), $flags);
             } else {
                 // Wikia - change end
                 // Modules without dependencies, a group or a foreign source pass two arguments (name, timestamp) to
                 // mw.loader.register()
                 if (!count($module->getDependencies()) && $module->getGroup() === null && $module->getSource() === 'local') {
                     $registrations[] = array($name, $mtime);
                 } elseif ($module->getGroup() === null && $module->getSource() === 'local') {
                     $registrations[] = array($name, $mtime, $module->getDependencies());
                 } elseif ($module->getSource() === 'local') {
                     $registrations[] = array($name, $mtime, $module->getDependencies(), $module->getGroup());
                 } else {
                     $registrations[] = array($name, $mtime, $module->getDependencies(), $module->getGroup(), $module->getSource());
                 }
             }
         }
     }
     $out .= ResourceLoader::makeLoaderRegisterScript($registrations);
     wfProfileOut(__METHOD__);
     return $out;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:55,代码来源:ResourceLoaderStartUpModule.php

示例3: getModuleRegistrations

 /**
  * Gets registration code for all modules
  *
  * @param $context ResourceLoaderContext object
  * @return String: JavaScript code for registering all modules with the client loader
  */
 public static function getModuleRegistrations(ResourceLoaderContext $context)
 {
     global $wgCacheEpoch;
     wfProfileIn(__METHOD__);
     $out = '';
     $registrations = array();
     $resourceLoader = $context->getResourceLoader();
     $target = $context->getRequest()->getVal('target', 'desktop');
     // Register sources
     $out .= ResourceLoader::makeLoaderSourcesScript($resourceLoader->getSources());
     // Register modules
     foreach ($resourceLoader->getModuleNames() as $name) {
         $module = $resourceLoader->getModule($name);
         $moduleTargets = $module->getTargets();
         if (!in_array($target, $moduleTargets)) {
             continue;
         }
         $deps = $module->getDependencies();
         $group = $module->getGroup();
         $source = $module->getSource();
         // Support module loader scripts
         $loader = $module->getLoaderScript();
         if ($loader !== false) {
             $version = wfTimestamp(TS_ISO_8601_BASIC, $module->getModifiedTime($context));
             $out .= ResourceLoader::makeCustomLoaderScript($name, $version, $deps, $group, $source, $loader);
             continue;
         }
         // Automatically register module
         // 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, $wgCacheEpoch));
         // Modules without dependencies, a group or a foreign source pass two arguments (name, timestamp) to
         // mw.loader.register()
         if (!count($deps) && $group === null && $source === 'local') {
             $registrations[] = array($name, $mtime);
         } elseif ($group === null && $source === 'local') {
             $registrations[] = array($name, $mtime, $deps);
         } elseif ($source === 'local') {
             $registrations[] = array($name, $mtime, $deps, $group);
         } else {
             $registrations[] = array($name, $mtime, $deps, $group, $source);
         }
     }
     $out .= ResourceLoader::makeLoaderRegisterScript($registrations);
     wfProfileOut(__METHOD__);
     return $out;
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:54,代码来源:ResourceLoaderStartUpModule.php

示例4: getModuleRegistrations

 /**
  * Gets registration code for all modules
  *
  * @param $context ResourceLoaderContext object
  * @return String: JavaScript code for registering all modules with the client loader
  */
 public static function getModuleRegistrations(ResourceLoaderContext $context)
 {
     global $wgCacheEpoch;
     wfProfileIn(__METHOD__);
     $out = '';
     $registrations = array();
     $resourceLoader = $context->getResourceLoader();
     // Register sources
     $out .= $resourceLoader->makeLoaderSourcesScript($resourceLoader->getSources());
     // Register modules
     foreach ($resourceLoader->getModuleNames() as $name) {
         $module = $resourceLoader->getModule($name);
         // Support module loader scripts
         //die("get loader code@!");
         $loader = $module->getLoaderScript();
         if ($loader !== false) {
             $deps = $module->getDependencies();
             $group = $module->getGroup();
             $source = $module->getSource();
             $version = wfTimestamp(TS_ISO_8601_BASIC, $module->getModifiedTime($context));
             $out .= ResourceLoader::makeCustomLoaderScript($name, $version, $deps, $group, $source, $loader);
         } else {
             // 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 = $moduleMtime;
             // Modules without dependencies, a group or a foreign source pass two arguments (name, timestamp) to
             // mw.loader.register()
             if (!count($module->getDependencies() && $module->getGroup() === null && $module->getSource() === 'local')) {
                 $registrations[] = array($name, $mtime);
             } elseif ($module->getGroup() === null && $module->getSource() === 'local') {
                 $registrations[] = array($name, $mtime, $module->getDependencies());
             } elseif ($module->getSource() === 'local') {
                 $registrations[] = array($name, $mtime, $module->getDependencies(), $module->getGroup());
             } else {
                 $registrations[] = array($name, $mtime, $module->getDependencies(), $module->getGroup(), $module->getSource());
             }
         }
     }
     global $wgScriptCacheDirectory, $wgMwEmbedVersion;
     $cachePath = $wgScriptCacheDirectory . '/registrations.' . $wgMwEmbedVersion . $_GET['skin'] . $_GET['lang'] . '.min.json';
     @file_put_contents($cachePath, json_encode($registrations));
     $out .= ResourceLoader::makeLoaderRegisterScript($registrations);
     wfProfileOut(__METHOD__);
     return $out;
 }
开发者ID:hipstern,项目名称:mwEmbed,代码行数:52,代码来源:ResourceLoaderStartUpModule.php

示例5: getModuleRegistrations

 /**
  * Get registration code for all modules.
  *
  * @param ResourceLoaderContext $context object
  * @return string JavaScript code for registering all modules with the client loader
  */
 public static function getModuleRegistrations(ResourceLoaderContext $context)
 {
     global $wgCacheEpoch;
     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;
         }
         // 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, $wgCacheEpoch));
         // FIXME: Convert to numbers, wfTimestamp always gives us stings, even for TS_UNIX
         $registryData[$name] = array('version' => $mtime, 'dependencies' => $module->getDependencies(), 'group' => $module->getGroup(), 'source' => $module->getSource(), 'loader' => $module->getLoaderScript());
     }
     // 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') {
             // Modules without dependencies, a group or a foreign source;
             // call mw.loader.register(name, timestamp)
             $registrations[] = array($name, $data['version']);
         } elseif ($data['group'] === null && $data['source'] === 'local') {
             // Modules with dependencies but no group or foreign source;
             // call mw.loader.register(name, timestamp, dependencies)
             $registrations[] = array($name, $data['version'], $data['dependencies']);
         } elseif ($data['source'] === 'local') {
             // Modules with a group but no foreign source;
             // call mw.loader.register(name, timestamp, dependencies, group)
             $registrations[] = array($name, $data['version'], $data['dependencies'], $data['group']);
         } else {
             // Modules with a foreign source;
             // call mw.loader.register(name, timestamp, dependencies, group, source)
             $registrations[] = array($name, $data['version'], $data['dependencies'], $data['group'], $data['source']);
         }
     }
     // Register modules
     $out .= ResourceLoader::makeLoaderRegisterScript($registrations);
     wfProfileOut(__METHOD__);
     return $out;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:61,代码来源:ResourceLoaderStartUpModule.php

示例6: 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)
 {
     $resourceLoader = $context->getResourceLoader();
     $target = $context->getRequest()->getVal('target', 'desktop');
     // Bypass target filter if this request is from a unit test context. To prevent misuse in
     // production, this is only allowed if testing is enabled server-side.
     $byPassTargetFilter = $this->getConfig()->get('EnableJavaScriptTest') && $target === 'test';
     $out = '';
     $registryData = array();
     // Get registry data
     foreach ($resourceLoader->getModuleNames() as $name) {
         $module = $resourceLoader->getModule($name);
         $moduleTargets = $module->getTargets();
         if (!$byPassTargetFilter && !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;
         }
         $versionHash = $module->getVersionHash($context);
         if (strlen($versionHash) !== 8) {
             // Module implementation either broken or deviated from ResourceLoader::makeHash
             // Asserted by tests/phpunit/structure/ResourcesTest.
             $versionHash = ResourceLoader::makeHash($versionHash);
         }
         $skipFunction = $module->getSkipFunction();
         if ($skipFunction !== null && !ResourceLoader::inDebugMode()) {
             $skipFunction = $resourceLoader->filter('minify-js', $skipFunction, false);
         }
         $registryData[$name] = array('version' => $versionHash, 'dependencies' => $module->getDependencies($context), '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, $data['version'], $data['dependencies'], $data['group'], $data['source'], $data['loader']);
             continue;
         }
         // Call mw.loader.register(name, version, dependencies, group, source, skip)
         $registrations[] = array($name, $data['version'], $data['dependencies'], $data['group'], $data['source'] === 'local' ? null : $data['source'], $data['skip']);
     }
     // Register modules
     $out .= "\n" . ResourceLoader::makeLoaderRegisterScript($registrations);
     return $out;
 }
开发者ID:rugby110,项目名称:mediawiki,代码行数:58,代码来源:ResourceLoaderStartUpModule.php

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

示例8: 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)
 {
     $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;
         }
         // Coerce module timestamp to UNIX timestamp.
         // getModifiedTime() is supposed to return a UNIX timestamp, but custom implementations
         // might forget. TODO: Maybe emit warning?
         $moduleMtime = wfTimestamp(TS_UNIX, $module->getModifiedTime($context));
         $skipFunction = $module->getSkipFunction();
         if ($skipFunction !== null && !ResourceLoader::inDebugMode()) {
             $skipFunction = $resourceLoader->filter('minify-js', $skipFunction, false);
         }
         $mtime = max($moduleMtime, wfTimestamp(TS_UNIX, $this->getConfig()->get('CacheEpoch')));
         $registryData[$name] = array('version' => (int) $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, $data['version'], $data['dependencies'], $data['group'], $data['source'], $data['loader']);
             continue;
         }
         // Call mw.loader.register(name, timestamp, dependencies, group, source, skip)
         $registrations[] = array($name, $data['version'], $data['dependencies'], $data['group'], $data['source'] === 'local' ? null : $data['source'], $data['skip']);
     }
     // Register modules
     $out .= ResourceLoader::makeLoaderRegisterScript($registrations);
     return $out;
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:54,代码来源:ResourceLoaderStartUpModule.php


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