TYPO3 CMS  TYPO3_8-7
ConfigurationForm.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 
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 
107  {
108  $this->ext_getTSCE_config($cat);
109  }
110 
122  public function ext_getForm($cat, $theConstants, $script = '', $addFields = '', $extKey = '', $addFormTag = true)
123  {
125  $printFields = trim($this->ext_printFields($theConstants, $cat));
126  $content = '';
127  $content .= GeneralUtility::wrapJS('
128  function uFormUrl(aname) {
129  document.' . $this->ext_CEformName . '.action = ' . GeneralUtility::quoteJSvalue(GeneralUtility::linkThisScript() . '#') . '+aname;
130  }
131  ');
132  if ($addFormTag) {
133  $content .= '<form action="' . htmlspecialchars(($script ?: GeneralUtility::linkThisScript())) . '" name="' . $this->ext_CEformName . '" method="post" enctype="multipart/form-data">';
134  }
135  $content .= $addFields;
136  $content .= $printFields;
137  $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) . '" />';
138  $example = $this->ext_displayExample();
139  $content .= $example ? '<hr/>' . $example : '';
140  return $content;
141  }
142 
148  public function ext_displayExample()
149  {
150  $out = '';
151  if ($this->helpConfig['description'] || $this->helpConfig['header']) {
152  $out = ($this->helpConfig['description'] ? implode('<br />', explode('//', $this->helpConfig['description'])) . '<br />' : '')
153  . ($this->helpConfig['bulletlist'] ? '<ul><li>' . implode('<li>', explode('//', $this->helpConfig['bulletlist'])) . '</ul>' : '<BR>');
154  }
155  return $out;
156  }
157 
164  public function ext_mergeIncomingWithExisting($arr)
165  {
166  $parseObj = GeneralUtility::makeInstance(Parser\TypoScriptParser::class);
167  $parseObj->parse(implode(LF, $this->ext_incomingValues));
168  $arr2 = $parseObj->setup;
170  return $arr;
171  }
172 
177  public function ext_fNandV($params)
178  {
179  $fN = 'data[' . $params['name'] . ']';
180  $idName = str_replace('.', '-', $params['name']);
181  $fV = ($params['value'] = isset($this->ext_realValues[$params['name']]) ? $this->ext_realValues[$params['name']] : $params['default_value']);
182  $reg = [];
183  // Values entered from the constantsedit cannot be constants!
184  if (preg_match('/^\\{[\\$][a-zA-Z0-9\\.]*\\}$/', trim($fV), $reg)) {
185  $fV = '';
186  }
187  $fV = htmlspecialchars($fV);
188  return [$fN, $fV, $params, $idName];
189  }
190 
195  public function ext_putValueInConf($key, $var)
196  {
197  $this->ext_incomingValues[$key] = $key . '=' . $var;
198  }
199 
203  public function ext_removeValueInConf($key)
204  {
205  }
206 }
ext_setValueArray($theConstants, $valueArray)
static linkThisScript(array $getParams=[])
ext_getForm($cat, $theConstants, $script='', $addFields='', $extKey='', $addFormTag=true)
static makeInstance($className,... $constructorArguments)
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=true, $includeEmptyValues=true, $enableUnsetFeature=true)