TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript Class Reference
Inheritance diagram for TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript:
tx_form_Domain_Factory_JsonToTyposcript

Public Member Functions

 convert ($json)
 

Protected Member Functions

 convertToTyposcriptArray (array $elements, array &$parent, $childrenWithParentName=FALSE)
 
 getContainer (array $element, array &$parent, $elementCounter, $childrenWithParentName=FALSE)
 
 getForm (array $element, array &$parent, $elementCounter)
 
 getDefaultElementSetup (array $element, array &$parent, $elementCounter, $childrenWithParentName=FALSE)
 
 getContentObjectType (array $element)
 
 setConfiguration (array $element, array &$parent, $elementCounter, $childrenWithParentName=FALSE)
 
 setAttributes (array $attributes, array &$parent, $elementCounter, $childrenWithParentName=FALSE)
 
 setConfirmation ($confirmation, array &$parent, $elementCounter)
 
 setFilters (array $filters, array &$parent, $elementCounter)
 
 setLabel (array $label, array &$parent, $elementCounter)
 
 setLayout (array $element, $value, array &$parent, $elementCounter)
 
 setLegend (array $legend, array &$parent, $elementCounter)
 
 setOptions (array $element, array $options, array &$parent, $elementCounter)
 
 setPostProcessor (array $postProcessors, array &$parent, $elementCounter)
 
 setPrefix ($prefix, array &$parent, $elementCounter)
 
 setValidationRules (array $element, array $validationRules)
 
 setVarious (array $element, array $various, array &$parent, $elementCounter)
 
 typoscriptArrayToString (array $typoscriptArray, $addKey='', $tabCount=-1)
 

Protected Attributes

 $elementId = 0
 
 $validationRules = array()
 
 $validationRulesCounter = 1
 

Detailed Description

This file is part of the TYPO3 CMS project.

It is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, either version 2 of the License, or any later version.

For the full copyright and license information, please read the LICENSE.txt file that was distributed with this source code.

The TYPO3 project - inspiring people to share! Json to Typoscript converter

Takes the incoming Json and converts it to Typoscipt

Author
Patrick Broens patri.nosp@m.ck@p.nosp@m.atric.nosp@m.kbro.nosp@m.ens.n.nosp@m.l

Definition at line 24 of file JsonToTypoScript.php.

Member Function Documentation

◆ convert()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::convert (   $json)

Convert JSON to TypoScript

First a TypoScript array is constructed, which will be converted to a formatted string

Parameters
string$jsonJson containing all configuration for the form
Returns
string The typoscript for the form

Definition at line 57 of file JsonToTypoScript.php.

References TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\convertToTyposcriptArray(), and TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\typoscriptArrayToString().

◆ convertToTyposcriptArray()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::convertToTyposcriptArray ( array  $elements,
array &  $parent,
  $childrenWithParentName = FALSE 
)
protected

Converts the JSON array for each element to a TypoScript array and adds this Typoscript array to the parent

Parameters
array$elementsThe JSON array
array$parentThe parent element
boolean$childrenWithParentNameIndicates if the children use the parent name
Returns
void

Definition at line 77 of file JsonToTypoScript.php.

References TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\getContainer(), TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\getDefaultElementSetup(), and TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\getForm().

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\convert(), and TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\getContainer().

◆ getContainer()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::getContainer ( array  $element,
array &  $parent,
  $elementCounter,
  $childrenWithParentName = FALSE 
)
protected

Called for elements are a container for other elements like FORM and FIELDSET

Parameters
array$elementThe JSON array for this element
array$parentThe parent element
boolean$childrenWithParentNameIndicates if the children use the parent name
integer$elementCounterThe element counter
Returns
void

Definition at line 148 of file JsonToTypoScript.php.

References TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\convertToTyposcriptArray().

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\convertToTyposcriptArray().

◆ getContentObjectType()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::getContentObjectType ( array  $element)
protected

Returns the content object type which is related to the ExtJS xtype

Parameters
array$elementThe JSON array for this element
Returns
string The Content Object Type

Definition at line 202 of file JsonToTypoScript.php.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\getDefaultElementSetup().

◆ getDefaultElementSetup()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::getDefaultElementSetup ( array  $element,
array &  $parent,
  $elementCounter,
  $childrenWithParentName = FALSE 
)
protected

Called for each element

Adds the content object type to the parent array and starts adding the configuration for the element

Parameters
array$elementThe JSON array for this element
array$parentThe parent element
integer$elementCounterThe element counter
boolean$childrenWithParentNameIndicates if the children use the parent name
Returns
void

Definition at line 185 of file JsonToTypoScript.php.

References TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\getContentObjectType(), and TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\convertToTyposcriptArray().

◆ getForm()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::getForm ( array  $element,
array &  $parent,
  $elementCounter 
)
protected

Only called for the type FORM

Adds the validation rules to the form. In the wizard they are added to each element. In this script the validation rules are stored in a separate array to add them to the form at a later point.

Parameters
array$elementThe JSON array for this element
array$parentThe parent element
integer$elementCounterThe element counter
Returns
void

Definition at line 166 of file JsonToTypoScript.php.

References TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\$validationRules.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\convertToTyposcriptArray().

◆ setAttributes()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setAttributes ( array  $attributes,
array &  $parent,
  $elementCounter,
  $childrenWithParentName = FALSE 
)
protected

