TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
ConfigurationView.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Lowlevel\View;
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 
17 use Psr\Http\Message\ResponseInterface;
18 use Psr\Http\Message\ServerRequestInterface;
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 
105  public function init()
106  {
107  $this->menuConfig();
108  $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
109  $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Lowlevel/ConfigurationView');
110  }
111 
117  public function menuConfig()
118  {
119  // MENU-ITEMS:
120  // If array, then it's a selector box menu
121  // If empty string it's just a variable, that'll be saved.
122  // Values NOT in this array will not be saved in the settings-array for the module.
123  $this->MOD_MENU = [
124  'function' => [
125  0 => LocalizationUtility::translate('typo3ConfVars', 'lowlevel'),
126  1 => LocalizationUtility::translate('tca', 'lowlevel'),
127  2 => LocalizationUtility::translate('tcaDescr', 'lowlevel'),
128  3 => LocalizationUtility::translate('loadedExt', 'lowlevel'),
129  4 => LocalizationUtility::translate('t3services', 'lowlevel'),
130  5 => LocalizationUtility::translate('tbemodules', 'lowlevel'),
131  6 => LocalizationUtility::translate('tbemodulesext', 'lowlevel'),
132  7 => LocalizationUtility::translate('tbeStyles', 'lowlevel'),
133  8 => LocalizationUtility::translate('beUser', 'lowlevel'),
134  9 => LocalizationUtility::translate('usersettings', 'lowlevel'),
135  10 => LocalizationUtility::translate('routes', 'lowlevel')
136  ],
137  'regexsearch' => '',
138  'fixedLgd' => ''
139  ];
140  // CLEANSE SETTINGS
141  $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->moduleName);
142  }
143 
149  public function main()
150  {
152  $arrayBrowser = GeneralUtility::makeInstance(ArrayBrowser::class);
153  $label = $this->MOD_MENU['function'][$this->MOD_SETTINGS['function']];
154  $search_field = GeneralUtility::_GP('search_field');
155 
156  $templatePathAndFilename = GeneralUtility::getFileAbsFileName('EXT:lowlevel/Resources/Private/Templates/Backend/Configuration.html');
157  $this->view->setTemplatePathAndFilename($templatePathAndFilename);
158  $this->view->assign('label', $label);
159  $this->view->assign('search_field', $search_field);
160  $this->view->assign('checkbox_checkRegexsearch', BackendUtility::getFuncCheck(0, 'SET[regexsearch]', $this->MOD_SETTINGS['regexsearch'], '', '', 'id="checkRegexsearch"'));
161 
162  switch ($this->MOD_SETTINGS['function']) {
163  case 0:
164  $theVar = $GLOBALS['TYPO3_CONF_VARS'];
166  $arrayBrowser->varName = '$TYPO3_CONF_VARS';
167  break;
168  case 1:
169  $theVar = $GLOBALS['TCA'];
171  $arrayBrowser->varName = '$TCA';
172  break;
173  case 2:
174  $theVar = $GLOBALS['TCA_DESCR'];
176  $arrayBrowser->varName = '$TCA_DESCR';
177  break;
178  case 3:
179  $theVar = $GLOBALS['TYPO3_LOADED_EXT'];
181  $arrayBrowser->varName = '$TYPO3_LOADED_EXT';
182  break;
183  case 4:
184  $theVar = $GLOBALS['T3_SERVICES'];
186  $arrayBrowser->varName = '$T3_SERVICES';
187  break;
188  case 5:
189  $theVar = $GLOBALS['TBE_MODULES'];
191  $arrayBrowser->varName = '$TBE_MODULES';
192  break;
193  case 6:
194  $theVar = $GLOBALS['TBE_MODULES_EXT'];
196  $arrayBrowser->varName = '$TBE_MODULES_EXT';
197  break;
198  case 7:
199  $theVar = $GLOBALS['TBE_STYLES'];
201  $arrayBrowser->varName = '$TBE_STYLES';
202  break;
203  case 8:
204  $theVar = $GLOBALS['BE_USER']->uc;
206  $arrayBrowser->varName = '$BE_USER->uc';
207  break;
208  case 9:
209  $theVar = $GLOBALS['TYPO3_USER_SETTINGS'];
211  $arrayBrowser->varName = '$TYPO3_USER_SETTINGS';
212  break;
213  case 10:
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  }
324 }
mainAction(ServerRequestInterface $request, ResponseInterface $response)
static getModuleData($MOD_MENU, $CHANGED_SETTINGS, $modName, $type= '', $dontValidateList= '', $setDefaultList= '')
static intersectRecursive(array $source, array $mask=[])
static translate($key, $extensionName, $arguments=null)
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']
static makeInstance($className,...$constructorArguments)
static getFileAbsFileName($filename, $_=null, $_2=null)