TYPO3 CMS  TYPO3_7-6
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 
58  protected $ext_backPath = '';
59 
67  public function ext_initTSstyleConfig($configTemplate, $pathRel, $pathAbs, $backPath = '')
68  {
69  // Do not log time-performance information
70  $this->tt_track = 0;
71  $this->constants = [$configTemplate, ''];
72  // The editable constants are returned in an array.
73  $theConstants = $this->generateConfig_constants();
74  $this->ext_localGfxPrefix = $pathAbs;
75  $this->ext_localWebGfxPrefix = $backPath . $pathRel;
76  $this->ext_backPath = $backPath;
77  return $theConstants;
78  }
79 
87  public function ext_setValueArray($theConstants, $valueArray)
88  {
89  $temp = $this->flatSetup;
90  $this->flatSetup = [];
91  $this->flattenSetup($valueArray, '', '');
92  $this->objReg = $this->ext_realValues = $this->flatSetup;
93  $this->flatSetup = $temp;
94  foreach ($theConstants as $k => $p) {
95  if (isset($this->objReg[$k])) {
96  $theConstants[$k]['value'] = $this->ext_realValues[$k];
97  }
98  }
99  // Reset the default pool of categories.
100  $this->categories = [];
101  // The returned constants are sorted in categories, that goes into the $this->categories array
102  $this->ext_categorizeEditableConstants($theConstants);
103  return $theConstants;
104  }
105 
109  public function ext_getCategoriesForModMenu()
110  {
111  return $this->ext_getCategoryLabelArray();
112  }
113 
119  {
120  $this->ext_getTSCE_config($cat);
121  }
122 
134  public function ext_getForm($cat, $theConstants, $script = '', $addFields = '', $extKey = '', $addFormTag = true)
135  {
137  $printFields = trim($this->ext_printFields($theConstants, $cat));
138  $content = '';
139  $content .= GeneralUtility::wrapJS('
140  function uFormUrl(aname) {
141  document.' . $this->ext_CEformName . '.action = ' . GeneralUtility::quoteJSvalue(GeneralUtility::linkThisScript() . '#') . '+aname;
142  }
143  ');
144  if ($addFormTag) {
145  $content .= '<form action="' . htmlspecialchars(($script ?: GeneralUtility::linkThisScript())) . '" name="' . $this->ext_CEformName . '" method="post" enctype="multipart/form-data">';
146  }
147  $content .= $addFields;
148  $content .= $printFields;
149  $content .= '<input class="btn btn-default" type="submit" name="submit" value="' . $this->getLanguageService()->sL('LLL:EXT:lang/locallang_tsfe.xlf:update', true) . '" id="configuration-submit-' . htmlspecialchars($extKey) . '" />';
150  $example = $this->ext_displayExample();
151  $content .= $example ? '<hr/>' . $example : '';
152  return $content;
153  }
154 
160  public function ext_displayExample()
161  {
162  $out = '';
163  if ($this->helpConfig['imagetag'] || $this->helpConfig['description'] || $this->helpConfig['header']) {
164  $out = '<div align="center">' . $this->helpConfig['imagetag'] . '</div><br />'
165  . ($this->helpConfig['description'] ? implode(explode('//', $this->helpConfig['description']), '<br />') . '<br />' : '')
166  . ($this->helpConfig['bulletlist'] ? '<ul><li>' . implode(explode('//', $this->helpConfig['bulletlist']), '<li>') . '</ul>' : '<BR>');
167  }
168  return $out;
169  }
170 
177  public function ext_mergeIncomingWithExisting($arr)
178  {
179  $parseObj = GeneralUtility::makeInstance(Parser\TypoScriptParser::class);
180  $parseObj->parse(implode(LF, $this->ext_incomingValues));
181  $arr2 = $parseObj->setup;
183  return $arr;
184  }
185 
191  public function ext_getKeyImage($key)
192  {
194  return '<span class="label label-danger">' . $key . '</span>';
195  }
196 
201  public function ext_getTSCE_config_image($imgConf)
202  {
203  $iFile = $this->ext_localGfxPrefix . $imgConf;
204  $tFile = $this->ext_localWebGfxPrefix . $imgConf;
205  $imageInfo = @getimagesize($iFile);
206  return '<img src="' . $tFile . '" ' . $imageInfo[3] . '>';
207  }
208 
213  public function ext_fNandV($params)
214  {
215  $fN = 'data[' . $params['name'] . ']';
216  $idName = str_replace('.', '-', $params['name']);
217  $fV = ($params['value'] = isset($this->ext_realValues[$params['name']]) ? $this->ext_realValues[$params['name']] : $params['default_value']);
218  $reg = [];
219  // Values entered from the constantsedit cannot be constants!
220  if (preg_match('/^\\{[\\$][a-zA-Z0-9\\.]*\\}$/', trim($fV), $reg)) {
221  $fV = '';
222  }
223  $fV = htmlspecialchars($fV);
224  return [$fN, $fV, $params, $idName];
225  }
226 
232  public function ext_putValueInConf($key, $var)
233  {
234  $this->ext_incomingValues[$key] = $key . '=' . $var;
235  }
236 
241  public function ext_removeValueInConf($key)
242  {
243  }
244 }
ext_setValueArray($theConstants, $valueArray)
static linkThisScript(array $getParams=[])
ext_getForm($cat, $theConstants, $script='', $addFields='', $extKey='', $addFormTag=true)
ext_initTSstyleConfig($configTemplate, $pathRel, $pathAbs, $backPath='')
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=true, $includeEmptyValues=true, $enableUnsetFeature=true)
static wrapJS($string, $linebreak=true)