64c6bc8a8d12b08243f7e8761e23e9c2f4313f31
[Packages/TYPO3.CMS.git] / typo3 / sysext / lowlevel / Classes / View / ConfigurationView.php
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;
19 use TYPO3\CMS\Backend\Module\BaseScriptClass;
20 use TYPO3\CMS\Backend\Template\ModuleTemplate;
21 use TYPO3\CMS\Backend\Utility\BackendUtility;
22 use TYPO3\CMS\Core\Utility\ArrayUtility;
23 use TYPO3\CMS\Core\Utility\GeneralUtility;
24 use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
25 use TYPO3\CMS\Fluid\View\StandaloneView;
26 use TYPO3\CMS\Lowlevel\Utility\ArrayBrowser;
27
28 /**
29 * Script class for the Config module
30 */
31 class ConfigurationView extends BaseScriptClass
32 {
33 /**
34 * @var StandaloneView
35 */
36 protected $view;
37
38 /**
39 * The name of the module
40 *
41 * @var string
42 */
43 protected $moduleName = 'system_config';
44
45 /**
46 * ModuleTemplate Container
47 *
48 * @var ModuleTemplate
49 */
50 protected $moduleTemplate;
51
52 /**
53 * Constructor
54 */
55 public function __construct()
56 {
57 $this->view = GeneralUtility::makeInstance(StandaloneView::class);
58 $this->view->getRequest()->setControllerExtensionName('lowlevel');
59 }
60
61 /**
62 * Initialization
63 *
64 * @return void
65 */
66 public function init()
67 {
68 $this->menuConfig();
69 $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
70 }
71
72 /**
73 * Menu Configuration
74 *
75 * @return void
76 */
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
103 /**
104 * Main function
105 *
106 * @return void
107 */
108 public function main()
109 {
110 /** @var ArrayBrowser $arrayBrowser */
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'];
124 ArrayUtility::naturalKeySortRecursive($theVar);
125 $arrayBrowser->varName = '$TYPO3_CONF_VARS';
126 break;
127 case 1:
128 $theVar = $GLOBALS['TCA'];
129 ArrayUtility::naturalKeySortRecursive($theVar);
130 $arrayBrowser->varName = '$TCA';
131 break;
132 case 2:
133 $theVar = $GLOBALS['TCA_DESCR'];
134 ArrayUtility::naturalKeySortRecursive($theVar);
135 $arrayBrowser->varName = '$TCA_DESCR';
136 break;
137 case 3:
138 $theVar = $GLOBALS['TYPO3_LOADED_EXT'];
139 ArrayUtility::naturalKeySortRecursive($theVar);
140 $arrayBrowser->varName = '$TYPO3_LOADED_EXT';
141 break;
142 case 4:
143 $theVar = $GLOBALS['T3_SERVICES'];
144 ArrayUtility::naturalKeySortRecursive($theVar);
145 $arrayBrowser->varName = '$T3_SERVICES';
146 break;
147 case 5:
148 $theVar = $GLOBALS['TBE_MODULES'];
149 ArrayUtility::naturalKeySortRecursive($theVar);
150 $arrayBrowser->varName = '$TBE_MODULES';
151 break;
152 case 6:
153 $theVar = $GLOBALS['TBE_MODULES_EXT'];
154 ArrayUtility::naturalKeySortRecursive($theVar);
155 $arrayBrowser->varName = '$TBE_MODULES_EXT';
156 break;
157 case 7:
158 $theVar = $GLOBALS['TBE_STYLES'];
159 ArrayUtility::naturalKeySortRecursive($theVar);
160 $arrayBrowser->varName = '$TBE_STYLES';
161 break;
162 case 8:
163 $theVar = $GLOBALS['BE_USER']->uc;
164 ArrayUtility::naturalKeySortRecursive($theVar);
165 $arrayBrowser->varName = '$BE_USER->uc';
166 break;
167 case 9:
168 $theVar = $GLOBALS['TYPO3_USER_SETTINGS'];
169 ArrayUtility::naturalKeySortRecursive($theVar);
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
220 /**
221 * Injects the request object for the current request or subrequest
222 * Simply calls main() and init() and outputs the content
223 *
224 * @param ServerRequestInterface $request the current request
225 * @param ResponseInterface $response
226 * @return ResponseInterface the response with the content
227 */
228 public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
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
239 /**
240 * Print output to browser
241 *
242 * @return void
243 * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
244 */
245 public function printContent()
246 {
247 GeneralUtility::logDeprecatedFunction();
248 echo $this->content;
249 }
250
251 /**
252 * Generates the action menu
253 */
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 }