TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
ConfigurationForm.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Core\TypoScript;
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 
19 
24 {
28  public $categories = [];
29 
34 
38  public $ext_CEformName = 'tsStyleConfigForm';
39 
43  public $ext_printAll = true;
44 
48  public $ext_incomingValues = [];
49 
53  protected $ext_realValues = [];
54 
59  public function ext_initTSstyleConfig($configTemplate)
60  {
61  // Do not log time-performance information
62  $this->tt_track = 0;
63  $this->constants = [$configTemplate, ''];
64  // The editable constants are returned in an array.
65  $theConstants = $this->generateConfig_constants();
66  return $theConstants;
67  }
68 
76  public function ext_setValueArray($theConstants, $valueArray)
77  {
78  $temp = $this->flatSetup;
79  $this->flatSetup = [];
80  $this->flattenSetup($valueArray, '', '');
81  $this->objReg = $this->ext_realValues = $this->flatSetup;
82  $this->flatSetup = $temp;
83  foreach ($theConstants as $k => $p) {
84  if (isset($this->objReg[$k])) {
85  $theConstants[$k]['value'] = $this->ext_realValues[$k];
86  }
87  }
88  // Reset the default pool of categories.
89  $this->categories = [];
90  // The returned constants are sorted in categories, that goes into the $this->categories array
91  $this->ext_categorizeEditableConstants($theConstants);
92  return $theConstants;
93  }
94 
98  public function ext_getCategoriesForModMenu()
99  {
100  return $this->ext_getCategoryLabelArray();
101  }
102 
108  {
109  $this->ext_getTSCE_config($cat);
110  }
111 
123  public function ext_getForm($cat, $theConstants, $script = '', $addFields = '', $extKey = '', $addFormTag = true)
124  {
126  $printFields = trim($this->ext_printFields($theConstants, $cat));
127  $content = '';
128  $content .= GeneralUtility::wrapJS('
129  function uFormUrl(aname) {
130  document.' . $this->ext_CEformName . '.action = ' . GeneralUtility::quoteJSvalue(GeneralUtility::linkThisScript() . '#') . '+aname;
131  }
132  ');
133  if ($addFormTag) {
134  $content .= '<form action="' . htmlspecialchars(($script ?: GeneralUtility::linkThisScript())) . '" name="' . $this->ext_CEformName . '" method="post" enctype="multipart/form-data">';
135  }
136  $content .= $addFields;
137  $content .= $printFields;
138  $content .= '<input class="btn btn-default" type="submit" name="submit" value="' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_tsfe.xlf:update')) . '" id="configuration-submit-' . htmlspecialchars($extKey) . '" />';
139  $example = $this->ext_displayExample();
140  $content .= $example ? '<hr/>' . $example : '';
141  return $content;
142  }
143 
149  public function ext_displayExample()
150  {
151  $out = '';
152  if ($this->helpConfig['description'] || $this->helpConfig['header']) {
153  $out = ($this->helpConfig['description'] ? implode(explode('//', $this->helpConfig['description']), '<br />') . '<br />' : '')
154  . ($this->helpConfig['bulletlist'] ? '<ul><li>' . implode(explode('//', $this->helpConfig['bulletlist']), '<li>') . '</ul>' : '<BR>');
155  }
156  return $out;
157  }
158 
165  public function ext_mergeIncomingWithExisting($arr)
166  {
167  $parseObj = GeneralUtility::makeInstance(Parser\TypoScriptParser::class);
168  $parseObj->parse(implode(LF, $this->ext_incomingValues));
169  $arr2 = $parseObj->setup;
171  return $arr;
172  }
173 
178  public function ext_fNandV($params)
179  {
180  $fN = 'data[' . $params['name'] . ']';
181  $idName = str_replace('.', '-', $params['name']);
182  $fV = ($params['value'] = isset($this->ext_realValues[$params['name']]) ? $this->ext_realValues[$params['name']] : $params['default_value']);
183  $reg = [];
184  // Values entered from the constantsedit cannot be constants!
185  if (preg_match('/^\\{[\\$][a-zA-Z0-9\\.]*\\}$/', trim($fV), $reg)) {
186  $fV = '';
187  }
188  $fV = htmlspecialchars($fV);
189  return [$fN, $fV, $params, $idName];
190  }
191 
197  public function ext_putValueInConf($key, $var)
198  {
199  $this->ext_incomingValues[$key] = $key . '=' . $var;
200  }
201 
206  public function ext_removeValueInConf($key)
207  {
208  }
209 }
ext_getForm($cat, $theConstants, $script= '', $addFields= '', $extKey= '', $addFormTag=true)
ext_setValueArray($theConstants, $valueArray)
static linkThisScript(array $getParams=[])
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=true, $includeEmptyValues=true, $enableUnsetFeature=true)
static makeInstance($className,...$constructorArguments)