[TASK] EXT:form - Add HTML4 / HTML5 attributes for FORM to wizard
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Classes / Domain / Model / Json / FormJsonElement.php
1 <?php
2 namespace TYPO3\CMS\Form\Domain\Model\Json;
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 /**
18 * JSON form
19 */
20 class FormJsonElement extends \TYPO3\CMS\Form\Domain\Model\Json\ContainerJsonElement {
21
22 /**
23 * The ExtJS xtype of the element
24 *
25 * @var string
26 */
27 public $xtype = 'typo3-form-wizard-elements-basic-form';
28
29 /**
30 * The configuration array for the xtype
31 *
32 * @var array
33 */
34 public $configuration = array(
35 'attributes' => array(),
36 'prefix' => 'tx_form',
37 'confirmation' => TRUE,
38 'postProcessor' => array()
39 );
40
41 /**
42 * Allowed attributes for this object
43 *
44 * @var array
45 */
46 protected $allowedAttributes = array(
47 'accesskey',
48 'class',
49 'contenteditable',
50 'contextmenu',
51 'dir',
52 'draggable',
53 'dropzone',
54 'hidden',
55 'id',
56 'lang',
57 'spellcheck',
58 'style',
59 'tabindex',
60 'title',
61 'translate',
62 /* element specific attributes */
63 'accept',
64 'accept-charset',
65 'action',
66 'autocomplete',
67 'enctype',
68 'method',
69 'novalidate'
70 );
71
72 /**
73 * Set all the parameters for this object
74 *
75 * @param array $parameters Configuration array
76 * @return void
77 * @see \TYPO3\CMS\Form\Domain\Model\Json\ContainerJsonElement::setParameters()
78 */
79 public function setParameters(array $parameters) {
80 parent::setParameters($parameters);
81 $this->setPrefix($parameters);
82 $this->setConfirmation($parameters);
83 $this->setPostProcessors($parameters);
84 }
85
86 /**
87 * Set the confirmation message boolean
88 *
89 * @param array $parameters Configuration array
90 * @return void
91 */
92 protected function setConfirmation(array $parameters) {
93 if (isset($parameters['confirmation'])) {
94 $this->configuration['confirmation'] = $parameters['confirmation'];
95 }
96 }
97
98 /**
99 * Set the post processors and their configuration
100 *
101 * @param array $parameters Configuration array
102 * @return void
103 */
104 protected function setPostProcessors(array $parameters) {
105 if (isset($parameters['postProcessor.']) && is_array($parameters['postProcessor.'])) {
106 $postProcessors = $parameters['postProcessor.'];
107 foreach ($postProcessors as $key => $postProcessorName) {
108 if ((int)$key && strpos($key, '.') === FALSE) {
109 $postProcessorConfiguration = array();
110 if (isset($postProcessors[$key . '.'])) {
111 $postProcessorConfiguration = $postProcessors[$key . '.'];
112 }
113 $this->configuration['postProcessor'][$postProcessorName] = $postProcessorConfiguration;
114 }
115 }
116 } else {
117 $this->configuration['postProcessor'] = array(
118 'mail' => array(
119 'recipientEmail' => '',
120 'senderEmail' => ''
121 )
122 );
123 }
124 }
125
126 /**
127 * Set the prefix
128 *
129 * @param array $parameters Configuration array
130 * @return void
131 */
132 protected function setPrefix(array $parameters) {
133 if (isset($parameters['prefix'])) {
134 $this->configuration['prefix'] = $parameters['prefix'];
135 }
136 }
137
138 }