58 $elements = json_decode((
string) $json, TRUE);
59 $typoscriptArray = array();
62 if ($typoscriptArray[
'10.'] && is_array($typoscriptArray[
'10.']) && !empty($typoscriptArray[
'10.'])) {
78 if (is_array($elements)) {
80 foreach ($elements as $element) {
81 if ($element[
'xtype']) {
83 switch ($element[
'xtype']) {
84 case 'typo3-form-wizard-elements-basic-button':
86 case 'typo3-form-wizard-elements-basic-checkbox':
88 case 'typo3-form-wizard-elements-basic-fileupload':
90 case 'typo3-form-wizard-elements-basic-hidden':
92 case 'typo3-form-wizard-elements-basic-password':
94 case 'typo3-form-wizard-elements-basic-radio':
96 case 'typo3-form-wizard-elements-basic-reset':
98 case 'typo3-form-wizard-elements-basic-select':
100 case 'typo3-form-wizard-elements-basic-submit':
102 case 'typo3-form-wizard-elements-basic-textarea':
104 case 'typo3-form-wizard-elements-basic-textline':
106 case 'typo3-form-wizard-elements-predefined-email':
108 case 'typo3-form-wizard-elements-content-header':
110 case 'typo3-form-wizard-elements-content-textblock':
113 case 'typo3-form-wizard-elements-basic-fieldset':
115 case 'typo3-form-wizard-elements-predefined-name':
117 $this->
getContainer($element, $parent, $elementCounter);
119 case 'typo3-form-wizard-elements-predefined-checkboxgroup':
121 case 'typo3-form-wizard-elements-predefined-radiogroup':
123 $this->
getContainer($element, $parent, $elementCounter, TRUE);
125 case 'typo3-form-wizard-elements-basic-form':
127 $this->
getContainer($element, $parent, $elementCounter);
128 $this->
getForm($element, $parent, $elementCounter);
134 $elementCounter = $elementCounter + 10;
148 protected function getContainer(array $element, array &$parent, $elementCounter, $childrenWithParentName = FALSE) {
149 if ($element[
'elementContainer'] && $element[
'elementContainer'][
'items']) {
150 $this->
convertToTyposcriptArray($element[
'elementContainer'][
'items'], $parent[$elementCounter .
'.'], $childrenWithParentName);
166 protected function getForm(array $element, array &$parent, $elementCounter) {
168 if (!empty($this->validationRules)) {
185 protected function getDefaultElementSetup(array $element, array &$parent, $elementCounter, $childrenWithParentName = FALSE) {
187 if (is_null($contentObjectType) === FALSE) {
188 $parent[$elementCounter] = $contentObjectType;
189 $parent[$elementCounter .
'.'] = array();
190 if ($element[
'configuration']) {
191 $this->
setConfiguration($element, $parent, $elementCounter, $childrenWithParentName);
203 $contentObjectType = NULL;
204 $shortXType = str_replace(
'typo3-form-wizard-elements-',
'', $element[
'xtype']);
205 list($category, $type) = explode(
'-', $shortXType);
208 $contentObjectType = strtoupper($type);
212 case 'checkboxgroup':
215 $contentObjectType = strtoupper($type);
218 $contentObjectType =
'TEXTLINE';
221 $contentObjectType =
'FIELDSET';
229 $contentObjectType = strtoupper($type);
234 return $contentObjectType;
247 protected function setConfiguration(array $element, array &$parent, $elementCounter, $childrenWithParentName = FALSE) {
248 foreach ($element[
'configuration'] as $key => $value) {
251 $this->
setAttributes($value, $parent, $elementCounter, $childrenWithParentName);
257 $this->
setFilters($value, $parent, $elementCounter);
260 $this->
setLabel($value, $parent, $elementCounter);
263 $this->
setLayout($element, $value, $parent, $elementCounter);
266 $this->
setLegend($value, $parent, $elementCounter);
269 $this->
setOptions($element, $value, $parent, $elementCounter);
271 case 'postProcessor':
275 $this->
setPrefix($value, $parent, $elementCounter);
281 $this->
setVarious($element, $value, $parent, $elementCounter);
298 protected function setAttributes(array $attributes, array &$parent, $elementCounter, $childrenWithParentName = FALSE) {
299 foreach ($attributes as $key => $value) {
300 if ($key ===
'name' && $value ===
'' && !$childrenWithParentName) {
303 if ($value !=
'' && $key !=
'type') {
304 $parent[$elementCounter .
'.'][$key] = $value;
320 $parent[$elementCounter .
'.'][
'confirmation'] = $confirmation;
331 protected function setFilters(array $filters, array &$parent, $elementCounter) {
332 if (!empty($filters)) {
333 $parent[$elementCounter .
'.'][
'filters'] = array();
335 foreach ($filters as $name => $filterConfiguration) {
336 $parent[$elementCounter .
'.'][
'filters'][$filterCounter] = $name;
337 $parent[$elementCounter .
'.'][
'filters'][$filterCounter .
'.'] = $filterConfiguration;
351 protected function setLabel(array $label, array &$parent, $elementCounter) {
352 if ($label[
'value'] !=
'') {
353 $parent[$elementCounter .
'.'][
'label.'][
'value'] = $label[
'value'];
370 protected function setLayout(array $element, $value, array &$parent, $elementCounter) {
371 switch ($element[
'xtype']) {
372 case 'typo3-form-wizard-elements-basic-button':
374 case 'typo3-form-wizard-elements-basic-fileupload':
376 case 'typo3-form-wizard-elements-basic-password':
378 case 'typo3-form-wizard-elements-basic-reset':
380 case 'typo3-form-wizard-elements-basic-submit':
382 case 'typo3-form-wizard-elements-basic-textline':
383 if ($value ===
'back') {
384 $parent[$elementCounter .
'.'][
'layout'] =
'<input />' . chr(10) .
'<label />';
387 case 'typo3-form-wizard-elements-basic-checkbox':
389 case 'typo3-form-wizard-elements-basic-radio':
390 if ($value ===
'front') {
391 $parent[$elementCounter .
'.'][
'layout'] =
'<label />' . chr(10) .
'<input />';
394 case 'typo3-form-wizard-elements-basic-select':
395 if ($value ===
'back') {
396 $parent[$elementCounter .
'.'][
'layout'] =
'<select>' . chr(10) .
'<elements />' . chr(10) .
'</select>' . chr(10) .
'<label />';
399 case 'typo3-form-wizard-elements-basic-textarea':
400 if ($value ===
'back') {
401 $parent[$elementCounter .
'.'][
'layout'] =
'<textarea />' . chr(10) .
'<label />';
417 protected function setLegend(array $legend, array &$parent, $elementCounter) {
418 if ($legend[
'value'] !=
'') {
419 $parent[$elementCounter .
'.'][
'legend.'][
'value'] = $legend[
'value'];
436 protected function setOptions(array $element, array $options, array &$parent, $elementCounter) {
437 if (is_array($options) && $element[
'xtype'] ===
'typo3-form-wizard-elements-basic-select') {
439 foreach ($options as $option) {
440 $parent[$elementCounter .
'.'][$optionCounter] =
'OPTION';
441 $parent[$elementCounter .
'.'][$optionCounter .
'.'][
'data'] = $option[
'data'];
442 if (isset($option[
'attributes'])) {
443 $parent[$elementCounter .
'.'][$optionCounter .
'.'] += $option[
'attributes'];
445 $optionCounter = $optionCounter + 10;
458 protected function setPostProcessor(array $postProcessors, array &$parent, $elementCounter) {
459 if (!empty($postProcessors)) {
460 $parent[$elementCounter .
'.'][
'postProcessor'] = array();
461 $postProcessorCounter = 1;
462 foreach ($postProcessors as $name => $postProcessorConfiguration) {
463 $parent[$elementCounter .
'.'][
'postProcessor'][$postProcessorCounter] = $name;
464 $parent[$elementCounter .
'.'][
'postProcessor'][$postProcessorCounter .
'.'] = $postProcessorConfiguration;
465 $postProcessorCounter++;
480 protected function setPrefix($prefix, array &$parent, $elementCounter) {
481 $parent[$elementCounter .
'.'][
'prefix'] = $prefix;
495 foreach ($validationRules as $name => $ruleConfiguration) {
496 if (isset($element[
'configuration'][
'attributes'][
'name']) && $element[
'configuration'][
'attributes'][
'name'] !=
'') {
497 $ruleConfiguration[
'element'] = $element[
'configuration'][
'attributes'][
'name'];
498 } elseif (isset($element[
'configuration'][
'various'][
'name']) && $element[
'configuration'][
'various'][
'name'] !=
'') {
499 $ruleConfiguration[
'element'] = $element[
'configuration'][
'various'][
'name'];
504 $this->validationRules[$this->validationRulesCounter .
'.'] = $ruleConfiguration;
505 $this->validationRulesCounter++;
518 protected function setVarious(array $element, array $various, array &$parent, $elementCounter) {
519 foreach ($various as $key => $value) {
526 $parent[$elementCounter .
'.'][$key] = (string) $value;
545 $typoscript .= str_repeat(chr(9), $tabCount) . str_replace(
'.',
'', $addKey) .
' {' . chr(10);
548 foreach ($typoscriptArray as $key => $value) {
549 if (!is_array($value)) {
550 if (strstr($value, chr(10))) {
551 $typoscript .= str_repeat(chr(9), $tabCount) . $key .
' (' . chr(10);
552 $value = str_replace(chr(10), chr(10) . str_repeat(chr(9), ($tabCount + 1)), $value);
553 $typoscript .= str_repeat(chr(9), ($tabCount + 1)) . $value . chr(10);
554 $typoscript .= str_repeat(chr(9), $tabCount) .
')' . chr(10);
556 $typoscript .= str_repeat(chr(9), $tabCount) . $key .
' = ' . $value . chr(10);
564 $typoscript .= str_repeat(chr(9), $tabCount) .
'}' . chr(10);
getDefaultElementSetup(array $element, array &$parent, $elementCounter, $childrenWithParentName=FALSE)
setVarious(array $element, array $various, array &$parent, $elementCounter)
setPrefix($prefix, array &$parent, $elementCounter)
setConfirmation($confirmation, array &$parent, $elementCounter)
setLayout(array $element, $value, array &$parent, $elementCounter)
convertToTyposcriptArray(array $elements, array &$parent, $childrenWithParentName=FALSE)
setLabel(array $label, array &$parent, $elementCounter)
setLegend(array $legend, array &$parent, $elementCounter)
getContentObjectType(array $element)
setValidationRules(array $element, array $validationRules)
setConfiguration(array $element, array &$parent, $elementCounter, $childrenWithParentName=FALSE)
setPostProcessor(array $postProcessors, array &$parent, $elementCounter)
getForm(array $element, array &$parent, $elementCounter)
getContainer(array $element, array &$parent, $elementCounter, $childrenWithParentName=FALSE)
typoscriptArrayToString(array $typoscriptArray, $addKey='', $tabCount=-1)
setAttributes(array $attributes, array &$parent, $elementCounter, $childrenWithParentName=FALSE)
setOptions(array $element, array $options, array &$parent, $elementCounter)
setFilters(array $filters, array &$parent, $elementCounter)