Skip to content

Commit

Permalink
[BUGFIX] Make IconWizard compatible with v11
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminkott committed Jun 30, 2023
1 parent f0bec8a commit 5548340
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions Classes/Form/FieldWizard/IconWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use BK2K\BootstrapPackage\Service\IconService;
use TYPO3\CMS\Backend\Form\AbstractNode;
use TYPO3\CMS\Backend\Form\Utility\FormEngineUtility;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class IconWizard extends AbstractNode
Expand All @@ -32,6 +33,14 @@ public function render(): array
$selectItems = $parameterArray['fieldConf']['config']['items'];
$selectItemCounter = 0;
foreach ($selectItems as $item) {
if ((new Typo3Version())->getMajorVersion() < 12) {
$item = [
'label' => $item[0] ?? '',
'value' => $item[1] ?? '',
'icon' => $item[2] ?? '',
];
}

if ($item['value'] === '--div--') {
continue;
}
Expand Down Expand Up @@ -64,16 +73,31 @@ public function render(): array

$html = [];
if (count($selectIcons) > 0) {
$html[] = '<div class="t3js-forms-select-single-icons form-wizard-icon-list">';
foreach ($selectIcons as $i => $selectIcon) {
$active = $selectIcon['active'] ? ' active' : '';
$html[] = '<div class="form-wizard-icon-list-item">';
$html[] = '<a class="' . $active . '" href="#" title="' . htmlspecialchars($selectIcon['title'], ENT_COMPAT, 'UTF-8', false) . '" data-select-index="' . htmlspecialchars((string)$selectIcon['index']) . '">';
$html[] = $selectIcon['icon'];
$html[] = '</a>';
if ((new Typo3Version())->getMajorVersion() < 12) {
$html[] = '<div class="t3js-forms-select-single-icons icon-list">';
$html[] = '<div class="row">';
foreach ($selectIcons as $selectIcon) {
$active = $selectIcon['active'] ? ' active' : '';
$html[] = '<div class="col col-auto item' . $active . '">';
$html[] = '<a href="#" title="' . htmlspecialchars($selectIcon['title'], ENT_COMPAT, 'UTF-8', false) . '" data-select-index="' . htmlspecialchars((string)$selectIcon['index']) . '">';
$html[] = $selectIcon['icon'];
$html[] = '</a>';
$html[] = '</div>';
}
$html[] = '</div>';
$html[] = '</div>';
} else {
$html[] = '<div class="t3js-forms-select-single-icons form-wizard-icon-list">';
foreach ($selectIcons as $selectIcon) {
$active = $selectIcon['active'] ? ' active' : '';
$html[] = '<div class="form-wizard-icon-list-item">';
$html[] = '<a class="' . $active . '" href="#" title="' . htmlspecialchars($selectIcon['title'], ENT_COMPAT, 'UTF-8', false) . '" data-select-index="' . htmlspecialchars((string)$selectIcon['index']) . '">';
$html[] = $selectIcon['icon'];
$html[] = '</a>';
$html[] = '</div>';
}
$html[] = '</div>';
}
$html[] = '</div>';
}

$result['html'] = implode(LF, $html);
Expand Down

0 comments on commit 5548340

Please sign in to comment.