TYPO3 CMS  TYPO3_7-6
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  ],
68  'SYS' => [
69  'encryptionKey' => '******'
70  ]
71  ]
72  ];
73 
77  public function __construct()
78  {
79  $this->view = GeneralUtility::makeInstance(StandaloneView::class);
80  $this->view->getRequest()->setControllerExtensionName('lowlevel');
81  }
82 
88  public function init()
89  {
90  $this->menuConfig();
91  $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
92  $this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Lowlevel/ConfigurationView');
93  }
94 
100  public function menuConfig()
101  {
102  // MENU-ITEMS:
103  // If array, then it's a selector box menu
104  // If empty string it's just a variable, that'll be saved.
105  // Values NOT in this array will not be saved in the settings-array for the module.
106  $this->MOD_MENU = [
107  'function' => [
108  0 => LocalizationUtility::translate('typo3ConfVars', 'lowlevel'),
109  1 => LocalizationUtility::translate('tca', 'lowlevel'),
110  2 => LocalizationUtility::translate('tcaDescr', 'lowlevel'),
111  3 => LocalizationUtility::translate('loadedExt', 'lowlevel'),
112  4 => LocalizationUtility::translate('t3services', 'lowlevel'),
113  5 => LocalizationUtility::translate('tbemodules', 'lowlevel'),
114  6 => LocalizationUtility::translate('tbemodulesext', 'lowlevel'),
115  7 => LocalizationUtility::translate('tbeStyles', 'lowlevel'),
116  8 => LocalizationUtility::translate('beUser', 'lowlevel'),
117  9 => LocalizationUtility::translate('usersettings', 'lowlevel'),
118  10 => LocalizationUtility::translate('routes', 'lowlevel')
119  ],
120  'regexsearch' => '',
121  'fixedLgd' => ''
122  ];
123  // CLEANSE SETTINGS
124  $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->moduleName);
125  }
126 
132  public function main()
133  {
135  $arrayBrowser = GeneralUtility::makeInstance(ArrayBrowser::class);
136  $label = $this->MOD_MENU['function'][$this->MOD_SETTINGS['function']];
137  $search_field = GeneralUtility::_GP('search_field');
138 
139  $templatePathAndFilename = GeneralUtility::getFileAbsFileName('EXT:lowlevel/Resources/Private/Templates/Backend/Configuration.html');
140  $this->view->setTemplatePathAndFilename($templatePathAndFilename);
141  $this->view->assign('label', $label);
142  $this->view->assign('search_field', $search_field);
143  $this->view->assign('checkbox_checkRegexsearch', BackendUtility::getFuncCheck(0, 'SET[regexsearch]', $this->MOD_SETTINGS['regexsearch'], '', '', 'id="checkRegexsearch"'));
144 
145  switch ($this->MOD_SETTINGS['function']) {
146  case 0:
147  $theVar = $GLOBALS['TYPO3_CONF_VARS'];
149  $arrayBrowser->varName = '$TYPO3_CONF_VARS';
150  break;
151  case 1:
152  $theVar = $GLOBALS['TCA'];
154  $arrayBrowser->varName = '$TCA';
155  break;
156  case 2:
157  $theVar = $GLOBALS['TCA_DESCR'];
159  $arrayBrowser->varName = '$TCA_DESCR';
160  break;
161  case 3:
162  $theVar = $GLOBALS['TYPO3_LOADED_EXT'];
164  $arrayBrowser->varName = '$TYPO3_LOADED_EXT';
165  break;
166  case 4:
167  $theVar = $GLOBALS['T3_SERVICES'];
169  $arrayBrowser->varName = '$T3_SERVICES';
170  break;
171  case 5:
172  $theVar = $GLOBALS['TBE_MODULES'];
174  $arrayBrowser->varName = '$TBE_MODULES';
175  break;
176  case 6:
177  $theVar = $GLOBALS['TBE_MODULES_EXT'];
179  $arrayBrowser->varName = '$TBE_MODULES_EXT';
180  break;
181  case 7:
182  $theVar = $GLOBALS['TBE_STYLES'];
184  $arrayBrowser->varName = '$TBE_STYLES';
185  break;
186  case 8:
187  $theVar = $GLOBALS['BE_USER']->uc;
189  $arrayBrowser->varName = '$BE_USER->uc';
190  break;
191  case 9:
192  $theVar = $GLOBALS['TYPO3_USER_SETTINGS'];
194  $arrayBrowser->varName = '$TYPO3_USER_SETTINGS';
195  break;
196  case 10:
197  $router = GeneralUtility::makeInstance(Router::class);
198  $routes = $router->getRoutes();
199  $theVar = [];
200  foreach ($routes as $identifier => $route) {
201  $theVar[$identifier] = [
202  'path' => $route->getPath(),
203  'options' => $route->getOptions()
204  ];
205  }
207  $arrayBrowser->varName = 'BackendRoutes';
208  break;
209  default:
210  $theVar = [];
211  }
212  // Update node:
213  $update = 0;
214  $node = GeneralUtility::_GET('node');
215  // If any plus-signs were clicked, it's registered.
216  if (is_array($node)) {
217  $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']] = $arrayBrowser->depthKeys($node, $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']]);
218  $update = 1;
219  }
220  if ($update) {
221  $this->getBackendUser()->pushModuleData($this->moduleName, $this->MOD_SETTINGS);
222  }
223  $arrayBrowser->dontLinkVar = true;
224  $arrayBrowser->depthKeys = $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']];
225  $arrayBrowser->regexMode = $this->MOD_SETTINGS['regexsearch'];
226  $arrayBrowser->fixedLgd = $this->MOD_SETTINGS['fixedLgd'];
227  $arrayBrowser->searchKeysToo = true;
228 
229  // If any POST-vars are send, update the condition array
230  if (GeneralUtility::_POST('search') && trim($search_field)) {
231  $arrayBrowser->depthKeys = $arrayBrowser->getSearchKeys($theVar, '', $search_field, []);
232  }
233 
234  // mask sensitive information
235  $varName = trim($arrayBrowser->varName, '$');
236  if (isset($this->blindedConfigurationOptions[$varName])) {
237  ArrayUtility::mergeRecursiveWithOverrule($theVar, $this->blindedConfigurationOptions[$varName]);
238  }
239  $tree = $arrayBrowser->tree($theVar, '', '');
240  $this->view->assign('tree', $tree);
241 
242  // Setting up the shortcut button for docheader
243  $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
244  // Shortcut
245  $shortcutButton = $buttonBar->makeShortcutButton()
246  ->setModuleName($this->moduleName)
247  ->setDisplayName($this->MOD_MENU['function'][$this->MOD_SETTINGS['function']])
248  ->setSetVariables(['function']);
249  $buttonBar->addButton($shortcutButton);
250 
251  $this->getModuleMenu();
252 
253  $this->content = '<form action="" id="ConfigurationView" method="post">';
254  $this->content .= $this->view->render();
255  $this->content .= '</form>';
256  }
257 
266  public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
267  {
268  $GLOBALS['SOBE'] = $this;
269  $this->init();
270  $this->main();
271 
272  $this->moduleTemplate->setContent($this->content);
273  $response->getBody()->write($this->moduleTemplate->renderContent());
274  return $response;
275  }
276 
283  public function printContent()
284  {
286  echo $this->content;
287  }
288 
292  protected function getModuleMenu()
293  {
294  $menu = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
295  $menu->setIdentifier('ConfigurationJumpMenu');
296 
297  foreach ($this->MOD_MENU['function'] as $controller => $title) {
298  $item = $menu
299  ->makeMenuItem()
300  ->setHref(
301  BackendUtility::getModuleUrl(
302  $this->moduleName,
303  [
304  'id' => $this->id,
305  'SET' => [
306  'function' => $controller
307  ]
308  ]
309  )
310  )
311  ->setTitle($title);
312  if ($controller === (int)$this->MOD_SETTINGS['function']) {
313  $item->setActive(true);
314  }
315  $menu->addMenuItem($item);
316  }
317  $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
318  $this->moduleTemplate->addJavaScriptCode(
319  'jumpToUrl',
320  '
321  function jumpToUrl(URL) {
322  window.location.href = URL;
323  return false;
324  }
325  '
326  );
327  }
328 }
static translate($key, $extensionName, $arguments=null)
static getFuncCheck($mainParams, $elementName, $currentValue, $script='', $addParams='', $tagParams='')
mainAction(ServerRequestInterface $request, ResponseInterface $response)
static naturalKeySortRecursive(array &$array)
static getModuleData($MOD_MENU, $CHANGED_SETTINGS, $modName, $type='', $dontValidateList='', $setDefaultList='')
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=true, $includeEmptyValues=true, $enableUnsetFeature=true)
static getFileAbsFileName($filename, $onlyRelative=true, $relToTYPO3_mainDir=false)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']