mirror of
https://github.com/joomla/joomla-cms.git
synced 2024-06-16 09:02:52 +00:00
Fix for the title of a loaded module is not visible (#39839)
* Fix default style for "load module" plugin * Fix default style for "load module" plugin * Fix default style for "load module" plugin, performance * Fix default style for "load module" plugin, deprecation * Fix default style for "load module" plugin, remove unused * phpcs * Update plugins/content/loadmodule/loadmodule.xml Co-authored-by: Brian Teeman <brian@teeman.net> --------- Co-authored-by: Brian Teeman <brian@teeman.net>
This commit is contained in:
parent
b6ff47e6bf
commit
5fd5edfc45
|
@ -16,7 +16,7 @@ $module = $displayData['module'];
|
|||
$params = $displayData['params'];
|
||||
?>
|
||||
<table
|
||||
class="moduletable <?php echo htmlspecialchars($params->get('moduleclass_sfx'), ENT_COMPAT, 'UTF-8'); ?>">
|
||||
class="moduletable <?php echo htmlspecialchars($params->get('moduleclass_sfx', ''), ENT_COMPAT, 'UTF-8'); ?>">
|
||||
<?php if ((bool) $module->showtitle) : ?>
|
||||
<tr>
|
||||
<th>
|
||||
|
|
|
@ -54,22 +54,23 @@ class PlgContentLoadmodule extends CMSPlugin
|
|||
return;
|
||||
}
|
||||
|
||||
// Simple performance check to determine whether bot should process further
|
||||
if (strpos($article->text, 'loadposition') === false && strpos($article->text, 'loadmodule') === false) {
|
||||
return;
|
||||
$defaultStyle = $this->params->get('style', 'none');
|
||||
|
||||
// Fallback xhtml (used in Joomla 3) to html5
|
||||
if ($defaultStyle === 'xhtml') {
|
||||
$defaultStyle = 'html5';
|
||||
}
|
||||
|
||||
// Expression to search for (positions)
|
||||
$regex = '/{loadposition\s(.*?)}/i';
|
||||
$style = $this->params->def('style', 'none');
|
||||
|
||||
// Expression to search for(modules)
|
||||
$regexmod = '/{loadmodule\s(.*?)}/i';
|
||||
$stylemod = $this->params->def('style', 'none');
|
||||
|
||||
// Expression to search for(id)
|
||||
$regexmodid = '/{loadmoduleid\s([1-9][0-9]*)}/i';
|
||||
|
||||
if (str_contains($article->text, '{loadposition ')) {
|
||||
// Find all instances of plugin and put in $matches for loadposition
|
||||
// $matches[0] is full pattern match, $matches[1] is the position
|
||||
preg_match_all($regex, $article->text, $matches, PREG_SET_ORDER);
|
||||
|
@ -81,7 +82,7 @@ class PlgContentLoadmodule extends CMSPlugin
|
|||
|
||||
// We may not have a module style so fall back to the plugin default.
|
||||
if (!array_key_exists(1, $matcheslist)) {
|
||||
$matcheslist[1] = $style;
|
||||
$matcheslist[1] = $defaultStyle;
|
||||
}
|
||||
|
||||
$position = trim($matcheslist[0]);
|
||||
|
@ -93,11 +94,11 @@ class PlgContentLoadmodule extends CMSPlugin
|
|||
if (($start = strpos($article->text, $match[0])) !== false) {
|
||||
$article->text = substr_replace($article->text, $output, $start, strlen($match[0]));
|
||||
}
|
||||
|
||||
$style = $this->params->def('style', 'none');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (str_contains($article->text, '{loadmodule ')) {
|
||||
// Find all instances of plugin and put in $matchesmod for loadmodule
|
||||
preg_match_all($regexmod, $article->text, $matchesmod, PREG_SET_ORDER);
|
||||
|
||||
|
@ -117,7 +118,7 @@ class PlgContentLoadmodule extends CMSPlugin
|
|||
}
|
||||
|
||||
// Third parameter is the module style, (fallback is the plugin default set earlier).
|
||||
$stylemod = '';
|
||||
$stylemod = $defaultStyle;
|
||||
|
||||
if (array_key_exists(2, $matchesmodlist)) {
|
||||
$stylemod = trim($matchesmodlist[2]);
|
||||
|
@ -129,11 +130,11 @@ class PlgContentLoadmodule extends CMSPlugin
|
|||
if (($start = strpos($article->text, $matchmod[0])) !== false) {
|
||||
$article->text = substr_replace($article->text, $output, $start, strlen($matchmod[0]));
|
||||
}
|
||||
|
||||
$stylemod = $this->params->def('style', 'none');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (str_contains($article->text, '{loadmoduleid ')) {
|
||||
// Find all instances of plugin and put in $matchesmodid for loadmoduleid
|
||||
preg_match_all($regexmodid, $article->text, $matchesmodid, PREG_SET_ORDER);
|
||||
|
||||
|
@ -147,8 +148,7 @@ class PlgContentLoadmodule extends CMSPlugin
|
|||
if (($start = strpos($article->text, $match[0])) !== false) {
|
||||
$article->text = substr_replace($article->text, $output, $start, strlen($match[0]));
|
||||
}
|
||||
|
||||
$style = $this->params->def('style', 'none');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +165,6 @@ class PlgContentLoadmodule extends CMSPlugin
|
|||
*/
|
||||
protected function _load($position, $style = 'none')
|
||||
{
|
||||
self::$modules[$position] = '';
|
||||
$document = Factory::getDocument();
|
||||
$renderer = $document->loadRenderer('module');
|
||||
$modules = ModuleHelper::getModules($position);
|
||||
|
@ -176,9 +175,7 @@ class PlgContentLoadmodule extends CMSPlugin
|
|||
echo $renderer->render($module, $params);
|
||||
}
|
||||
|
||||
self::$modules[$position] = ob_get_clean();
|
||||
|
||||
return self::$modules[$position];
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -195,7 +192,6 @@ class PlgContentLoadmodule extends CMSPlugin
|
|||
*/
|
||||
protected function _loadmod($module, $title, $style = 'none')
|
||||
{
|
||||
self::$mods[$module] = '';
|
||||
$document = Factory::getDocument();
|
||||
$renderer = $document->loadRenderer('module');
|
||||
$mod = ModuleHelper::getModule($module, $title);
|
||||
|
@ -214,9 +210,7 @@ class PlgContentLoadmodule extends CMSPlugin
|
|||
echo $renderer->render($mod, $params);
|
||||
}
|
||||
|
||||
self::$mods[$module] = ob_get_clean();
|
||||
|
||||
return self::$mods[$module];
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -230,7 +224,6 @@ class PlgContentLoadmodule extends CMSPlugin
|
|||
*/
|
||||
protected function _loadid($id)
|
||||
{
|
||||
self::$modules[$id] = '';
|
||||
$document = Factory::getDocument();
|
||||
$renderer = $document->loadRenderer('module');
|
||||
$modules = ModuleHelper::getModuleById($id);
|
||||
|
@ -241,8 +234,6 @@ class PlgContentLoadmodule extends CMSPlugin
|
|||
echo $renderer->render($modules, $params);
|
||||
}
|
||||
|
||||
self::$modules[$id] = ob_get_clean();
|
||||
|
||||
return self::$modules[$id];
|
||||
return ob_get_clean();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,14 +23,15 @@
|
|||
name="style"
|
||||
type="list"
|
||||
label="PLG_LOADMODULE_FIELD_STYLE_LABEL"
|
||||
default="table"
|
||||
default="none"
|
||||
validate="options"
|
||||
>
|
||||
<option value="table">PLG_LOADMODULE_FIELD_VALUE_TABLE</option>
|
||||
<option value="horz">PLG_LOADMODULE_FIELD_VALUE_HORIZONTAL</option>
|
||||
<option value="xhtml">PLG_LOADMODULE_FIELD_VALUE_DIVS</option>
|
||||
<option value="rounded">PLG_LOADMODULE_FIELD_VALUE_MULTIPLEDIVS</option>
|
||||
<option value="none">PLG_LOADMODULE_FIELD_VALUE_RAW</option>
|
||||
<option value="html5">PLG_LOADMODULE_FIELD_VALUE_DIVS</option>
|
||||
<option value="table">PLG_LOADMODULE_FIELD_VALUE_TABLE</option>
|
||||
<!-- @TODO: The following styles don't exist in default installation and can be removed in Joomla 5 -->
|
||||
<option value="horz">PLG_LOADMODULE_FIELD_VALUE_HORIZONTAL</option>
|
||||
<option value="rounded">PLG_LOADMODULE_FIELD_VALUE_MULTIPLEDIVS</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
|
|
Loading…
Reference in New Issue
Block a user