TYPO3 CMS  TYPO3_7-6
Configuration.php
Go to the documentation of this file.
1 <?php
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 
22 {
26  const DISABLE_CONTENT_ELEMENT_RENDERING = 'disableContentElement';
27 
31  const DEFAULT_THEME_NAME = 'Default';
32 
36  public static function create()
37  {
38  return \TYPO3\CMS\Form\Utility\FormUtility::getObjectManager()->get(self::class);
39  }
40 
44  protected $typoScript = [];
45 
49  protected $contentElementRendering = false;
50 
54  protected $prefix = 'form';
55 
59  protected $compatibility = false;
60 
64  protected $themeName = '';
65 
70 
75  public function injectTypoScriptRepository(\TYPO3\CMS\Form\Domain\Repository\TypoScriptRepository $typoScriptRepository)
76  {
77  $this->typoScriptRepository = $typoScriptRepository;
78  }
79 
83  public function getTypoScript()
84  {
85  return $this->typoScript;
86  }
87 
92  public function setTypoScript(array $typoScript)
93  {
94  $this->typoScript = $typoScript;
95  $this->update();
96  return $this;
97  }
98 
99  public function getContentElementRendering()
100  {
102  }
103 
109  {
110  $this->contentElementRendering = (bool)$contentElementRendering;
111  return $this;
112  }
113 
117  public function getPrefix()
118  {
119  return $this->prefix;
120  }
121 
126  public function setPrefix($prefix)
127  {
128  $this->prefix = (string)$prefix;
129  return $this;
130  }
131 
135  public function getCompatibility()
136  {
137  return $this->compatibility;
138  }
139 
145  {
146  $this->compatibility = (bool)$compatibility;
147  return $this;
148  }
149 
153  public function getThemeName()
154  {
155  return $this->themeName;
156  }
157 
162  public function setThemeName($themeName = '')
163  {
164  if ($themeName === '') {
165  $themeName = static::DEFAULT_THEME_NAME;
166  }
167  $this->themeName = $themeName;
168  return $this;
169  }
170 
175  protected function update()
176  {
177  // Determine content rendering mode. If activated, cObject and stdWrap can be
178  // used to execute various processes that must not be allowed on TypoScript
179  // that has been created by non-privileged backend users (= insecure TypoScript)
181  empty($this->typoScript[static::DISABLE_CONTENT_ELEMENT_RENDERING])
182  );
183  // Determine the HTML form element prefix to distinguish
184  // different form components on the same page in the frontend
185  if (!empty($this->typoScript['prefix'])) {
186  $this->setPrefix($this->typoScript['prefix']);
187  }
188  // Determine compatibility behavior
189  $this->setCompatibility((bool)$this->typoScriptRepository->getModelConfigurationByScope('FORM', 'compatibilityMode'));
190  if (isset($this->typoScript['compatibilityMode'])) {
191  if ((int)($this->typoScript['compatibilityMode']) === 0) {
192  $this->setCompatibility(false);
193  } else {
194  $this->setCompatibility(true);
195  }
196  }
197  // Set the theme name
198  if (!empty($this->typoScript['themeName'])) {
199  $this->setThemeName($this->typoScript['themeName']);
200  } elseif (!empty($this->typoScriptRepository->getModelConfigurationByScope('FORM', 'themeName'))) {
201  $this->setThemeName($this->typoScriptRepository->getModelConfigurationByScope('FORM', 'themeName'));
202  } else {
203  $this->setThemeName(static::DEFAULT_THEME_NAME);
204  }
205  }
206 }
setContentElementRendering($contentElementRendering)
injectTypoScriptRepository(\TYPO3\CMS\Form\Domain\Repository\TypoScriptRepository $typoScriptRepository)