TYPO3 CMS  TYPO3_6-2
AbstractJsonElement.php
Go to the documentation of this file.
1 <?php
3 
23 
29  public $xtype = '';
30 
36  public $configuration = array();
37 
43  protected $allowedAttributes = array();
44 
52  protected $childElementsAllowed = TRUE;
53 
60  public function setParameters(array $parameters) {
61  foreach ($this->configuration as $key => $value) {
62  switch ($key) {
63  case 'attributes':
64  $this->setAttributes($parameters);
65  break;
66  case 'filters':
67  $this->setFilters($parameters);
68  break;
69  case 'label':
70  $this->setLabel($parameters);
71  break;
72  case 'layout':
73  $this->setLayout($parameters);
74  break;
75  case 'validation':
76  $this->setValidation($parameters);
77  break;
78  }
79  }
80  }
81 
87  public function childElementsAllowed() {
89  }
90 
97  protected function setAttributes(array $parameters) {
98  foreach ($this->allowedAttributes as $allowedAttribute) {
99  if (isset($parameters[$allowedAttribute])) {
100  $this->configuration['attributes'][$allowedAttribute] = $parameters[$allowedAttribute];
101  } elseif (!isset($this->configuration['attributes'][$allowedAttribute])) {
102  $this->configuration['attributes'][$allowedAttribute] = '';
103  }
104  }
105  }
106 
113  protected function setFilters(array $parameters) {
114  if (isset($parameters['filters.']) && is_array($parameters['filters.'])) {
115  $filters = $parameters['filters.'];
116  foreach ($filters as $key => $filterName) {
117  if ((int)$key && strpos($key, '.') === FALSE) {
118  $filterConfiguration = array();
119  if (isset($filters[$key . '.'])) {
120  $filterConfiguration = $filters[$key . '.'];
121  }
122  $this->configuration['filters'][$filterName] = $filterConfiguration;
123  }
124  }
125  } else {
126  $this->configuration['filters'] = new \stdClass();
127  }
128  }
129 
136  protected function setLabel(array $parameters) {
137  if (isset($parameters['label']) && !isset($parameters['label.'])) {
138  $this->configuration['label']['value'] = $parameters['label'];
139  } elseif (!isset($parameters['label']) && isset($parameters['label.'])) {
140  $this->configuration['label']['value'] = $parameters['label.']['value'];
141  }
142  }
143 
150  protected function setLayout(array $parameters) {
151  if (isset($parameters['layout'])) {
152  if ($this->configuration['layout'] === 'front') {
153  $this->configuration['layout'] = 'back';
154  } else {
155  $this->configuration['layout'] = 'front';
156  }
157  }
158  }
159 
166  protected function setValidation(array $parameters) {
167  if (isset($parameters['validation']) && is_array($parameters['validation'])) {
168  $this->configuration['validation'] = $parameters['validation'];
169  } else {
170  $this->configuration['validation'] = new \stdClass();
171  }
172  }
173 
174 }
$parameters
Definition: FileDumpEID.php:15