‪TYPO3CMS  ‪main
SelectIcons.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
22 
28 {
32  public function ‪render(): array
33  {
34  $selectIcons = [];
35  $result = $this->‪initializeResultArray();
36 
37  $parameterArray = $this->data['parameterArray'];
38  $selectItems = $parameterArray['fieldConf']['config']['items'];
39 
40  $selectItemCounter = 0;
41  foreach ($selectItems as $item) {
42  if ($item['value'] === '--div--') {
43  continue;
44  }
45  $icon = !empty($item['icon']) ? ‪FormEngineUtility::getIconHtml($item['icon'], $item['label'], $item['label']) : '';
46  if ($icon) {
47  $fieldValue = $this->data['databaseRow'][$this->data['fieldName']];
48  $selectIcons[] = [
49  'title' => $item['label'],
50  'active' => ($fieldValue[0] ?? false) === (string)($item['value'] ?? ''),
51  'icon' => $icon,
52  'index' => $selectItemCounter,
53  ];
54  }
55  $selectItemCounter++;
56  }
57 
58  $html = [];
59  if (!empty($selectIcons)) {
60  $html[] = '<div class="t3js-forms-select-single-icons form-wizard-icon-list">';
61  foreach ($selectIcons as $i => $selectIcon) {
62  $active = $selectIcon['active'] ? ' active' : '';
63  $html[] = '<div class="form-wizard-icon-list-item">';
64  if (is_array($selectIcon)) {
65  $html[] = '<a class="' . $active . '" href="#" title="' . htmlspecialchars($selectIcon['title'], ENT_COMPAT, 'UTF-8', false) . '" data-select-index="' . htmlspecialchars((string)$selectIcon['index']) . '">';
66  $html[] = $selectIcon['icon'];
67  $html[] = '</a>';
68  }
69  $html[] = '</div>';
70  }
71  $html[] = '</div>';
72  }
73 
74  $result['html'] = implode(LF, $html);
75  return $result;
76  }
77 }
‪TYPO3\CMS\Backend\Form\FieldWizard\SelectIcons\render
‪render()
Definition: SelectIcons.php:32
‪TYPO3\CMS\Backend\Form\Utility\FormEngineUtility
Definition: FormEngineUtility.php:41
‪TYPO3\CMS\Backend\Form\FieldWizard\SelectIcons
Definition: SelectIcons.php:28
‪TYPO3\CMS\Backend\Form\FieldWizard
Definition: DefaultLanguageDifferences.php:18
‪TYPO3\CMS\Backend\Form\Utility\FormEngineUtility\getIconHtml
‪static string getIconHtml($icon, $alt='', $title='')
Definition: FormEngineUtility.php:134
‪TYPO3\CMS\Backend\Form\AbstractNode
Definition: AbstractNode.php:29
‪TYPO3\CMS\Backend\Form\AbstractNode\initializeResultArray
‪initializeResultArray()
Definition: AbstractNode.php:77