Commit 3ca7d0bb authored by Christian Kuhn's avatar Christian Kuhn Committed by Andreas Fernandez
Browse files

[BUGFIX] Select icon added via pageTsConfig not shown

Fix for issue #78628 fixed "addItems" for TCA trees, but broke them
for select drop downs. Juggle icon providing around a bit to fix.

Change-Id: I3a1077992a7db0d72bc2d7d0247292763cc25958
Resolves: #78747
Related: #78628
Releases: master
Reviewed-on: https://review.typo3.org/51766

Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Mona Muzaffar's avatarMona Muzaffar <mona.muzaffar@gmx.de>
Tested-by: Mona Muzaffar's avatarMona Muzaffar <mona.muzaffar@gmx.de>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <typo3@scripting-base.de>
parent adb45e1d
......@@ -120,8 +120,6 @@ abstract class AbstractItemProvider
{
$table = $result['tableName'];
$iconRegistry = GeneralUtility::makeInstance(IconRegistry::class);
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
if (!empty($result['pageTsConfig']['TCEFORM.'][$table . '.'][$fieldName . '.']['addItems.'])
&& is_array($result['pageTsConfig']['TCEFORM.'][$table . '.'][$fieldName . '.']['addItems.'])
) {
......@@ -132,7 +130,7 @@ abstract class AbstractItemProvider
continue;
}
// Check if value "34 = mylabel" also has a "34.icon = myImage.png"
$icon = null;
$iconIdentifier = null;
if (isset($addItemsArray[$value . '.'])
&& is_array($addItemsArray[$value . '.'])
&& !empty($addItemsArray[$value . '.']['icon'])
......@@ -155,9 +153,8 @@ abstract class AbstractItemProvider
);
}
}
$icon = $iconFactory->getIcon($iconIdentifier, Icon::SIZE_SMALL)->getMarkup('inline');
}
$items[] = [$label, $value, $icon];
$items[] = [$label, $value, $iconIdentifier];
}
}
return $items;
......
......@@ -15,6 +15,8 @@ namespace TYPO3\CMS\Backend\Form\FormDataProvider;
*/
use TYPO3\CMS\Backend\Form\FormDataProviderInterface;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Tree\TableConfiguration\ExtJsArrayTreeRenderer;
use TYPO3\CMS\Core\Tree\TableConfiguration\TableConfigurationTree;
use TYPO3\CMS\Core\Tree\TableConfiguration\TreeDataProviderFactory;
......@@ -91,15 +93,26 @@ class TcaSelectTreeItems extends AbstractItemProvider implements FormDataProvide
// "static" and "dynamic" is separated since the tree code only copes with "real" existing foreign nodes,
// so this "static" stuff allows defining tree items that don't really exist in the tree.
$itemsFromTca = $this->sanitizeItemArray($fieldConfig['config']['items'], $table, $fieldName);
// List of additional items defined by page ts config "addItems"
$itemsFromPageTsConfig = $this->addItemsFromPageTsConfig($result, $fieldName, []);
if (!empty($itemsFromTca) || !empty($itemsFromPageTsConfig)) {
// Resolve pageTsConfig item icons to markup
$iconFactory = GeneralUtility::makeInstance(IconFactory::class);
$finalPageTsConfigItems = [];
foreach ($itemsFromPageTsConfig as $item) {
if ($item[2] !== null) {
$item[2] = $iconFactory->getIcon($item[2], Icon::SIZE_SMALL)->getMarkup('inline');
}
$finalPageTsConfigItems[] = $item;
}
if (!empty($itemsFromTca) || !empty($finalPageTsConfigItems)) {
// First apply "keepItems" to $itemsFromTca, this will restrict the tca item list to only
// those items that are defined in page ts "keepItems" if given
$itemsFromTca = $this->removeItemsByKeepItemsPageTsConfig($result, $fieldName, $itemsFromTca);
// Then, merge the items from page ts "addItems" into item list, since "addItems" should
// add additional items even if they are not in the "keepItems" list
$staticItems = array_merge($itemsFromTca, $itemsFromPageTsConfig);
$staticItems = array_merge($itemsFromTca, $finalPageTsConfigItems);
// Now apply page ts config "removeItems", so this is *after* addItems, so "removeItems" could
// possibly remove items again that were added via "addItems"
$staticItems = $this->removeItemsByRemoveItemsPageTsConfig($result, $fieldName, $staticItems);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment