2 namespace TYPO3\CMS\Rsaauth\Form\Element
;
5 * This file is part of the TYPO3 CMS project.
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.
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
14 * The TYPO3 project - inspiring people to share!
17 use TYPO3\CMS\Backend\Form\Element\AbstractFormElement
;
18 use TYPO3\CMS\Core\Utility\GeneralUtility
;
19 use TYPO3\CMS\Core\Utility\MathUtility
;
20 use TYPO3\CMS\Core\Utility\StringUtility
;
23 * Generation of form element of the type rsaInput
25 class RsaInputElement
extends AbstractFormElement
28 * Default field wizards enabled for this element.
32 protected $defaultFieldWizard = [
33 'otherLanguageContent' => [
34 'renderType' => 'otherLanguageContent',
36 'defaultLanguageDifferences' => [
37 'renderType' => 'defaultLanguageDifferences',
39 'otherLanguageContent',
45 * This will render a single-line input form field, possibly with various control/validation features
47 * @return array As defined in initializeResultArray() of AbstractNode
49 public function render()
51 $fieldName = $this->data
['fieldName'];
52 $parameterArray = $this->data
['parameterArray'];
53 $resultArray = $this->initializeResultArray();
54 $resultArray['requireJsModules'] = ['TYPO3/CMS/Rsaauth/RsaEncryptionModule'];
56 $itemValue = $parameterArray['itemFormElValue'] ?
'*********' : '';
57 $config = $parameterArray['fieldConf']['config'];
58 $size = MathUtility
::forceIntegerInRange($config['size'] ?
: $this->defaultInputWidth
, $this->minimumInputWidth
, $this->maxInputWidth
);
59 $evalList = GeneralUtility
::trimExplode(',', $config['eval'], true);
60 $width = (int)$this->formMaxWidth($size);
62 if ($config['readOnly']) {
64 $html[] = '<div class="t3js-formengine-field-item">';
65 $html[] = '<div class="form-wizards-wrap">';
66 $html[] = '<div class="form-wizards-element">';
67 $html[] = '<div class="form-control-wrap" style="max-width: ' . $width . 'px">';
68 $html[] = '<input class="form-control" value="' . htmlspecialchars($itemValue) . '" type="text" disabled>';
73 $resultArray['html'] = implode(LF
, $html);
77 // @todo: The whole eval handling is a mess and needs refactoring
78 foreach ($evalList as $func) {
79 // @todo: This is ugly: The code should find out on it's own whether a eval definition is a
80 // @todo: keyword like "date", or a class reference. The global registration could be dropped then
81 // Pair hook to the one in \TYPO3\CMS\Core\DataHandling\DataHandler::checkValue_input_Eval()
82 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func])) {
83 if (class_exists($func)) {
84 $evalObj = GeneralUtility
::makeInstance($func);
85 if (method_exists($evalObj, 'deevaluateFieldValue')) {
89 $itemValue = $evalObj->deevaluateFieldValue($_params);
91 if (method_exists($evalObj, 'returnFieldJS')) {
92 $resultArray['additionalJavaScriptPost'][] = 'TBE_EDITOR.customEvalFunctions[' . GeneralUtility
::quoteJSvalue($func) . ']'
93 . ' = function(value) {' . $evalObj->returnFieldJS() . '};';
98 $evalList = array_filter($evalList, function ($value) {
99 return $value !== 'password';
104 'id' => StringUtility
::getUniqueId('formengine-input-'),
106 'class' => implode(' ', [
111 'data-formengine-validation-rules'=> $this->getValidationDataAsJsonString($config),
112 'data-formengine-input-params' => json_encode([
113 'field' => $parameterArray['itemFormElName'],
114 'evalList' => implode(',', $evalList),
115 'is_in' => trim($config['is_in']),
117 'data-formengine-input-name' => htmlspecialchars($parameterArray['itemFormElName']),
120 if (isset($config['max']) && (int)$config['max'] > 0) {
121 $attributes['maxlength'] = (int)$config['max'];
123 if (!empty($config['placeholder'])) {
124 $attributes['placeholder'] = trim($config['placeholder']);
126 if (isset($config['autocomplete'])) {
127 $attributes['autocomplete'] = empty($config['autocomplete']) ?
'new-' . $fieldName : 'on';
129 if (in_array('password', $evalList)) {
130 $attributes['type'] = 'password';
131 $attributes['value'] = $itemValue ?
'*********' : '';
132 $attributes['autocomplete'] = 'new-' . $fieldName;
135 $legacyWizards = $this->renderWizards();
136 $legacyFieldControlHtml = implode(LF
, $legacyWizards['fieldControl']);
137 $legacyFieldWizardHtml = implode(LF
, $legacyWizards['fieldWizard']);
139 $fieldInformationResult = $this->renderFieldInformation();
140 $fieldInformationHtml = $fieldInformationResult['html'];
141 $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldInformationResult, false);
143 $fieldControlResult = $this->renderFieldControl();
144 $fieldControlHtml = $legacyFieldControlHtml . $fieldControlResult['html'];
145 $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldControlResult, false);
147 $fieldWizardResult = $this->renderFieldWizard();
148 $fieldWizardHtml = $legacyFieldWizardHtml . $fieldWizardResult['html'];
149 $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $fieldWizardResult, false);
152 $html[] = '<div class="t3js-formengine-field-item">';
153 $html[] = $fieldInformationHtml;
154 $html[] = '<div class="form-control-wrap" style="max-width: ' . $width . 'px">';
155 $html[] = '<div class="form-wizards-wrap">';
156 $html[] = '<div class="form-wizards-element">';
157 $html[] = '<input ' . GeneralUtility
::implodeAttributes($attributes, true) . ' />';
159 $html[] = ' type="hidden"';
160 $html[] = ' data-rsa-encryption=""';
161 $html[] = ' id="' . $parameterArray['itemFormElID'] . '_hidden"';
162 $html[] = ' name="' . $parameterArray['itemFormElName'] . '"';
163 $html[] = ' value="' . htmlspecialchars($itemValue) . '"';
166 $html[] = '<div class="form-wizards-items-aside">';
167 $html[] = '<div class="btn-group">';
168 $html[] = $fieldControlHtml;
171 $html[] = '<div class="form-wizards-items-bottom">';
172 $html[] = $fieldWizardHtml;
178 $resultArray['html'] = implode(LF
, $html);