Set the attributes for the element

Parameters
array$attributesThe JSON array for the attributes of this element
array$parentThe parent element
integer$elementCounterThe element counter
boolean$childrenWithParentNameIndicates if the children use the parent name
Returns
void

Definition at line 298 of file JsonToTypoScript.php.

References TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\$elementId.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

◆ setConfiguration()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setConfiguration ( array  $element,
array &  $parent,
  $elementCounter,
  $childrenWithParentName = FALSE 
)
protected

◆ setConfirmation()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setConfirmation (   $confirmation,
array &  $parent,
  $elementCounter 
)
protected

Set the confirmation for the element FORM

The confirmation indicates a confirmation screen has to be displayed

Parameters
boolean$confirmationTRUE when confirmation screen
array$parentThe parent element
integer$elementCounterThe element counter
Returns
void

Definition at line 319 of file JsonToTypoScript.php.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

◆ setFilters()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setFilters ( array  $filters,
array &  $parent,
  $elementCounter 
)
protected

Set the filters for the element

Parameters
array$filtersThe JSON array for the filters of this element
array$parentThe parent element
integer$elementCounterThe element counter
Returns
void

Definition at line 331 of file JsonToTypoScript.php.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

◆ setLabel()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setLabel ( array  $label,
array &  $parent,
  $elementCounter 
)
protected

Set the label for the element

Parameters
array$labelThe JSON array for the label of this element
array$parentThe parent element
integer$elementCounterThe element counter
Returns
void

Definition at line 351 of file JsonToTypoScript.php.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

◆ setLayout()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setLayout ( array  $element,
  $value,
array &  $parent,
  $elementCounter 
)
protected

Changes the layout of some elements when this has been set in the wizard

The wizard only uses 'back' or 'front' to set the layout. The TypoScript of the form uses a XML notation for the position of the label to the field.

Parameters
array$elementThe JSON array for this element
string$valueThe layout setting, back or front
array$parentThe parent element
integer$elementCounterThe element counter
Returns
void

Definition at line 370 of file JsonToTypoScript.php.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

◆ setLegend()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setLegend ( array  $legend,
array &  $parent,
  $elementCounter 
)
protected

Set the legend for the element

Parameters
array$legendThe JSON array for the legend of this element
array$parentThe parent element
integer$elementCounterThe element counter
Returns
void

Definition at line 417 of file JsonToTypoScript.php.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

◆ setOptions()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setOptions ( array  $element,
array  $options,
array &  $parent,
  $elementCounter 
)
protected

Set the options for a SELECT

Although other elements like CHECKBOXGROUP and RADIOGROUP are using the option setting as well, they act like containers and are handled differently

Parameters
array$elementThe JSON array for this element
array$optionsThe JSON array for the options of this element
array$parentThe parent element
integer$elementCounterThe element counter
Returns
void

Definition at line 436 of file JsonToTypoScript.php.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

◆ setPostProcessor()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setPostProcessor ( array  $postProcessors,
array &  $parent,
  $elementCounter 
)
protected

Set the post processors for the element

Parameters
array$postProcessorsThe JSON array for the post processors of this element
array$parentThe parent element
integer$elementCounterThe element counter
Returns
void

Definition at line 458 of file JsonToTypoScript.php.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

◆ setPrefix()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setPrefix (   $prefix,
array &  $parent,
  $elementCounter 
)
protected

Set the prefix for the element FORM

The prefix will be used in the names of all elements in the form

Parameters
string$prefixThe prefix for all element names
array$parentThe parent element
integer$elementCounterThe element counter
Returns
void

Definition at line 480 of file JsonToTypoScript.php.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

◆ setValidationRules()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setValidationRules ( array  $element,
array  $validationRules 
)
protected

Stores the validation rules, set to the elements, in a temporary array

In the wizard the validation rules are added to the element, in TypoScript they are added to the form.

Parameters
array$elementThe JSON array for this element
array$validationRulesThe temporary storage array for the rules
Returns
void

Definition at line 494 of file JsonToTypoScript.php.

References TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\$elementId, and TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\$validationRulesCounter.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

◆ setVarious()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::setVarious ( array  $element,
array  $various,
array &  $parent,
  $elementCounter 
)
protected

Set the various configuration of an element

Parameters
array$elementThe JSON array for this element
array$optionsThe JSON array for the various options of this element
array$parentThe parent element
integer$elementCounterThe element counter
Returns
void

Definition at line 518 of file JsonToTypoScript.php.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\setConfiguration().

◆ typoscriptArrayToString()

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::typoscriptArrayToString ( array  $typoscriptArray,
  $addKey = '',
  $tabCount = -1 
)
protected

Converts a TypoScript array to a formatted string

Takes care of indentation, curly brackets and parentheses

Parameters
array$typoscriptArrayThe TypoScript array
string$addKeyKey which has underlying configuration
integer$tabCountThe amount of tabs for indentation
Returns
string The formatted TypoScript string

Definition at line 542 of file JsonToTypoScript.php.

Referenced by TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript\convert().

Member Data Documentation

◆ $elementId

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::$elementId = 0
protected

◆ $validationRules

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::$validationRules = array()
protected

◆ $validationRulesCounter

TYPO3\CMS\Form\Domain\Factory\JsonToTypoScript::$validationRulesCounter = 1
protected