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