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