3029d60b7884b82f02c559148990f7e9e4316ef8
[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 'accept',
48 'accept-charset',
49 'action',
50 'class',
51 'dir',
52 'enctype',
53 'id',
54 'lang',
55 'method',
56 'style',
57 'title'
58 );
59
60 /**
61 * Set all the parameters for this object
62 *
63 * @param array $parameters Configuration array
64 * @return void
65 * @see \TYPO3\CMS\Form\Domain\Model\Json\ContainerJsonElement::setParameters()
66 */
67 public function setParameters(array $parameters) {
68 parent::setParameters($parameters);
69 $this->setPrefix($parameters);
70 $this->setConfirmation($parameters);
71 $this->setPostProcessors($parameters);
72 }
73
74 /**
75 * Set the confirmation message boolean
76 *
77 * @param array $parameters Configuration array
78 * @return void
79 */
80 protected function setConfirmation(array $parameters) {
81 if (isset($parameters['confirmation'])) {
82 $this->configuration['confirmation'] = $parameters['confirmation'];
83 }
84 }
85
86 /**
87 * Set the post processors and their configuration
88 *
89 * @param array $parameters Configuration array
90 * @return void
91 */
92 protected function setPostProcessors(array $parameters) {
93 if (isset($parameters['postProcessor.']) && is_array($parameters['postProcessor.'])) {
94 $postProcessors = $parameters['postProcessor.'];
95 foreach ($postProcessors as $key => $postProcessorName) {
96 if ((int)$key && strpos($key, '.') === FALSE) {
97 $postProcessorConfiguration = array();
98 if (isset($postProcessors[$key . '.'])) {
99 $postProcessorConfiguration = $postProcessors[$key . '.'];
100 }
101 $this->configuration['postProcessor'][$postProcessorName] = $postProcessorConfiguration;
102 }
103 }
104 } else {
105 $this->configuration['postProcessor'] = array(
106 'mail' => array(
107 'recipientEmail' => '',
108 'senderEmail' => ''
109 )
110 );
111 }
112 }
113
114 /**
115 * Set the prefix
116 *
117 * @param array $parameters Configuration array
118 * @return void
119 */
120 protected function setPrefix(array $parameters) {
121 if (isset($parameters['prefix'])) {
122 $this->configuration['prefix'] = $parameters['prefix'];
123 }
124 }
125
126 }