TYPO3  7.6
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 
27 
32 {
36  protected $view;
37 
43  protected $moduleName = 'system_config';
44 
50  protected $moduleTemplate;
51 
55  public function __construct()
56  {
57  $this->view = GeneralUtility::makeInstance(StandaloneView::class);
58  $this->view->getRequest()->setControllerExtensionName('lowlevel');
59  }
60 
66  public function init()
67  {
68  $this->menuConfig();
69  $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
70  }
71 
77  public function menuConfig()
78  {
79  // MENU-ITEMS:
80  // If array, then it's a selector box menu
81  // If empty string it's just a variable, that'll be saved.
82  // Values NOT in this array will not be saved in the settings-array for the module.
83  $this->MOD_MENU = array(
84  'function' => array(
85  0 => LocalizationUtility::translate('typo3ConfVars', 'lowlevel'),
86  1 => LocalizationUtility::translate('tca', 'lowlevel'),
87  2 => LocalizationUtility::translate('tcaDescr', 'lowlevel'),
88  3 => LocalizationUtility::translate('loadedExt', 'lowlevel'),
89  4 => LocalizationUtility::translate('t3services', 'lowlevel'),
90  5 => LocalizationUtility::translate('tbemodules', 'lowlevel'),
91  6 => LocalizationUtility::translate('tbemodulesext', 'lowlevel'),
92  7 => LocalizationUtility::translate('tbeStyles', 'lowlevel'),
93  8 => LocalizationUtility::translate('beUser', 'lowlevel'),
94  9 => LocalizationUtility::translate('usersettings', 'lowlevel')
95  ),
96  'regexsearch' => '',
97  'fixedLgd' => ''
98  );
99  // CLEANSE SETTINGS
100  $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->moduleName);
101  }
102 
108  public function main()
109  {
111  $arrayBrowser = GeneralUtility::makeInstance(ArrayBrowser::class);
112  $label = $this->MOD_MENU['function'][$this->MOD_SETTINGS['function']];
113  $search_field = GeneralUtility::_GP('search_field');
114 
115  $templatePathAndFilename = GeneralUtility::getFileAbsFileName('EXT:lowlevel/Resources/Private/Templates/Backend/Configuration.html');
116  $this->view->setTemplatePathAndFilename($templatePathAndFilename);
117  $this->view->assign('label', $label);
118  $this->view->assign('search_field', $search_field);
119  $this->view->assign('checkbox_checkRegexsearch', BackendUtility::getFuncCheck(0, 'SET[regexsearch]', $this->MOD_SETTINGS['regexsearch'], '', '', 'id="checkRegexsearch"'));
120 
121  switch ($this->MOD_SETTINGS['function']) {
122  case 0:
123  $theVar = $GLOBALS['TYPO3_CONF_VARS'];
125  $arrayBrowser->varName = '$TYPO3_CONF_VARS';
126  break;
127  case 1:
128  $theVar = $GLOBALS['TCA'];
130  $arrayBrowser->varName = '$TCA';
131  break;
132  case 2:
133  $theVar = $GLOBALS['TCA_DESCR'];
135  $arrayBrowser->varName = '$TCA_DESCR';
136  break;
137  case 3:
138  $theVar = $GLOBALS['TYPO3_LOADED_EXT'];
140  $arrayBrowser->varName = '$TYPO3_LOADED_EXT';
141  break;
142  case 4:
143  $theVar = $GLOBALS['T3_SERVICES'];
145  $arrayBrowser->varName = '$T3_SERVICES';
146  break;
147  case 5:
148  $theVar = $GLOBALS['TBE_MODULES'];
150  $arrayBrowser->varName = '$TBE_MODULES';
151  break;
152  case 6:
153  $theVar = $GLOBALS['TBE_MODULES_EXT'];
155  $arrayBrowser->varName = '$TBE_MODULES_EXT';
156  break;
157  case 7:
158  $theVar = $GLOBALS['TBE_STYLES'];
160  $arrayBrowser->varName = '$TBE_STYLES';
161  break;
162  case 8:
163  $theVar = $GLOBALS['BE_USER']->uc;
165  $arrayBrowser->varName = '$BE_USER->uc';
166  break;
167  case 9:
168  $theVar = $GLOBALS['TYPO3_USER_SETTINGS'];
170  $arrayBrowser->varName = '$TYPO3_USER_SETTINGS';
171  break;
172  default:
173  $theVar = array();
174  }
175  // Update node:
176  $update = 0;
177  $node = GeneralUtility::_GET('node');
178  // If any plus-signs were clicked, it's registred.
179  if (is_array($node)) {
180  $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']] = $arrayBrowser->depthKeys($node, $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']]);
181  $update = 1;
182  }
183  if ($update) {
184  $this->getBackendUser()->pushModuleData($this->moduleName, $this->MOD_SETTINGS);
185  }
186  $arrayBrowser->dontLinkVar = true;
187  $arrayBrowser->depthKeys = $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']];
188  $arrayBrowser->regexMode = $this->MOD_SETTINGS['regexsearch'];
189  $arrayBrowser->fixedLgd = $this->MOD_SETTINGS['fixedLgd'];
190  $arrayBrowser->searchKeysToo = true;
191 
192  // If any POST-vars are send, update the condition array
193  if (GeneralUtility::_POST('search') && trim($search_field)) {
194  $arrayBrowser->depthKeys = $arrayBrowser->getSearchKeys($theVar, '', $search_field, array());
195  }
196  // mask the encryption key to not show it as plaintext in the configuration module
197  if ($theVar == $GLOBALS['TYPO3_CONF_VARS']) {
198  $theVar['SYS']['encryptionKey'] = '***** (length: ' . strlen($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']) . ' characters)';
199  }
200  $tree = $arrayBrowser->tree($theVar, '', '');
201  $this->view->assign('tree', $tree);
202 
203  // Setting up the shortcut button for docheader
204  $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
205  // Shortcut
206  $shortcutButton = $buttonBar->makeShortcutButton()
207  ->setModuleName($this->moduleName)
208  ->setDisplayName($this->MOD_MENU['function'][$this->MOD_SETTINGS['function']])
209  ->setSetVariables(['function']);
210  $buttonBar->addButton($shortcutButton);
211 
212  $this->getModuleMenu();
213 
214  $this->content = '<form action="" id="ConfigurationView" method="post">';
215  $this->content .= $this->view->render();
216  $this->content .= '</form>';
217  }
218 
219 
229  {
230  $GLOBALS['SOBE'] = $this;
231  $this->init();
232  $this->main();
233 
234  $this->moduleTemplate->setContent($this->content);
235  $response->getBody()->write($this->moduleTemplate->renderContent());
236  return $response;
237  }
238 
245  public function printContent()
246  {
248  echo $this->content;
249  }
250 
254  protected function getModuleMenu()
255  {
256  $menu = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
257  $menu->setIdentifier('ConfigurationJumpMenu');
258 
259  foreach ($this->MOD_MENU['function'] as $controller => $title) {
260  $item = $menu
261  ->makeMenuItem()
262  ->setHref(
263  BackendUtility::getModuleUrl(
264  $this->moduleName,
265  [
266  'id' => $this->id,
267  'SET' => [
268  'function' => $controller
269  ]
270  ]
271  )
272  )
273  ->setTitle($title);
274  if ($controller === (int)$this->MOD_SETTINGS['function']) {
275  $item->setActive(true);
276  }
277  $menu->addMenuItem($item);
278  }
279  $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
280  }
281 }