本文整理汇总了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);
}
}
示例2: getScriptURLsForDebug
/**
* @param ResourceLoaderContext $context
* @return array
*/
public function getScriptURLsForDebug(ResourceLoaderContext $context)
{
// Bypass file module urls
return ResourceLoaderModule::getScriptURLsForDebug($context);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例7: getModifiedTime
public function getModifiedTime(ResourceLoaderContext $context)
{
return max($this->getGitHeadModifiedTime($context), $this->getMsgBlobMtime($context->getLanguage()), ResourceLoaderModule::safeFilemtime(__FILE__));
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例11: javaScriptParser
/**
* @return JSParser
*/
protected static function javaScriptParser()
{
if (!self::$jsParser) {
self::$jsParser = new JSParser();
}
return self::$jsParser;
}
示例12: isPositionDefault
public function isPositionDefault()
{
$this->loadFromDefinition();
return parent::isPositionDefault();
}
示例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;
}
示例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);
}
示例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;
}