TYPO3 CMS  TYPO3_8-7
ConfigurationView.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 
28 
33 {
37  protected $view;
38 
44  protected $moduleName = 'system_config';
45 
51  protected $moduleTemplate;
52 
59  'TYPO3_CONF_VARS' => [
60  'DB' => [
61  'database' => '******',
62  'host' => '******',
63  'password' => '******',
64  'port' => '******',
65  'socket' => '******',
66  'username' => '******',
67  'Connections' => [
68  'Default' => [
69  'dbname' => '******',
70  'host' => '******',
71  'password' => '******',
72  'port' => '******',
73  'user' => '******',
74  'unix_socket' => '******',
75  ],
76  ],
77  ],
78  'SYS' => [
79  'encryptionKey' => '******'
80  ]
81  ]
82  ];
83 
87  public function __construct()
88  {
89  $this->view = GeneralUtility::makeInstance(StandaloneView::class);
90  $this->view->getRequest()->setControllerExtensionName('lowlevel');
91  // Prepare blinding for all database connection types
92  foreach (array_keys($GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']) as $connectionName) {
93  if ($connectionName !== 'Default') {
94  $this->blindedConfigurationOptions['TYPO3_CONF_VARS']['DB']['Connections'][$connectionName] =
95  $this->blindedConfigurationOptions['TYPO3_CONF_VARS']['DB']['Connections']['Default'];
96  }
97  }
98  }
99 
103  public function init()
104  {
105  $this->menuConfig();
106  $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
107  $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Lowlevel/ConfigurationView');
108  }
109 
113  public function menuConfig()
114  {
115  // MENU-ITEMS:
116  // If array, then it's a selector box menu
117  // If empty string it's just a variable, that'll be saved.
118  // Values NOT in this array will not be saved in the settings-array for the module.
119  $this->MOD_MENU = [
120  'function' => [
121  0 => LocalizationUtility::translate('typo3ConfVars', 'lowlevel'),
122  1 => LocalizationUtility::translate('tca', 'lowlevel'),
123  2 => LocalizationUtility::translate('tcaDescr', 'lowlevel'),
124  3 => LocalizationUtility::translate('loadedExt', 'lowlevel'),
125  4 => LocalizationUtility::translate('t3services', 'lowlevel'),
126  5 => LocalizationUtility::translate('tbemodules', 'lowlevel'),
127  6 => LocalizationUtility::translate('tbemodulesext', 'lowlevel'),
128  7 => LocalizationUtility::translate('tbeStyles', 'lowlevel'),
129  8 => LocalizationUtility::translate('beUser', 'lowlevel'),
130  9 => LocalizationUtility::translate('usersettings', 'lowlevel'),
131  10 => LocalizationUtility::translate('pagesTypes', 'lowlevel'),
132  11 => LocalizationUtility::translate('routes', 'lowlevel'),
133  ],
134  'regexsearch' => '',
135  'fixedLgd' => ''
136  ];
137  // CLEANSE SETTINGS
138  $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->moduleName);
139  }
140 
144  public function main()
145  {
147  $arrayBrowser = GeneralUtility::makeInstance(ArrayBrowser::class);
148  $label = $this->MOD_MENU['function'][$this->MOD_SETTINGS['function']];
149  $search_field = GeneralUtility::_GP('search_field');
150 
151  $templatePathAndFilename = GeneralUtility::getFileAbsFileName('EXT:lowlevel/Resources/Private/Templates/Backend/Configuration.html');
152  $this->view->setTemplatePathAndFilename($templatePathAndFilename);
153  $this->view->assign('label', $label);
154  $this->view->assign('search_field', $search_field);
155  $this->view->assign('checkbox_checkRegexsearch', BackendUtility::getFuncCheck(0, 'SET[regexsearch]', $this->MOD_SETTINGS['regexsearch'], '', '', 'id="checkRegexsearch"'));
156 
157  switch ($this->MOD_SETTINGS['function']) {
158  case 0:
159  $theVar = $GLOBALS['TYPO3_CONF_VARS'];
161  $arrayBrowser->varName = '$TYPO3_CONF_VARS';
162  break;
163  case 1:
164  $theVar = $GLOBALS['TCA'];
166  $arrayBrowser->varName = '$TCA';
167  break;
168  case 2:
169  $theVar = $GLOBALS['TCA_DESCR'];
171  $arrayBrowser->varName = '$TCA_DESCR';
172  break;
173  case 3:
174  $theVar = $GLOBALS['TYPO3_LOADED_EXT'];
176  $arrayBrowser->varName = '$TYPO3_LOADED_EXT';
177  break;
178  case 4:
179  $theVar = $GLOBALS['T3_SERVICES'];
181  $arrayBrowser->varName = '$T3_SERVICES';
182  break;
183  case 5:
184  $theVar = $GLOBALS['TBE_MODULES'];
186  $arrayBrowser->varName = '$TBE_MODULES';
187  break;
188  case 6:
189  $theVar = $GLOBALS['TBE_MODULES_EXT'];
191  $arrayBrowser->varName = '$TBE_MODULES_EXT';
192  break;
193  case 7:
194  $theVar = $GLOBALS['TBE_STYLES'];
196  $arrayBrowser->varName = '$TBE_STYLES';
197  break;
198  case 8:
199  $theVar = $GLOBALS['BE_USER']->uc;
201  $arrayBrowser->varName = '$BE_USER->uc';
202  break;
203  case 9:
204  $theVar = $GLOBALS['TYPO3_USER_SETTINGS'];
206  $arrayBrowser->varName = '$TYPO3_USER_SETTINGS';
207  break;
208  case 10:
209  $theVar = $GLOBALS['PAGES_TYPES'];
211  $arrayBrowser->varName = '$PAGES_TYPES';
212  break;
213  case 11:
214  $router = GeneralUtility::makeInstance(Router::class);
215  $routes = $router->getRoutes();
216  $theVar = [];
217  foreach ($routes as $identifier => $route) {
218  $theVar[$identifier] = [
219  'path' => $route->getPath(),
220  'options' => $route->getOptions()
221  ];
222  }
224  $arrayBrowser->varName = 'BackendRoutes';
225  break;
226  default:
227  $theVar = [];
228  }
229  // Update node:
230  $update = 0;
231  $node = GeneralUtility::_GET('node');
232  // If any plus-signs were clicked, it's registered.
233  if (is_array($node)) {
234  $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']] = $arrayBrowser->depthKeys($node, $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']]);
235  $update = 1;
236  }
237  if ($update) {
238  $this->getBackendUser()->pushModuleData($this->moduleName, $this->MOD_SETTINGS);
239  }
240  $arrayBrowser->dontLinkVar = true;
241  $arrayBrowser->depthKeys = $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']];
242  $arrayBrowser->regexMode = $this->MOD_SETTINGS['regexsearch'];
243  $arrayBrowser->fixedLgd = $this->MOD_SETTINGS['fixedLgd'];
244  $arrayBrowser->searchKeysToo = true;
245 
246  // If any POST-vars are send, update the condition array
247  if (GeneralUtility::_POST('search') && trim($search_field)) {
248  $arrayBrowser->depthKeys = $arrayBrowser->getSearchKeys($theVar, '', $search_field, []);
249  }
250 
251  // mask sensitive information
252  $varName = trim($arrayBrowser->varName, '$');
253  if (isset($this->blindedConfigurationOptions[$varName])) {
254  ArrayUtility::mergeRecursiveWithOverrule($theVar, ArrayUtility::intersectRecursive($this->blindedConfigurationOptions[$varName], $theVar));
255  }
256  $tree = $arrayBrowser->tree($theVar, '', '');
257  $this->view->assign('tree', $tree);
258 
259  // Setting up the shortcut button for docheader
260  $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
261  // Shortcut
262  $shortcutButton = $buttonBar->makeShortcutButton()
263  ->setModuleName($this->moduleName)
264  ->setDisplayName($this->MOD_MENU['function'][$this->MOD_SETTINGS['function']])
265  ->setSetVariables(['function']);
266  $buttonBar->addButton($shortcutButton);
267 
268  $this->getModuleMenu();
269 
270  $this->content = '<form action="" id="ConfigurationView" method="post">';
271  $this->content .= $this->view->render();
272  $this->content .= '</form>';
273  }
274 
283  public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
284  {
285  $GLOBALS['SOBE'] = $this;
286  $this->init();
287  $this->main();
288 
289  $this->moduleTemplate->setContent($this->content);
290  $response->getBody()->write($this->moduleTemplate->renderContent());
291  return $response;
292  }
293 
297  protected function getModuleMenu()
298  {
299  $menu = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
300  $menu->setIdentifier('ConfigurationJumpMenu');
301 
302  foreach ($this->MOD_MENU['function'] as $controller => $title) {
303  $item = $menu
304  ->makeMenuItem()
305  ->setHref(
306  BackendUtility::getModuleUrl(
307  $this->moduleName,
308  [
309  'id' => $this->id,
310  'SET' => [
311  'function' => $controller
312  ]
313  ]
314  )
315  )
316  ->setTitle($title);
317  if ($controller === (int)$this->MOD_SETTINGS['function']) {
318  $item->setActive(true);
319  }
320  $menu->addMenuItem($item);
321  }
322  $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
323  $this->moduleTemplate->addJavaScriptCode(
324  'jumpToUrl',
325  '
326  function jumpToUrl(URL) {
327  window.location.href = URL;
328  return false;
329  }
330  '
331  );
332  }
333 }
mainAction(ServerRequestInterface $request, ResponseInterface $response)
static getModuleData( $MOD_MENU, $CHANGED_SETTINGS, $modName, $type='', $dontValidateList='', $setDefaultList='')
static intersectRecursive(array $source, array $mask=[])
static getFileAbsFileName($filename, $_=null, $_2=null)
static translate($key, $extensionName=null, $arguments=null)
static makeInstance($className,... $constructorArguments)
static naturalKeySortRecursive(array &$array)
static getFuncCheck( $mainParams, $elementName, $currentValue, $script='', $addParams='', $tagParams='')
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=true, $includeEmptyValues=true, $enableUnsetFeature=true)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']