[TASK] Remove usage of modTmpl->setForm from ConfigurationView
[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\Components\ButtonBar;
21 use TYPO3\CMS\Backend\Template\ModuleTemplate;
22 use TYPO3\CMS\Backend\Utility\BackendUtility;
23 use TYPO3\CMS\Core\Utility\ArrayUtility;
24 use TYPO3\CMS\Core\Utility\GeneralUtility;
25 use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
26 use TYPO3\CMS\Fluid\View\StandaloneView;
27 use TYPO3\CMS\Lowlevel\Utility\ArrayBrowser;
28
29 /**
30 * Script class for the Config module
31 */
32 class ConfigurationView extends BaseScriptClass
33 {
34 /**
35 * @var StandaloneView
36 */
37 protected $view;
38
39 /**
40 * The name of the module
41 *
42 * @var string
43 */
44 protected $moduleName = 'system_config';
45
46 /**
47 * ModuleTemplate Container
48 *
49 * @var ModuleTemplate
50 */
51 protected $moduleTemplate;
52
53 /**
54 * Constructor
55 */
56 public function __construct()
57 {
58 $this->view = GeneralUtility::makeInstance(StandaloneView::class);
59 $this->view->getRequest()->setControllerExtensionName('lowlevel');
60 }
61
62 /**
63 * Initialization
64 *
65 * @return void
66 */
67 public function init()
68 {
69 $this->menuConfig();
70 $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
71 }
72
73 /**
74 * Menu Configuration
75 *
76 * @return void
77 */
78 public function menuConfig()
79 {
80 // MENU-ITEMS:
81 // If array, then it's a selector box menu
82 // If empty string it's just a variable, that'll be saved.
83 // Values NOT in this array will not be saved in the settings-array for the module.
84 $this->MOD_MENU = array(
85 'function' => array(
86 0 => LocalizationUtility::translate('typo3ConfVars', 'lowlevel'),
87 1 => LocalizationUtility::translate('tca', 'lowlevel'),
88 2 => LocalizationUtility::translate('tcaDescr', 'lowlevel'),
89 3 => LocalizationUtility::translate('loadedExt', 'lowlevel'),
90 4 => LocalizationUtility::translate('t3services', 'lowlevel'),
91 5 => LocalizationUtility::translate('tbemodules', 'lowlevel'),
92 6 => LocalizationUtility::translate('tbemodulesext', 'lowlevel'),
93 7 => LocalizationUtility::translate('tbeStyles', 'lowlevel'),
94 8 => LocalizationUtility::translate('beUser', 'lowlevel'),
95 9 => LocalizationUtility::translate('usersettings', 'lowlevel')
96 ),
97 'regexsearch' => '',
98 'fixedLgd' => ''
99 );
100 // CLEANSE SETTINGS
101 $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->moduleName);
102 }
103
104 /**
105 * Main function
106 *
107 * @return void
108 */
109 public function main()
110 {
111 /** @var ArrayBrowser $arrayBrowser */
112 $arrayBrowser = GeneralUtility::makeInstance(ArrayBrowser::class);
113 $label = $this->MOD_MENU['function'][$this->MOD_SETTINGS['function']];
114 $search_field = GeneralUtility::_GP('search_field');
115
116 $templatePathAndFilename = GeneralUtility::getFileAbsFileName('EXT:lowlevel/Resources/Private/Templates/Backend/Configuration.html');
117 $this->view->setTemplatePathAndFilename($templatePathAndFilename);
118 $this->view->assign('label', $label);
119 $this->view->assign('search_field', $search_field);
120 $this->view->assign('checkbox_checkRegexsearch', BackendUtility::getFuncCheck(0, 'SET[regexsearch]', $this->MOD_SETTINGS['regexsearch'], '', '', 'id="checkRegexsearch"'));
121
122 switch ($this->MOD_SETTINGS['function']) {
123 case 0:
124 $theVar = $GLOBALS['TYPO3_CONF_VARS'];
125 ArrayUtility::naturalKeySortRecursive($theVar);
126 $arrayBrowser->varName = '$TYPO3_CONF_VARS';
127 break;
128 case 1:
129 $theVar = $GLOBALS['TCA'];
130 ArrayUtility::naturalKeySortRecursive($theVar);
131 $arrayBrowser->varName = '$TCA';
132 break;
133 case 2:
134 $theVar = $GLOBALS['TCA_DESCR'];
135 ArrayUtility::naturalKeySortRecursive($theVar);
136 $arrayBrowser->varName = '$TCA_DESCR';
137 break;
138 case 3:
139 $theVar = $GLOBALS['TYPO3_LOADED_EXT'];
140 ArrayUtility::naturalKeySortRecursive($theVar);
141 $arrayBrowser->varName = '$TYPO3_LOADED_EXT';
142 break;
143 case 4:
144 $theVar = $GLOBALS['T3_SERVICES'];
145 ArrayUtility::naturalKeySortRecursive($theVar);
146 $arrayBrowser->varName = '$T3_SERVICES';
147 break;
148 case 5:
149 $theVar = $GLOBALS['TBE_MODULES'];
150 ArrayUtility::naturalKeySortRecursive($theVar);
151 $arrayBrowser->varName = '$TBE_MODULES';
152 break;
153 case 6:
154 $theVar = $GLOBALS['TBE_MODULES_EXT'];
155 ArrayUtility::naturalKeySortRecursive($theVar);
156 $arrayBrowser->varName = '$TBE_MODULES_EXT';
157 break;
158 case 7:
159 $theVar = $GLOBALS['TBE_STYLES'];
160 ArrayUtility::naturalKeySortRecursive($theVar);
161 $arrayBrowser->varName = '$TBE_STYLES';
162 break;
163 case 8:
164 $theVar = $GLOBALS['BE_USER']->uc;
165 ArrayUtility::naturalKeySortRecursive($theVar);
166 $arrayBrowser->varName = '$BE_USER->uc';
167 break;
168 case 9:
169 $theVar = $GLOBALS['TYPO3_USER_SETTINGS'];
170 ArrayUtility::naturalKeySortRecursive($theVar);
171 $arrayBrowser->varName = '$TYPO3_USER_SETTINGS';
172 break;
173 default:
174 $theVar = array();
175 }
176 // Update node:
177 $update = 0;
178 $node = GeneralUtility::_GET('node');
179 // If any plus-signs were clicked, it's registred.
180 if (is_array($node)) {
181 $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']] = $arrayBrowser->depthKeys($node, $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']]);
182 $update = 1;
183 }
184 if ($update) {
185 $this->getBackendUser()->pushModuleData($this->moduleName, $this->MOD_SETTINGS);
186 }
187 $arrayBrowser->dontLinkVar = true;
188 $arrayBrowser->depthKeys = $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']];
189 $arrayBrowser->regexMode = $this->MOD_SETTINGS['regexsearch'];
190 $arrayBrowser->fixedLgd = $this->MOD_SETTINGS['fixedLgd'];
191 $arrayBrowser->searchKeysToo = true;
192
193 // If any POST-vars are send, update the condition array
194 if (GeneralUtility::_POST('search') && trim($search_field)) {
195 $arrayBrowser->depthKeys = $arrayBrowser->getSearchKeys($theVar, '', $search_field, array());
196 }
197 // mask the encryption key to not show it as plaintext in the configuration module
198 if ($theVar == $GLOBALS['TYPO3_CONF_VARS']) {
199 $theVar['SYS']['encryptionKey'] = '***** (length: ' . strlen($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']) . ' characters)';
200 }
201 $tree = $arrayBrowser->tree($theVar, '', '');
202 $this->view->assign('tree', $tree);
203
204 // Setting up the shortcut button for docheader
205 $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
206 // Shortcut
207 $shortcutButton = $buttonBar->makeShortcutButton()
208 ->setModuleName($this->moduleName)
209 ->setDisplayName($this->MOD_MENU['function'][$this->MOD_SETTINGS['function']])
210 ->setSetVariables(['function']);
211 $buttonBar->addButton($shortcutButton);
212
213 $this->getModuleMenu();
214
215 $this->content = '<form action="" id="ConfigurationView" method="post">';
216 $this->content .= $this->view->render();
217 $this->content .= '</form>';
218 }
219
220
221 /**
222 * Injects the request object for the current request or subrequest
223 * Simply calls main() and init() and outputs the content
224 *
225 * @param ServerRequestInterface $request the current request
226 * @param ResponseInterface $response
227 * @return ResponseInterface the response with the content
228 */
229 public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
230 {
231 $GLOBALS['SOBE'] = $this;
232 $this->init();
233 $this->main();
234
235 $this->moduleTemplate->setContent($this->content);
236 $response->getBody()->write($this->moduleTemplate->renderContent());
237 return $response;
238 }
239
240 /**
241 * Print output to browser
242 *
243 * @return void
244 * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
245 */
246 public function printContent()
247 {
248 GeneralUtility::logDeprecatedFunction();
249 echo $this->content;
250 }
251
252 /**
253 * Generates the action menu
254 */
255 protected function getModuleMenu()
256 {
257 $menu = $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
258 $menu->setIdentifier('ConfigurationJumpMenu');
259
260 foreach ($this->MOD_MENU['function'] as $controller => $title) {
261 $item = $menu
262 ->makeMenuItem()
263 ->setHref(
264 BackendUtility::getModuleUrl(
265 $this->moduleName,
266 [
267 'id' => $this->id,
268 'SET' => [
269 'function' => $controller
270 ]
271 ]
272 )
273 )
274 ->setTitle($title);
275 if ($controller === (int)$this->MOD_SETTINGS['function']) {
276 $item->setActive(true);
277 }
278 $menu->addMenuItem($item);
279 }
280 $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
281 }
282 }