Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions joomla-cms
33 changes: 26 additions & 7 deletions libraries/src/Form/Field/TextField.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down