• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ResourceLoader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __construct

 /**
  * @param ResourceLoader $resourceLoader
  * @param WebRequest $request
  */
 public function __construct(ResourceLoader $resourceLoader, WebRequest $request)
 {
     $this->resourceLoader = $resourceLoader;
     $this->request = $request;
     $this->logger = $resourceLoader->getLogger();
     // Future developers: Avoid use of getVal() in this class, which performs
     // expensive UTF normalisation by default. Use getRawVal() instead.
     // Values here are either one of a finite number of internal IDs,
     // or previously-stored user input (e.g. titles, user names) that were passed
     // to this endpoint by ResourceLoader itself from the canonical value.
     // Values do not come directly from user input and need not match.
     // List of modules
     $modules = $request->getRawVal('modules');
     $this->modules = $modules ? self::expandModuleNames($modules) : [];
     // Various parameters
     $this->user = $request->getRawVal('user');
     $this->debug = $request->getFuzzyBool('debug', $resourceLoader->getConfig()->get('ResourceLoaderDebug'));
     $this->only = $request->getRawVal('only', null);
     $this->version = $request->getRawVal('version', null);
     $this->raw = $request->getFuzzyBool('raw');
     // Image requests
     $this->image = $request->getRawVal('image');
     $this->variant = $request->getRawVal('variant');
     $this->format = $request->getRawVal('format');
     $this->skin = $request->getRawVal('skin');
     $skinnames = Skin::getSkinNames();
     // If no skin is specified, or we don't recognize the skin, use the default skin
     if (!$this->skin || !isset($skinnames[$this->skin])) {
         $this->skin = $resourceLoader->getConfig()->get('DefaultSkin');
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:35,代码来源:ResourceLoaderContext.php


示例2: execute

 public function execute()
 {
     $result = false;
     $resourceLoader = new ResourceLoader();
     foreach ($resourceLoader->getModuleNames() as $name) {
         /** @var ResourceLoaderFileModule $module */
         $module = $resourceLoader->getModule($name);
         if (!$module || !$module instanceof ResourceLoaderFileModule) {
             continue;
         }
         $hadErrors = false;
         foreach ($module->getAllStyleFiles() as $file) {
             if ($module->getStyleSheetLang($file) !== 'less') {
                 continue;
             }
             try {
                 $compiler = ResourceLoader::getLessCompiler();
                 $compiler->compileFile($file);
             } catch (Exception $e) {
                 if (!$hadErrors) {
                     $this->error("Errors checking module {$name}:\n");
                     $hadErrors = true;
                 }
                 $this->error($e->getMessage() . "\n");
                 $result = true;
             }
         }
     }
     if (!$result) {
         $this->output("No errors found\n");
     } else {
         die(1);
     }
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:34,代码来源:checkLess.php


示例3: __construct

 /**
  * @param ResourceLoader $resourceLoader
  * @param WebRequest $request
  */
 public function __construct(ResourceLoader $resourceLoader, WebRequest $request)
 {
     $this->resourceLoader = $resourceLoader;
     $this->request = $request;
     // Interpret request
     // List of modules
     $modules = $request->getVal('modules');
     $this->modules = $modules ? self::expandModuleNames($modules) : array();
     // Various parameters
     $this->skin = $request->getVal('skin');
     $this->user = $request->getVal('user');
     $this->debug = $request->getFuzzyBool('debug', $resourceLoader->getConfig()->get('ResourceLoaderDebug'));
     $this->only = $request->getVal('only');
     $this->version = $request->getVal('version');
     $this->raw = $request->getFuzzyBool('raw');
     // Image requests
     $this->image = $request->getVal('image');
     $this->variant = $request->getVal('variant');
     $this->format = $request->getVal('format');
     $skinnames = Skin::getSkinNames();
     // If no skin is specified, or we don't recognize the skin, use the default skin
     if (!$this->skin || !isset($skinnames[$this->skin])) {
         $this->skin = $resourceLoader->getConfig()->get('DefaultSkin');
     }
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:29,代码来源:ResourceLoaderContext.php


示例4: execute

 public function execute()
 {
     $dbw = wfGetDB(DB_MASTER);
     $rl = new ResourceLoader(ConfigFactory::getDefaultInstance()->makeConfig('main'));
     $moduleNames = $rl->getModuleNames();
     $moduleList = implode(', ', array_map(array($dbw, 'addQuotes'), $moduleNames));
     $limit = max(1, intval($this->getOption('batchsize', 500)));
     $this->output("Cleaning up module_deps table...\n");
     $i = 1;
     $modDeps = $dbw->tableName('module_deps');
     do {
         // $dbw->delete() doesn't support LIMIT :(
         $where = $moduleList ? "md_module NOT IN ({$moduleList})" : '1=1';
         $dbw->query("DELETE FROM {$modDeps} WHERE {$where} LIMIT {$limit}", __METHOD__);
         $numRows = $dbw->affectedRows();
         $this->output("Batch {$i}: {$numRows} rows\n");
         $i++;
         wfWaitForSlaves();
     } while ($numRows > 0);
     $this->output("done\n");
     $this->output("Cleaning up msg_resource table...\n");
     $i = 1;
     $mrRes = $dbw->tableName('msg_resource');
     do {
         $where = $moduleList ? "mr_resource NOT IN ({$moduleList})" : '1=1';
         $dbw->query("DELETE FROM {$mrRes} WHERE {$where} LIMIT {$limit}", __METHOD__);
         $numRows = $dbw->affectedRows();
         $this->output("Batch {$i}: {$numRows} rows\n");
         $i++;
         wfWaitForSlaves();
     } while ($numRows > 0);
     $this->output("done\n");
 }
开发者ID:mb720,项目名称:mediawiki,代码行数:33,代码来源:cleanupRemovedModules.php


示例5: onResourceLoaderRegisterModules

 /**
  * @param ResourceLoader $rl
  * @return bool
  */
 public static function onResourceLoaderRegisterModules(ResourceLoader $rl)
 {
     $moduleDependencies = array('mediawiki.api', 'mediawiki.RegExp', 'mediawiki.Title', 'mediawiki.jqueryMsg', 'mediawiki.Uri', 'moment', 'jquery.jStorage', 'jquery.client', 'jquery.hidpi');
     // If EventLogging is present, add the schema as a dependency.
     if (class_exists('ResourceLoaderSchemaModule')) {
         $moduleDependencies[] = "schema.Popups";
     }
     $rl->register("ext.popups", array('scripts' => array('resources/ext.popups.core.js', 'resources/ext.popups.logger.js', 'resources/ext.popups.renderer.js', 'resources/ext.popups.renderer.article.js', 'resources/ext.popups.disablenavpop.js', 'resources/ext.popups.settings.js'), 'styles' => array('resources/ext.popups.core.less', 'resources/ext.popups.animation.less', 'resources/ext.popups.settings.less'), 'dependencies' => $moduleDependencies, 'messages' => array('popups-last-edited', "popups-settings-title", "popups-settings-description", "popups-settings-option-simple", "popups-settings-option-simple-description", "popups-settings-option-advanced", "popups-settings-option-advanced-description", "popups-settings-option-off", "popups-settings-option-off-description", "popups-settings-save", "popups-settings-cancel", "popups-settings-enable", "popups-settings-help", "popups-settings-help-ok", "popups-send-feedback"), 'remoteExtPath' => 'Popups', 'localBasePath' => __DIR__));
     return true;
 }
开发者ID:webrooms,项目名称:mediawiki-extensions-Popups,代码行数:14,代码来源:Popups.hooks.php


示例6: onResourceLoaderRegisterModules

 public static function onResourceLoaderRegisterModules(ResourceLoader &$resourceLoader)
 {
     global $wgFlowEventLogging, $wgResourceModules;
     // Only if EventLogging in Flow is enabled & EventLogging exists
     if ($wgFlowEventLogging && class_exists('ResourceLoaderSchemaModule')) {
         $resourceLoader->register('schema.FlowReplies', array('class' => 'ResourceLoaderSchemaModule', 'schema' => 'FlowReplies', 'revision' => 10561344));
         // Add as dependency to Flow JS
         $wgResourceModules['ext.flow']['dependencies'][] = 'schema.FlowReplies';
     }
     return true;
 }
开发者ID:TarLocesilion,项目名称:mediawiki-extensions-Flow,代码行数:11,代码来源:Hooks.php


示例7: resourceLoaderRegisterModules

 /**
  * ResourceLoaderRegisterModules hook
  *
  * Adds modules to ResourceLoader
  *
  * @param ResourceLoader $resourceLoader
  * @return bool
  */
 public static function resourceLoaderRegisterModules(&$resourceLoader)
 {
     global $wgAPIModules;
     if (array_key_exists('titleblacklist', $wgAPIModules)) {
         self::$modules['ext.uploadWizard']['dependencies'][] = 'mediawiki.api.titleblacklist';
     }
     if (class_exists('ResourceLoaderSchemaModule')) {
         self::$modules['ext.uploadWizard.events']['dependencies'] = array('ext.eventLogging', 'schema.UploadWizardTutorialActions', 'schema.UploadWizardUploadActions');
         self::$modules['uw.EventFlowLogger']['dependencies'] += array('ext.eventLogging', 'schema.UploadWizardStep', 'schema.UploadWizardFlowEvent', 'schema.UploadWizardErrorFlowEvent', 'schema.UploadWizardExceptionFlowEvent', 'schema.UploadWizardUploadFlowEvent');
     }
     foreach (self::$modules as $name => $resources) {
         $resourceLoader->register($name, $resources + array('localBasePath' => __DIR__, 'remoteExtPath' => 'UploadWizard'));
     }
     return true;
 }
开发者ID:robksawyer,项目名称:lathe.tools,代码行数:23,代码来源:UploadWizardHooks.php


示例8: testLessFileCompilation

 public function testLessFileCompilation()
 {
     $thisString = $this->toString();
     $this->assertTrue(is_string($this->file) && is_file($this->file) && is_readable($this->file), "{$thisString} must refer to a readable file");
     $compiler = ResourceLoader::getLessCompiler(RequestContext::getMain()->getConfig());
     $this->assertNotNull($compiler->compileFile($this->file));
 }
开发者ID:Habatchii,项目名称:wikibase-for-mediawiki,代码行数:7,代码来源:LessFileCompilationTest.php


示例9: registerAssetsManagerGroups

 protected static function registerAssetsManagerGroups(ResourceLoader $resourceLoader)
 {
     if (empty(self::$assetsManagerGroups)) {
         return true;
     }
     $assetsConfig = new AssetsConfig();
     foreach (self::$assetsManagerGroups as $moduleName => $groupName) {
         $type = $assetsConfig->getGroupType($groupName);
         $key = null;
         switch ($type) {
             case AssetsManager::TYPE_JS:
                 $key = 'scripts';
                 break;
             case AssetsManager::TYPE_CSS:
             case AssetsManager::TYPE_SCSS:
                 $key = 'styles';
                 break;
         }
         if (empty($key)) {
             // todo: log error
             continue;
         }
         $assets = $assetsConfig->resolve($groupName, false, false);
         foreach ($assets as $k => $v) {
             if (!preg_match('#^(extensions|resources|skins)/#', $v)) {
                 unset($assets[$k]);
             }
         }
         $assets = array_values($assets);
         $module = array();
         $module[$key] = $assets;
         $resourceLoader->register($moduleName, $module);
     }
     return true;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:35,代码来源:ResourceLoaderHooks.class.php


示例10: getInlineScript

 /**
  * Get contents of a javascript file for inline use.
  *
  * Roughly based MediaWiki core methods:
  * - ResourceLoader::filter()
  * - ResourceLoaderFileModule::readScriptFiles()
  *
  * @param string $name Path to file relative to /modules/inline/
  * @return string Minified script
  * @throws Exception If file doesn't exist
  */
 protected static function getInlineScript($name)
 {
     // Get file
     $filePath = __DIR__ . '/../../modules/inline/' . $name;
     if (!file_exists($filePath)) {
         throw new Exception(__METHOD__ . ": file not found: \"{$filePath}\"");
     }
     $contents = file_get_contents($filePath);
     // Try minified from cache
     $key = wfMemcKey('centralauth', 'minify-js', md5($contents));
     $cache = wfGetCache(CACHE_ANYTHING);
     $cacheEntry = $cache->get($key);
     if (is_string($cacheEntry)) {
         return $cacheEntry;
     }
     // Compute new value
     $result = '';
     try {
         $result = JavaScriptMinifier::minify($contents) . "\n/* cache key: {$key} */";
         $cache->set($key, $result);
     } catch (Exception $e) {
         MWExceptionHandler::logException($e);
         wfDebugLog('CentralAuth', __METHOD__ . ": minification failed for {$name}: {$e}");
         $result = ResourceLoader::formatException($e) . "\n" . $contents;
     }
     return $result;
 }
开发者ID:NDKilla,项目名称:mediawiki-extensions-CentralAuth,代码行数:38,代码来源:SpecialCentralAutoLogin.php


示例11: testResourceLoaderModifyMaxAge

 /**
  * @group Slow
  * @slowExecutionTime 0.01651 ms
  * @dataProvider resourceLoaderModifyMaxAgeDataProvider
  *
  * @param $timestamp int timestamp in URL
  * @param $ttl int expected caching period
  */
 public function testResourceLoaderModifyMaxAge($version, $ttl)
 {
     global $wgHooks;
     $resourceLoader = new ResourceLoader();
     $resourceLoader->register('WikiaTestModule', array('class' => 'TestResourceLoaderModule'));
     $request = new WebRequest();
     $request->setVal('modules', 'WikiaTestModule');
     $request->setVal('version', join('-', $version));
     // set up hooks
     $wgHooks['ResourceLoaderCacheControlHeaders'][] = 'ResourceLoaderTest::onResourceLoaderCacheControlHeaders';
     ob_start();
     $resourceLoader->respond(new ResourceLoaderContext($resourceLoader, $request));
     ob_end_clean();
     // hook ResourceLoaderHooks::onResourceLoaderModifyMaxAge was called
     // check modified caching period with expected one
     $this->assertEquals($ttl, self::$ttl, 'TTL should match expected value');
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:25,代码来源:ResourceLoaderTest.php


示例12: getAllModules

 /**
  * Get all registered modules from ResouceLoader.
  */
 protected static function getAllModules()
 {
     global $wgEnableJavaScriptTest;
     // Test existance of test suite files as well
     // (can't use setUp or setMwGlobals because providers are static)
     $org_wgEnableJavaScriptTest = $wgEnableJavaScriptTest;
     $wgEnableJavaScriptTest = true;
     // Initialize ResourceLoader
     $rl = new ResourceLoader();
     $modules = array();
     foreach ($rl->getModuleNames() as $moduleName) {
         $modules[$moduleName] = $rl->getModule($moduleName);
     }
     // Restore settings
     $wgEnableJavaScriptTest = $org_wgEnableJavaScriptTest;
     return array('modules' => $modules, 'resourceloader' => $rl, 'context' => new ResourceLoaderContext($rl, new FauxRequest()));
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:20,代码来源:ResourcesTest.php


示例13: test

 public function test()
 {
     $loader = new ResourceLoader();
     $definitions = new Definition($loader->load($this->source));
     foreach ($definitions->getExpectations() as $definition) {
         if (null !== $definition['type']) {
             $actual = $loader->getType($definition['uri']);
             if ($actual !== $definition['type']) {
                 throw new FailedExpectationException("Type mismatch for {$definition['uri']}. Got [{$actual}] but expected [{$definition['type']}]");
             }
         }
         $expectation = new Expectation($definition['expected']);
         if (!$expectation->assert($loader->load($definition['uri']))) {
             throw new FailedExpectationException(implode("\n", $expectation->getMessages()));
         }
     }
     return true;
 }
开发者ID:jonjitsu,项目名称:api-tester,代码行数:18,代码来源:ExpectationTester.php


示例14: getStyles

 /**
  * @param ResourceLoaderContext $context
  * @return array
  */
 public function getStyles(ResourceLoaderContext $context)
 {
     $geshi = SyntaxHighlight_GeSHi::prepare('', $this->lang);
     if (!$geshi->error) {
         $css = SyntaxHighlight_GeSHi::getCSS($geshi);
     } else {
         $css = ResourceLoader::makeComment($geshi->error());
     }
     return array('all' => $css);
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:14,代码来源:ResourceLoaderGeSHiModule.php


示例15: setUp

 protected function setUp()
 {
     parent::setUp();
     ResourceLoader::clearCache();
     $globals = [];
     foreach (self::getSettings() as $key => $value) {
         $globals['wg' . $key] = $value;
     }
     $this->setMwGlobals($globals);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:10,代码来源:ResourceLoaderTestCase.php


示例16: __construct

 public function __construct()
 {
     parent::__construct();
     $resourceLoader = new ResourceLoader();
     foreach ($resourceLoader->getModuleNames() as $name) {
         $module = $resourceLoader->getModule($name);
         if (!$module || !$module instanceof ResourceLoaderFileModule) {
             continue;
         }
         foreach ($module->getAllStyleFiles() as $styleFile) {
             // TODO (phuedx, 2014-03-19) The
             // ResourceLoaderFileModule class shouldn't
             // know how to get a file's extension.
             if ($module->getStyleSheetLang($styleFile) !== 'less') {
                 continue;
             }
             $this->addTest(new LessFileCompilationTest($styleFile, $module));
         }
     }
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:20,代码来源:LessTestSuite.php


示例17: testValidation

 public function testValidation()
 {
     $module = $this->makeModule(array('foo'));
     $rl = new ResourceLoader();
     $rl->register($module->getName(), $module);
     $blobStore = $this->makeBlobStore(array('fetchMessage'), $rl);
     $blobStore->expects($this->once())->method('fetchMessage')->will($this->returnValueMap(array(array('foo', 'en', 'Hello'))));
     $blob = $blobStore->getBlob($module, 'en');
     $this->assertEquals('{"foo":"Hello"}', $blob, 'Generated blob');
     // Now, imagine a change to the module is deployed. The module now contains
     // message 'foo' and 'bar'. While updateMessage() was not called (since no
     // message values were changed) it should detect the change in list of
     // message keys.
     $module = $this->makeModule(array('foo', 'bar'));
     $rl = new ResourceLoader();
     $rl->register($module->getName(), $module);
     $blobStore = $this->makeBlobStore(array('fetchMessage'), $rl);
     $blobStore->expects($this->exactly(2))->method('fetchMessage')->will($this->returnValueMap(array(array('foo', 'en', 'Hello'), array('bar', 'en', 'World'))));
     $blob = $blobStore->getBlob($module, 'en');
     $this->assertEquals('{"foo":"Hello","bar":"World"}', $blob, 'Updated blob');
 }
开发者ID:mb720,项目名称:mediawiki,代码行数:21,代码来源:MessageBlobStoreTest.php


示例18: testLessFile

 /**
  * @dataProvider lessProvider
  */
 public function testLessFile($lessFile)
 {
     $cssFile = substr($lessFile, 0, -4) . 'css';
     if (!file_exists($cssFile)) {
         $this->fail("No css file found to assert equal to {$lessFile}");
         return;
     }
     $expect = file_get_contents($cssFile);
     $content = file_get_contents($lessFile);
     $result = ResourceLoader::getLessCompiler(RequestContext::getMain()->getConfig())->compile($content, $lessFile);
     $this->assertEquals($expect, $result);
 }
开发者ID:Habatchii,项目名称:wikibase-for-mediawiki,代码行数:15,代码来源:ResourceLoaderLESSTest.php


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


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ResourceLoaderContext类代码示例发布时间:2022-05-23
下一篇:
PHP Resource类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap