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