‪TYPO3CMS  10.4
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 {
34  public function ‪render(): array
35  {
36  $selectIcons = [];
37  $result = $this->‪initializeResultArray();
38 
39  $parameterArray = $this->data['parameterArray'];
40  $selectItems = $parameterArray['fieldConf']['config']['items'];
41 
42  $selectItemCounter = 0;
43  foreach ($selectItems as $item) {
44  if ($item[1] === '--div--') {
45  continue;
46  }
47  $icon = !empty($item[2]) ? ‪FormEngineUtility::getIconHtml($item[2], $item[0], $item[0]) : '';
48  if ($icon) {
49  $fieldValue = $this->data['databaseRow'][$this->data['fieldName']];
50  $selectIcons[] = [
51  'title' => $item[0],
52  'active' => ($fieldValue[0] === (string)$item[1]) ? true : false,
53  'icon' => $icon,
54  'index' => $selectItemCounter,
55  ];
56  }
57  $selectItemCounter++;
58  }
59 
60  $html = [];
61  if (!empty($selectIcons)) {
62  $html[] = '<div class="t3js-forms-select-single-icons icon-list">';
63  $html[] = '<div class="row">';
64  foreach ($selectIcons as $i => $selectIcon) {
65  $active = $selectIcon['active'] ? ' active' : '';
66  $html[] = '<div class="item' . $active . '">';
67  if (is_array($selectIcon)) {
68  $html[] = '<a href="#" title="' . htmlspecialchars($selectIcon['title'], ENT_COMPAT, 'UTF-8', false) . '" data-select-index="' . htmlspecialchars((string)$selectIcon['index']) . '">';
69  $html[] = $selectIcon['icon'];
70  $html[] = '</a>';
71  }
72  $html[] = '</div>';
73  }
74  $html[] = '</div>';
75  $html[] = '</div>';
76  }
77 
78  $result['html'] = implode(LF, $html);
79  return $result;
80  }
81 }
‪TYPO3\CMS\Backend\Form\AbstractNode\initializeResultArray
‪array initializeResultArray()
Definition: AbstractNode.php:90
‪TYPO3\CMS\Backend\Form\Utility\FormEngineUtility
Definition: FormEngineUtility.php:39
‪TYPO3\CMS\Backend\Form\FieldWizard\SelectIcons\render
‪array render()
Definition: SelectIcons.php:34
‪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:121
‪TYPO3\CMS\Backend\Form\AbstractNode
Definition: AbstractNode.php:29