diff --git a/joomla-cms b/joomla-cms new file mode 120000 index 0000000000000..70c25a4a3eada --- /dev/null +++ b/joomla-cms @@ -0,0 +1 @@ +joomla-cms \ No newline at end of file diff --git a/libraries/src/Form/Field/TextField.php b/libraries/src/Form/Field/TextField.php index 38a0ebb297bdd..b8b11a940056c 100644 --- a/libraries/src/Form/Field/TextField.php +++ b/libraries/src/Form/Field/TextField.php @@ -14,7 +14,9 @@ use Joomla\CMS\Form\FormField; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Language\Text; +use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Uri\Uri; +use Joomla\Registry\Registry; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; @@ -218,16 +220,33 @@ public function setup(\SimpleXMLElement $element, $value, $group = null) protected function getInput() { if ($this->element['useglobal']) { - $component = Factory::getApplication()->getInput()->getCmd('option'); + if (str_starts_with((string) $this->element['useglobal'], 'com_')) { + // Get the correct component parameters + $params = ComponentHelper::getParams((string) $this->element['useglobal']); + } elseif (substr_count((string) $this->element['useglobal'], '_') === 2) { + // Get the correct plugin parameters + [$prefix, $type, $plugin] = explode('_', (string) $this->element['useglobal'], 3); + + if ($prefix === 'plg' && PluginHelper::isEnabled($type, $plugin)) { + $plugin = PluginHelper::getPlugin($type, $plugin); + $params = new Registry($plugin->params); + } + } + + if (!isset($params)) { + // Fallback for B/C + $component = Factory::getApplication()->getInput()->getCmd('option'); + + // Get correct component for menu items + if ($component === 'com_menus') { + $link = $this->form->getData()->get('link'); + $uri = new Uri($link); + $component = $uri->getVar('option', 'com_menus'); + } - // Get correct component for menu items - if ($component === 'com_menus') { - $link = $this->form->getData()->get('link'); - $uri = new Uri($link); - $component = $uri->getVar('option', 'com_menus'); + $params = ComponentHelper::getParams($component); } - $params = ComponentHelper::getParams($component); $value = $params->get($this->fieldname); // Try with global configuration