[BUGFIX] Fix several typos in php comments
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Form / Element / NoneElement.php
1 <?php
2 namespace TYPO3\CMS\Backend\Form\Element;
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
17 use TYPO3\CMS\Core\Utility\MathUtility;
18
19 /**
20 * None element is a "disabled" input element with formatted values if needed.
21 */
22 class NoneElement extends AbstractFormElement
23 {
24 /**
25 * Default field information enabled for this element.
26 *
27 * @var array
28 */
29 protected $defaultFieldInformation = [
30 'tcaDescription' => [
31 'renderType' => 'tcaDescription',
32 ],
33 ];
34
35 /**
36 * This will render a non-editable display of the content of the field.
37 *
38 * @return array The HTML code for the TCEform field
39 */
40 public function render(): array
41 {
42 $resultArray = $this->initializeResultArray();
43
44 $parameterArray = $this->data['parameterArray'];
45 $config = $parameterArray['fieldConf']['config'];
46 $itemValue = $parameterArray['itemFormElValue'];
47
48 if (isset($config['format']) && $config['format']) {
49 $formatOptions = $config['format.'] ?? [];
50 $itemValue = $this->formatValue($config['format'], $itemValue, $formatOptions);
51 }
52 if (!$config['pass_content']) {
53 $itemValue = htmlspecialchars($itemValue);
54 }
55
56 $cols = $config['cols'] ?: ($config['size'] ?: $this->defaultInputWidth);
57 $size = MathUtility::forceIntegerInRange($cols ?: $this->defaultInputWidth, 5, $this->maxInputWidth);
58 $width = $this->formMaxWidth($size);
59
60 $fieldInformationResult = $this->renderFieldInformation();
61 $fieldInformationHtml = $fieldInformationResult['html'];
62 $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldInformationResult, false);
63
64 $html = [];
65 $html[] = '<div class="formengine-field-item t3js-formengine-field-item">';
66 $html[] = $fieldInformationHtml;
67 $html[] = '<div class="form-wizards-wrap">';
68 $html[] = '<div class="form-wizards-element">';
69 $html[] = '<div class="form-control-wrap" style="max-width: ' . $width . 'px">';
70 $html[] = '<input class="form-control" value="' . htmlspecialchars($itemValue) . '" type="text" disabled>';
71 $html[] = '</div>';
72 $html[] = '</div>';
73 $html[] = '</div>';
74 $html[] = '</div>';
75
76 $resultArray['html'] = implode(LF, $html);
77
78 return $resultArray;
79 }
80 }