1f53d906ca3efe405dc83bb8795dbbe7cacaab48
[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\DocumentTemplate;
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 * Constructor
47 */
48 public function __construct()
49 {
50 $this->view = GeneralUtility::makeInstance(StandaloneView::class);
51 $this->view->getRequest()->setControllerExtensionName('lowlevel');
52 }
53
54 /**
55 * Initialization
56 *
57 * @return void
58 */
59 public function init()
60 {
61 $this->menuConfig();
62 $this->doc = GeneralUtility::makeInstance(DocumentTemplate::class);
63 $this->doc->setModuleTemplate('EXT:lowlevel/Resources/Private/Templates/config.html');
64 $this->doc->form = '<form action="" method="post">';
65 $this->doc->addStyleSheet('module', 'sysext/lowlevel/Resources/Public/Css/styles.css');
66 $this->doc->bodyTagId = 'ext-lowlevel-Modules-Configuration-index-php';
67 }
68
69 /**
70 * Menu Configuration
71 *
72 * @return void
73 */
74 public function menuConfig()
75 {
76 // MENU-ITEMS:
77 // If array, then it's a selector box menu
78 // If empty string it's just a variable, that'll be saved.
79 // Values NOT in this array will not be saved in the settings-array for the module.
80 $this->MOD_MENU = array(
81 'function' => array(
82 0 => LocalizationUtility::translate('typo3ConfVars', 'lowlevel'),
83 1 => LocalizationUtility::translate('tca', 'lowlevel'),
84 2 => LocalizationUtility::translate('tcaDescr', 'lowlevel'),
85 3 => LocalizationUtility::translate('loadedExt', 'lowlevel'),
86 4 => LocalizationUtility::translate('t3services', 'lowlevel'),
87 5 => LocalizationUtility::translate('tbemodules', 'lowlevel'),
88 6 => LocalizationUtility::translate('tbemodulesext', 'lowlevel'),
89 7 => LocalizationUtility::translate('tbeStyles', 'lowlevel'),
90 8 => LocalizationUtility::translate('beUser', 'lowlevel'),
91 9 => LocalizationUtility::translate('usersettings', 'lowlevel')
92 ),
93 'regexsearch' => '',
94 'fixedLgd' => ''
95 );
96 // CLEANSE SETTINGS
97 $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->moduleName);
98 }
99
100 /**
101 * Main function
102 *
103 * @return void
104 */
105 public function main()
106 {
107 /** @var ArrayBrowser $arrayBrowser */
108 $arrayBrowser = GeneralUtility::makeInstance(ArrayBrowser::class);
109 $label = $this->MOD_MENU['function'][$this->MOD_SETTINGS['function']];
110 $search_field = GeneralUtility::_GP('search_field');
111
112 $templatePathAndFilename = GeneralUtility::getFileAbsFileName('EXT:lowlevel/Resources/Private/Templates/Backend/Configuration.html');
113 $this->view->setTemplatePathAndFilename($templatePathAndFilename);
114 $this->view->assign('label', $label);
115 $this->view->assign('search_field', $search_field);
116 $this->view->assign('checkbox_checkRegexsearch', BackendUtility::getFuncCheck(0, 'SET[regexsearch]', $this->MOD_SETTINGS['regexsearch'], '', '', 'id="checkRegexsearch"'));
117
118 switch ($this->MOD_SETTINGS['function']) {
119 case 0:
120 $theVar = $GLOBALS['TYPO3_CONF_VARS'];
121 ArrayUtility::naturalKeySortRecursive($theVar);
122 $arrayBrowser->varName = '$TYPO3_CONF_VARS';
123 break;
124 case 1:
125 $theVar = $GLOBALS['TCA'];
126 ArrayUtility::naturalKeySortRecursive($theVar);
127 $arrayBrowser->varName = '$TCA';
128 break;
129 case 2:
130 $theVar = $GLOBALS['TCA_DESCR'];
131 ArrayUtility::naturalKeySortRecursive($theVar);
132 $arrayBrowser->varName = '$TCA_DESCR';
133 break;
134 case 3:
135 $theVar = $GLOBALS['TYPO3_LOADED_EXT'];
136 ArrayUtility::naturalKeySortRecursive($theVar);
137 $arrayBrowser->varName = '$TYPO3_LOADED_EXT';
138 break;
139 case 4:
140 $theVar = $GLOBALS['T3_SERVICES'];
141 ArrayUtility::naturalKeySortRecursive($theVar);
142 $arrayBrowser->varName = '$T3_SERVICES';
143 break;
144 case 5:
145 $theVar = $GLOBALS['TBE_MODULES'];
146 ArrayUtility::naturalKeySortRecursive($theVar);
147 $arrayBrowser->varName = '$TBE_MODULES';
148 break;
149 case 6:
150 $theVar = $GLOBALS['TBE_MODULES_EXT'];
151 ArrayUtility::naturalKeySortRecursive($theVar);
152 $arrayBrowser->varName = '$TBE_MODULES_EXT';
153 break;
154 case 7:
155 $theVar = $GLOBALS['TBE_STYLES'];
156 ArrayUtility::naturalKeySortRecursive($theVar);
157 $arrayBrowser->varName = '$TBE_STYLES';
158 break;
159 case 8:
160 $theVar = $GLOBALS['BE_USER']->uc;
161 ArrayUtility::naturalKeySortRecursive($theVar);
162 $arrayBrowser->varName = '$BE_USER->uc';
163 break;
164 case 9:
165 $theVar = $GLOBALS['TYPO3_USER_SETTINGS'];
166 ArrayUtility::naturalKeySortRecursive($theVar);
167 $arrayBrowser->varName = '$TYPO3_USER_SETTINGS';
168 break;
169 default:
170 $theVar = array();
171 }
172 // Update node:
173 $update = 0;
174 $node = GeneralUtility::_GET('node');
175 // If any plus-signs were clicked, it's registred.
176 if (is_array($node)) {
177 $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']] = $arrayBrowser->depthKeys($node, $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']]);
178 $update = 1;
179 }
180 if ($update) {
181 $this->getBackendUser()->pushModuleData($this->moduleName, $this->MOD_SETTINGS);
182 }
183 $arrayBrowser->dontLinkVar = true;
184 $arrayBrowser->depthKeys = $this->MOD_SETTINGS['node_' . $this->MOD_SETTINGS['function']];
185 $arrayBrowser->regexMode = $this->MOD_SETTINGS['regexsearch'];
186 $arrayBrowser->fixedLgd = $this->MOD_SETTINGS['fixedLgd'];
187 $arrayBrowser->searchKeysToo = true;
188
189 // If any POST-vars are send, update the condition array
190 if (GeneralUtility::_POST('search') && trim($search_field)) {
191 $arrayBrowser->depthKeys = $arrayBrowser->getSearchKeys($theVar, '', $search_field, array());
192 }
193 // mask the encryption key to not show it as plaintext in the configuration module
194 if ($theVar == $GLOBALS['TYPO3_CONF_VARS']) {
195 $theVar['SYS']['encryptionKey'] = '***** (length: ' . strlen($GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']) . ' characters)';
196 }
197 $tree = $arrayBrowser->tree($theVar, '', '');
198 $this->view->assign('tree', $tree);
199
200 // Setting up the buttons and markers for docheader
201 $docHeaderButtons = $this->getButtons();
202 $markers = array(
203 'CSH' => $docHeaderButtons['csh'],
204 'FUNC_MENU' => $this->getFuncMenu(),
205 'CONTENT' => $this->view->render(),
206 );
207 // Build the <body> for the module
208 $this->content = $this->doc->moduleBody(array(), $docHeaderButtons, $markers);
209 // Renders the module page
210 $this->content = $this->doc->render('Configuration', $this->content);
211 }
212
213
214 /**
215 * Injects the request object for the current request or subrequest
216 * Simply calls main() and init() and outputs the content
217 *
218 * @param ServerRequestInterface $request the current request
219 * @param ResponseInterface $response
220 * @return ResponseInterface the response with the content
221 */
222 public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
223 {
224 $GLOBALS['SOBE'] = $this;
225 $this->init();
226 $this->main();
227
228 $response->getBody()->write($this->content);
229 return $response;
230 }
231
232 /**
233 * Print output to browser
234 *
235 * @return void
236 * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
237 */
238 public function printContent()
239 {
240 GeneralUtility::logDeprecatedFunction();
241 echo $this->content;
242 }
243
244 /**
245 * Create the panel of buttons for submitting the form or otherwise perform operations.
246 *
247 * @return array All available buttons as an assoc. array
248 */
249 protected function getButtons()
250 {
251 $buttons = array(
252 'csh' => '',
253 'shortcut' => ''
254 );
255 // Shortcut
256 if ($this->getBackendUser()->mayMakeShortcut()) {
257 $buttons['shortcut'] = $this->doc->makeShortcutIcon('', 'function', $this->moduleName);
258 }
259 return $buttons;
260 }
261
262 /**
263 * Create the function menu
264 *
265 * @return string HTML of the function menu
266 */
267 protected function getFuncMenu()
268 {
269 $funcMenu = BackendUtility::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
270 return $funcMenu;
271 }
272 }