2 namespace TYPO3\CMS\Extensionmanager\ViewHelpers\Form;
31 'int' =>
'renderIntegerField',
32 'int+' =>
'renderPositiveIntegerField',
33 'integer' =>
'renderIntegerField',
34 'color' =>
'renderColorPicker',
35 'wrap' =>
'renderWrapField',
36 'offset' =>
'renderOffsetField',
37 'options' =>
'renderOptionSelect',
38 'boolean' =>
'renderCheckbox',
39 'user' =>
'renderUserFunction',
40 'small' =>
'renderSmallTextField',
41 'string' =>
'renderTextField',
42 'input' =>
'renderTextField',
43 'default' =>
'renderTextField'
58 parent::initializeArguments();
70 public function render(\TYPO3\CMS\Extensionmanager\Domain\Model\ConfigurationItem $configuration)
73 if (isset($this->viewHelperMapping[$configuration->getType()]) && method_exists($this, $this->viewHelperMapping[$configuration->getType()])) {
74 $input = $this->{$this->viewHelperMapping[$configuration->getType()]}($configuration);
76 $input = $this->{$this->viewHelperMapping[
'default']}($configuration);
88 protected function renderColorPicker(\TYPO3\CMS\Extensionmanager\Domain\Model\ConfigurationItem $configuration)
90 $elementId =
'em-' . $configuration->getName();
91 $elementName = $this->
getName($configuration);
94 $this->tag->setTagName(
'input');
95 $this->tag->addAttribute(
'type',
'text');
96 $this->tag->addAttribute(
'id', $elementId);
97 $this->tag->addAttribute(
'name', $elementName);
98 $this->tag->addAttribute(
'data-formengine-input-name', $elementName);
99 $this->tag->addAttribute(
'class',
'form-control');
100 if ($configuration->getValue() !== null) {
101 $this->tag->addAttribute(
'value', $configuration->getValue());
106 'formName' =>
'configurationform',
107 'itemName' => $elementName,
111 'vHWin=window.open(' .
113 '\'popUpem-
' . GeneralUtility::shortmd5($elementName) . '\
',' .
114 '\'height=400,width=400,status=0,menubar=0,scrollbars=1\
'' .
120 $output =
'<div class="form-wizards-wrap form-wizards-aside">'
121 .
'<div class="form-wizards-element">' . $this->tag->render() .
'</div>'
122 .
'<div class="form-wizards-items"><a href="#" onClick="' . htmlspecialchars($onClick) .
'" class="btn btn-default"><span class="t3-icon fa fa-eyedropper"></span></a></div>'
134 protected function renderOffsetField(\TYPO3\CMS\Extensionmanager\Domain\Model\ConfigurationItem $configuration)
136 $this->tag->setTagName(
'input');
137 $this->tag->addAttribute(
'type',
'text');
138 $this->tag->addAttribute(
'id',
'em-' . $configuration->getName());
139 $this->tag->addAttribute(
'name', $this->
getName($configuration));
140 $this->tag->addAttribute(
'class',
'form-control t3js-emconf-offset');
141 if ($configuration->getValue() !== null) {
142 $this->tag->addAttribute(
'value', $configuration->getValue());
144 return $this->tag->render();
153 protected function renderWrapField(\TYPO3\CMS\Extensionmanager\Domain\Model\ConfigurationItem $configuration)
155 $this->tag->setTagName(
'input');
156 $this->tag->addAttribute(
'type',
'text');
157 $this->tag->addAttribute(
'id',
'em-' . $configuration->getName());
158 $this->tag->addAttribute(
'name', $this->
getName($configuration));
159 $this->tag->addAttribute(
'class',
'form-control t3js-emconf-wrap');
160 if ($configuration->getValue() !== null) {
161 $this->tag->addAttribute(
'value', $configuration->getValue());
163 return $this->tag->render();
172 protected function renderOptionSelect(\TYPO3\CMS\Extensionmanager\Domain\Model\ConfigurationItem $configuration)
174 $this->tag->setTagName(
'select');
175 $this->tag->addAttribute(
'id',
'em-' . $configuration->getName());
176 $this->tag->addAttribute(
'name', $this->
getName($configuration));
177 $this->tag->addAttribute(
'class',
'form-control');
178 $optionValueArray = $configuration->getGeneric();
180 foreach ($optionValueArray as $label => $value) {
181 $output .=
'<option value="' . htmlspecialchars($value) .
'"';
182 if ($configuration->getValue() == $value) {
183 $output .=
' selected="selected"';
185 $output .=
'>' .
$GLOBALS[
'LANG']->sL($label,
true) .
'</option>';
187 $this->tag->setContent($output);
188 return $this->tag->render();
199 $this->tag->setTagName(
'input');
200 $this->tag->addAttribute(
'type',
'number');
201 $this->tag->addAttribute(
'id',
'em-' . $configuration->getName());
202 $this->tag->addAttribute(
'name', $this->
getName($configuration));
203 $this->tag->addAttribute(
'class',
'form-control');
204 $this->tag->addAttribute(
'min',
'0');
205 if ($configuration->getValue() !== null) {
206 $this->tag->addAttribute(
'value', $configuration->getValue());
208 return $this->tag->render();
217 protected function renderIntegerField(\TYPO3\CMS\Extensionmanager\Domain\Model\ConfigurationItem $configuration)
219 $this->tag->setTagName(
'input');
220 $this->tag->addAttribute(
'type',
'number');
221 $this->tag->addAttribute(
'id',
'em-' . $configuration->getName());
222 $this->tag->addAttribute(
'name', $this->
getName($configuration));
223 $this->tag->addAttribute(
'class',
'form-control');
224 if ($configuration->getValue() !== null) {
225 $this->tag->addAttribute(
'value', $configuration->getValue());
227 return $this->tag->render();
236 protected function renderTextField(\TYPO3\CMS\Extensionmanager\Domain\Model\ConfigurationItem $configuration)
238 $this->tag->setTagName(
'input');
239 $this->tag->addAttribute(
'type',
'text');
240 $this->tag->addAttribute(
'id',
'em-' . $configuration->getName());
241 $this->tag->addAttribute(
'name', $this->
getName($configuration));
242 $this->tag->addAttribute(
'class',
'form-control');
243 if ($configuration->getValue() !== null) {
244 $this->tag->addAttribute(
'value', $configuration->getValue());
246 return $this->tag->render();
255 protected function renderSmallTextField(\TYPO3\CMS\Extensionmanager\Domain\Model\ConfigurationItem $configuration)
266 public function renderCheckbox(\TYPO3\CMS\Extensionmanager\Domain\Model\ConfigurationItem $configuration)
268 $this->tag->addAttribute(
'type',
'checkbox');
269 $this->tag->addAttribute(
'name', $this->
getName($configuration));
270 $this->tag->addAttribute(
'value', 1);
271 $this->tag->addAttribute(
'id',
'em-' . $configuration->getName());
272 if ($configuration->getValue() == 1) {
273 $this->tag->addAttribute(
'checked',
'checked');
276 return '<div class="checkbox">' . $hiddenField .
'<label>' . $this->tag->render() .
'</label></div>';
285 protected function renderUserFunction(\TYPO3\CMS\Extensionmanager\Domain\Model\ConfigurationItem $configuration)
287 $userFunction = $configuration->getGeneric();
288 $userFunctionParams = array(
289 'fieldName' => $this->
getName($configuration),
290 'fieldValue' => $configuration->getValue(),
291 'propertyName' => $configuration->getName()
293 return \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($userFunction, $userFunctionParams, $this,
'');
302 protected function getName(\TYPO3\CMS\Extensionmanager\Domain\Model\ConfigurationItem $configuration)
304 return 'tx_extensionmanager_tools_extensionmanagerextensionmanager[config][' . $configuration->getName() .
'][value]';
315 $hiddenFieldNames = array();
316 if ($this->viewHelperVariableContainer->exists(FormViewHelper::class,
'renderedHiddenFields')) {
317 $hiddenFieldNames = $this->viewHelperVariableContainer->get(FormViewHelper::class,
'renderedHiddenFields');
319 $fieldName = $this->
getName($configuration);
320 if (substr($fieldName, -2) ===
'[]') {
321 $fieldName = substr($fieldName, 0, -2);
323 if (!in_array($fieldName, $hiddenFieldNames)) {
324 $hiddenFieldNames[] = $fieldName;
325 $this->viewHelperVariableContainer->addOrUpdate(FormViewHelper::class,
'renderedHiddenFields', $hiddenFieldNames);
326 return '<input type="hidden" name="' . htmlspecialchars($fieldName) .
'" value="0" />';