TYPO3 CMS  TYPO3_8-7
RadioElement.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 {
27  protected $defaultFieldWizard = [
28  'localizationStateSelector' => [
29  'renderType' => 'localizationStateSelector',
30  ],
31  'otherLanguageContent' => [
32  'renderType' => 'otherLanguageContent',
33  'after' => [
34  'localizationStateSelector'
35  ],
36  ],
37  'defaultLanguageDifferences' => [
38  'renderType' => 'defaultLanguageDifferences',
39  'after' => [
40  'otherLanguageContent',
41  ],
42  ],
43  ];
44 
50  public function render()
51  {
52  $resultArray = $this->initializeResultArray();
53 
54  $disabled = '';
55  if ($this->data['parameterArray']['fieldConf']['config']['readOnly']) {
56  $disabled = ' disabled';
57  }
58 
59  $html = [];
60  foreach ($this->data['parameterArray']['fieldConf']['config']['items'] as $itemNumber => $itemLabelAndValue) {
61  $label = $itemLabelAndValue[0];
62  $value = $itemLabelAndValue[1];
63  $radioId = htmlspecialchars($this->data['parameterArray']['itemFormElID'] . '_' . $itemNumber);
64  $radioChecked = (string)$value === (string)$this->data['parameterArray']['itemFormElValue'] ? ' checked="checked"' : '';
65 
66  $fieldInformationResult = $this->renderFieldInformation();
67  $fieldInformationHtml = $fieldInformationResult['html'];
68  $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldInformationResult, false);
69 
70  $fieldWizardResult = $this->renderFieldWizard();
71  $fieldWizardHtml = $fieldWizardResult['html'];
72  $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldWizardResult, false);
73 
74  $html[] = '<div class="formengine-field-item t3js-formengine-field-item">';
75  if (!$disabled) {
76  $html[] = $fieldInformationHtml;
77  }
78  $html[] = '<div class="form-wizards-wrap">';
79  $html[] = '<div class="form-wizards-element">';
80  $html[] = '<div class="radio' . $disabled . '">';
81  $html[] = '<label for="' . $radioId . '">';
82  $html[] = '<input type="radio"';
83  $html[] = ' name="' . htmlspecialchars($this->data['parameterArray']['itemFormElName']) . '"';
84  $html[] = ' id="' . $radioId . '"';
85  $html[] = ' value="' . htmlspecialchars($value) . '"';
86  $html[] = $radioChecked;
87  $html[] = $disabled;
88  $html[] = ' onclick="' . htmlspecialchars(implode('', $this->data['parameterArray']['fieldChangeFunc'])) . '"';
89  $html[] = '/>';
90  $html[] = htmlspecialchars($label);
91  $html[] = '</label>';
92  $html[] = '</div>';
93  $html[] = '</div>';
94  if (!$disabled) {
95  $html[] = '<div class="form-wizards-items-bottom">';
96  $html[] = $fieldWizardHtml;
97  $html[] = '</div>';
98  }
99  $html[] = '</div>';
100  $html[] = '</div>';
101  }
102 
103  $resultArray['html'] = implode(LF, $html);
104  return $resultArray;
105  }
106 }
mergeChildReturnIntoExistingResult(array $existing, array $childReturn, bool $mergeHtml=true)