Cleanup: Updated copyright comments
[Packages/TYPO3.CMS.git] / typo3 / sysext / lowlevel / config / index.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Module: Config
29 *
30 * This module lets you view the config variables around TYPO3.
31 *
32 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
33 */
34 /**
35 * [CLASS/FUNCTION INDEX of SCRIPT]
36 *
37 *
38 *
39 * 72: class SC_mod_tools_config_index
40 * 89: function init()
41 * 103: function jumpToUrl(URL)
42 * 117: function menuConfig()
43 * 144: function main()
44 * 268: function printContent()
45 *
46 * TOTAL FUNCTIONS: 5
47 * (This index is automatically created/updated by the extension "extdeveval")
48 *
49 */
50
51 unset($MCONF);
52 require ('conf.php');
53 require ($BACK_PATH.'init.php');
54 require ($BACK_PATH.'template.php');
55 $GLOBALS['LANG']->includeLLFile('EXT:lowlevel/config/locallang.xml');
56
57 $BE_USER->modAccess($MCONF,1);
58
59
60
61
62
63
64
65 /**
66 * Script class for the Config module
67 *
68 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
69 * @package TYPO3
70 * @subpackage tx_lowlevel
71 */
72 class SC_mod_tools_config_index {
73
74 var $MCONF = array();
75 var $MOD_MENU = array();
76 var $MOD_SETTINGS = array();
77
78 /**
79 * document template object
80 *
81 * @var noDoc
82 */
83 var $doc;
84
85 var $include_once = array();
86 var $content;
87
88
89
90 /**
91 * Initialization
92 *
93 * @return void
94 */
95 function init() {
96 global $BACK_PATH;
97
98 $this->MCONF = $GLOBALS['MCONF'];
99
100 $this->menuConfig();
101
102 $this->doc = t3lib_div::makeInstance('template');
103 $this->doc->backPath = $BACK_PATH;
104 $this->doc->setModuleTemplate('templates/config.html');
105
106 // JavaScript
107 $this->doc->JScode = '
108 <script language="javascript" type="text/javascript">
109 script_ended = 0;
110 function jumpToUrl(URL) {
111 window.location.href = URL;
112 }
113 </script>
114 ';
115
116 $this->doc->form = '<form action="" method="post">';
117 }
118
119 /**
120 * Menu Configuration
121 *
122 * @return void
123 */
124 function menuConfig() {
125 global $TYPO3_CONF_VARS;
126
127 // MENU-ITEMS:
128 // If array, then it's a selector box menu
129 // If empty string it's just a variable, that'll be saved.
130 // Values NOT in this array will not be saved in the settings-array for the module.
131 $this->MOD_MENU = array(
132 'function' => array(
133 0 => $GLOBALS['LANG']->getLL('typo3ConfVars', true),
134 1 => $GLOBALS['LANG']->getLL('tca', true),
135 2 => $GLOBALS['LANG']->getLL('tcaDescr', true),
136 3 => $GLOBALS['LANG']->getLL('loadedExt', true),
137 4 => $GLOBALS['LANG']->getLL('t3services', true),
138 5 => $GLOBALS['LANG']->getLL('tbemodules', true),
139 6 => $GLOBALS['LANG']->getLL('tbemodulesext', true),
140 7 => $GLOBALS['LANG']->getLL('tbeStyles', true),
141 8 => $GLOBALS['LANG']->getLL('beUser', true),
142 9 => $GLOBALS['LANG']->getLL('usersettings', true),
143 ),
144 'regexsearch' => '',
145 'fixedLgd' => ''
146 );
147
148 // CLEANSE SETTINGS
149 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
150 }
151
152 /**
153 * [Describe function...]
154 *
155 * @return [type] ...
156 */
157 function main() {
158
159 $arrayBrowser = t3lib_div::makeInstance('t3lib_arrayBrowser');
160
161 $this->content= $this->doc->header($GLOBALS['LANG']->getLL('configuration', true));
162 $this->content.= $this->doc->spacer(5);
163
164 $this->content .= '<div id="lowlevel-config">
165 <label for="search_field">' . $GLOBALS['LANG']->getLL('enterSearchPhrase', true) . '</label>
166 <input type="text" id="search_field" name="search_field" value="' . htmlspecialchars($search_field) . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' />
167 <input type="submit" name="search" id="search" value="' . $GLOBALS['LANG']->getLL('search', true) . '" />';
168 $this->content .= t3lib_BEfunc::getFuncCheck(0,'SET[regexsearch]',$this->MOD_SETTINGS['regexsearch'],'','','id="checkRegexsearch"') .
169 '<label for="checkRegexsearch">' . $GLOBALS['LANG']->getLL('useRegExp', true) . '</label>';
170
171 $this->content.= t3lib_BEfunc::getFuncCheck(0, 'SET[fixedLgd]', $this->MOD_SETTINGS['fixedLgd'], '', '', 'id="checkFixedLgd"') .
172 '<label for="checkFixedLgd">' . $GLOBALS['LANG']->getLL('cropLines', true) . '</label>
173 </div>';
174
175 $this->content.= $this->doc->spacer(5);
176
177 switch($this->MOD_SETTINGS['function']) {
178 case 0:
179 $theVar = $GLOBALS['TYPO3_CONF_VARS'];
180 t3lib_div::naturalKeySortRecursive($theVar);
181 $arrayBrowser->varName = '$TYPO3_CONF_VARS';
182 break;
183 case 1:
184 foreach ($GLOBALS['TCA'] as $table => $config) {
185 t3lib_div::loadTCA($table);
186 }
187 $theVar = $GLOBALS['TCA'];
188 t3lib_div::naturalKeySortRecursive($theVar);
189 $arrayBrowser->varName = '$TCA';
190 break;
191 case 2:
192 $theVar = $GLOBALS['TCA_DESCR'];
193 t3lib_div::naturalKeySortRecursive($theVar);
194 $arrayBrowser->varName = '$TCA_DESCR';
195 break;
196 case 3:
197 $theVar = $GLOBALS['TYPO3_LOADED_EXT'];
198 t3lib_div::naturalKeySortRecursive($theVar);
199 $arrayBrowser->varName = '$TYPO3_LOADED_EXT';
200 break;
201 case 4:
202 $theVar = $GLOBALS['T3_SERVICES'];
203 t3lib_div::naturalKeySortRecursive($theVar);
204 $arrayBrowser->varName = '$T3_SERVICES';
205 break;
206 case 5:
207 $theVar = $GLOBALS['TBE_MODULES'];
208 t3lib_div::naturalKeySortRecursive($theVar);
209 $arrayBrowser->varName = '$TBE_MODULES';
210 break;
211 case 6:
212 $theVar = $GLOBALS['TBE_MODULES_EXT'];
213 t3lib_div::naturalKeySortRecursive($theVar);
214 $arrayBrowser->varName = '$TBE_MODULES_EXT';
215 break;
216 case 7:
217 $theVar = $GLOBALS['TBE_STYLES'];
218 t3lib_div::naturalKeySortRecursive($theVar);
219 $arrayBrowser->varName = '$TBE_STYLES';
220 break;
221 case 8:
222 $theVar = $GLOBALS['BE_USER']->uc;
223 t3lib_div::naturalKeySortRecursive($theVar);
224 $arrayBrowser->varName = '$BE_USER->uc';
225 break;
226 case 9:
227 $theVar = $GLOBALS['TYPO3_USER_SETTINGS'];
228 t3lib_div::naturalKeySortRecursive($theVar);
229 $arrayBrowser->varName = '$TYPO3_USER_SETTINGS';
230 break;
231 default:
232 $theVar = array();
233 break;
234 }
235
236
237 // Update node:
238 $update = 0;
239 $node = t3lib_div::_GET('node');
240 if (is_array($node)) { // If any plus-signs were clicked, it's registred.
241 $this->MOD_SETTINGS['node_'.$this->MOD_SETTINGS['function']] = $arrayBrowser->depthKeys($node, $this->MOD_SETTINGS['node_'.$this->MOD_SETTINGS['function']]);
242 $update = 1;
243 }
244 if ($update) {
245 $GLOBALS['BE_USER']->pushModuleData($this->MCONF['name'],$this->MOD_SETTINGS);
246 }
247
248 $arrayBrowser->depthKeys = $this->MOD_SETTINGS['node_'.$this->MOD_SETTINGS['function']];
249 $arrayBrowser->regexMode = $this->MOD_SETTINGS['regexsearch'];
250 $arrayBrowser->fixedLgd = $this->MOD_SETTINGS['fixedLgd'];
251 $arrayBrowser->searchKeysToo = TRUE;
252
253
254 $search_field = t3lib_div::_GP('search_field');
255 if (t3lib_div::_POST('search') && trim($search_field)) { // If any POST-vars are send, update the condition array
256 $arrayBrowser->depthKeys=$arrayBrowser->getSearchKeys($theVar, '', $search_field, array());
257 }
258
259 $tree = $arrayBrowser->tree($theVar, '', '');
260
261 $label = $this->MOD_MENU['function'][$this->MOD_SETTINGS['function']];
262 $this->content.= $this->doc->sectionEnd();
263
264 // Variable name:
265 if (t3lib_div::_GP('varname')) {
266 $line = t3lib_div::_GP('_') ? t3lib_div::_GP('_') : t3lib_div::_GP('varname');
267 if (t3lib_div::_GP('writetoexttables')) { // Write the line to extTables.php
268 // change value to $GLOBALS
269 $length = strpos($line, '[');
270 $var = substr($line, 0, $length);
271 $changedLine = '$GLOBALS[\'' . substr($line, 1, $length - 1) . '\']' . substr($line, $length);
272 // insert line in extTables.php
273 $extTables = t3lib_div::getURL(PATH_typo3conf . TYPO3_extTableDef_script);
274 $extTables = '<?php' . preg_replace('/<\?php|\?>/is', '', $extTables) . $changedLine . LF . '?>';
275 $success = t3lib_div::writeFile(PATH_typo3conf . TYPO3_extTableDef_script, $extTables);
276 if ($success) {
277 // show flash message
278 $flashMessage = t3lib_div::makeInstance(
279 't3lib_FlashMessage',
280 '',
281 sprintf($GLOBALS['LANG']->getLL('writeMessage', TRUE), TYPO3_extTableDef_script, '<br />', '<strong>' . $changedLine . '</strong>'),
282 t3lib_FlashMessage::OK
283 );
284 } else {
285 // Error: show flash message
286 $flashMessage = t3lib_div::makeInstance(
287 't3lib_FlashMessage',
288 '',
289 sprintf($GLOBALS['LANG']->getLL('writeMessageFailed', TRUE), TYPO3_extTableDef_script),
290 t3lib_FlashMessage::ERROR
291 );
292 }
293 $this->content .= $flashMessage->render();
294 }
295 $this->content .= '<div id="lowlevel-config-var">
296 <strong>' . $GLOBALS['LANG']->getLL('variable', TRUE) . '</strong><br />
297 <input type="text" name="_" value="'.trim(htmlspecialchars($line)).'" size="120" /><br/>';
298
299 if (TYPO3_extTableDef_script !== '' && ($this->MOD_SETTINGS['function'] === '1' || $this->MOD_SETTINGS['function'] === '4')) {
300 // write only for $TCA and TBE_STYLES if TYPO3_extTableDef_script is defined
301 $this->content .= '<br /><input type="submit" name="writetoexttables" value="' .
302 $GLOBALS['LANG']->getLL('writeValue', TRUE) . '" /></div>';
303 } else {
304 $this->content .= $GLOBALS['LANG']->getLL('copyPaste', TRUE) . LF . '</div>';
305 }
306
307 }
308
309 $this->content.= '<br /><table border="0" cellpadding="0" cellspacing="0" class="t3-tree t3-tree-config">';
310 $this->content.= '<tr>
311 <th class="t3-row-header t3-tree-config-header">' . $label . '</th>
312 </tr>
313 <tr>
314 <td>' . $tree . '</td>
315 </tr>
316 </table>
317 ';
318
319
320 // Setting up the buttons and markers for docheader
321 $docHeaderButtons = $this->getButtons();
322 $markers = array(
323 'CSH' => $docHeaderButtons['csh'],
324 'FUNC_MENU' => $this->getFuncMenu(),
325 'CONTENT' => $this->content
326 );
327
328 // Build the <body> for the module
329 $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
330 // Renders the module page
331 $this->content = $this->doc->render(
332 'Configuration',
333 $this->content
334 );
335 }
336
337 /**
338 * Print output to browser
339 *
340 * @return void
341 */
342 function printContent() {
343 echo $this->content;
344 }
345
346 /**
347 * Create the panel of buttons for submitting the form or otherwise perform operations.
348 *
349 * @return array all available buttons as an assoc. array
350 */
351 protected function getButtons() {
352
353 $buttons = array(
354 'csh' => '',
355 'shortcut' => ''
356 );
357 // CSH
358 //$buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']);
359
360 // Shortcut
361 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
362 $buttons['shortcut'] = $this->doc->makeShortcutIcon('','function',$this->MCONF['name']);
363 }
364 return $buttons;
365 }
366
367 /**
368 * Create the function menu
369 *
370 * @return string HTML of the function menu
371 */
372 protected function getFuncMenu() {
373 $funcMenu = t3lib_BEfunc::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
374 return $funcMenu;
375 }
376 }
377
378
379 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/lowlevel/config/index.php'])) {
380 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/lowlevel/config/index.php']);
381 }
382
383
384
385
386 // Make instance:
387 $SOBE = t3lib_div::makeInstance('SC_mod_tools_config_index');
388 $SOBE->init();
389 $SOBE->main();
390 $SOBE->printContent();
391 ?>