PageRenderTime 61ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 1ms

/typo3/sysext/lowlevel/config/index.php

https://github.com/but43r/TYPO3v4-Core
PHP | 406 lines | 236 code | 56 blank | 114 comment | 18 complexity | 836e8ebaba80b18bc6943a2ea3f76af5 MD5 | raw file
  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. unset($MCONF);
  51. require ('conf.php');
  52. require ($BACK_PATH.'init.php');
  53. require ($BACK_PATH.'template.php');
  54. $GLOBALS['LANG']->includeLLFile('EXT:lowlevel/config/locallang.xml');
  55. $BE_USER->modAccess($MCONF,1);
  56. /**
  57. * Script class for the Config module
  58. *
  59. * @author Kasper Skårhøj <kasperYYYY@typo3.com>
  60. * @package TYPO3
  61. * @subpackage tx_lowlevel
  62. */
  63. class SC_mod_tools_config_index {
  64. var $MCONF = array();
  65. var $MOD_MENU = array();
  66. var $MOD_SETTINGS = array();
  67. /**
  68. * document template object
  69. *
  70. * @var noDoc
  71. */
  72. var $doc;
  73. var $include_once = array();
  74. var $content;
  75. /**
  76. * Initialization
  77. *
  78. * @return void
  79. */
  80. function init() {
  81. global $BACK_PATH;
  82. $this->MCONF = $GLOBALS['MCONF'];
  83. $this->menuConfig();
  84. $this->doc = t3lib_div::makeInstance('template');
  85. $this->doc->backPath = $BACK_PATH;
  86. $this->doc->setModuleTemplate('templates/config.html');
  87. // JavaScript
  88. $this->doc->JScode = '
  89. <script language="javascript" type="text/javascript">
  90. script_ended = 0;
  91. function jumpToUrl(URL) {
  92. window.location.href = URL;
  93. }
  94. </script>
  95. ';
  96. $this->doc->form = '<form action="" method="post">';
  97. }
  98. /**
  99. * Menu Configuration
  100. *
  101. * @return void
  102. */
  103. function menuConfig() {
  104. global $TYPO3_CONF_VARS;
  105. // MENU-ITEMS:
  106. // If array, then it's a selector box menu
  107. // If empty string it's just a variable, that'll be saved.
  108. // Values NOT in this array will not be saved in the settings-array for the module.
  109. $this->MOD_MENU = array(
  110. 'function' => array(
  111. 0 => $GLOBALS['LANG']->getLL('typo3ConfVars', TRUE),
  112. 1 => $GLOBALS['LANG']->getLL('tca', TRUE),
  113. 2 => $GLOBALS['LANG']->getLL('tcaDescr', TRUE),
  114. 3 => $GLOBALS['LANG']->getLL('loadedExt', TRUE),
  115. 4 => $GLOBALS['LANG']->getLL('t3services', TRUE),
  116. 5 => $GLOBALS['LANG']->getLL('tbemodules', TRUE),
  117. 6 => $GLOBALS['LANG']->getLL('tbemodulesext', TRUE),
  118. 7 => $GLOBALS['LANG']->getLL('tbeStyles', TRUE),
  119. 8 => $GLOBALS['LANG']->getLL('beUser', TRUE),
  120. 9 => $GLOBALS['LANG']->getLL('usersettings', TRUE),
  121. ),
  122. 'regexsearch' => '',
  123. 'fixedLgd' => ''
  124. );
  125. // CLEANSE SETTINGS
  126. $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
  127. }
  128. /**
  129. * [Describe function...]
  130. *
  131. * @return [type] ...
  132. */
  133. function main() {
  134. $arrayBrowser = t3lib_div::makeInstance('t3lib_arrayBrowser');
  135. $this->content= $this->doc->header($GLOBALS['LANG']->getLL('configuration', TRUE));
  136. $this->content.= $this->doc->spacer(5);
  137. $this->content .= '<div id="lowlevel-config">
  138. <label for="search_field">' . $GLOBALS['LANG']->getLL('enterSearchPhrase', TRUE) . '</label>
  139. <input type="text" id="search_field" name="search_field" value="' . htmlspecialchars($search_field) . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' />
  140. <input type="submit" name="search" id="search" value="' . $GLOBALS['LANG']->getLL('search', TRUE) . '" />';
  141. $this->content .= t3lib_BEfunc::getFuncCheck(0,'SET[regexsearch]',$this->MOD_SETTINGS['regexsearch'],'','','id="checkRegexsearch"') .
  142. '<label for="checkRegexsearch">' . $GLOBALS['LANG']->getLL('useRegExp', TRUE) . '</label>';
  143. $this->content.= t3lib_BEfunc::getFuncCheck(0, 'SET[fixedLgd]', $this->MOD_SETTINGS['fixedLgd'], '', '', 'id="checkFixedLgd"') .
  144. '<label for="checkFixedLgd">' . $GLOBALS['LANG']->getLL('cropLines', TRUE) . '</label>
  145. </div>';
  146. $this->content.= $this->doc->spacer(5);
  147. switch($this->MOD_SETTINGS['function']) {
  148. case 0:
  149. $theVar = $GLOBALS['TYPO3_CONF_VARS'];
  150. t3lib_div::naturalKeySortRecursive($theVar);
  151. $arrayBrowser->varName = '$TYPO3_CONF_VARS';
  152. break;
  153. case 1:
  154. foreach ($GLOBALS['TCA'] as $table => $config) {
  155. t3lib_div::loadTCA($table);
  156. }
  157. $theVar = $GLOBALS['TCA'];
  158. t3lib_div::naturalKeySortRecursive($theVar);
  159. $arrayBrowser->varName = '$TCA';
  160. break;
  161. case 2:
  162. $theVar = $GLOBALS['TCA_DESCR'];
  163. t3lib_div::naturalKeySortRecursive($theVar);
  164. $arrayBrowser->varName = '$TCA_DESCR';
  165. break;
  166. case 3:
  167. $theVar = $GLOBALS['TYPO3_LOADED_EXT'];
  168. t3lib_div::naturalKeySortRecursive($theVar);
  169. $arrayBrowser->varName = '$TYPO3_LOADED_EXT';
  170. break;
  171. case 4:
  172. $theVar = $GLOBALS['T3_SERVICES'];
  173. t3lib_div::naturalKeySortRecursive($theVar);
  174. $arrayBrowser->varName = '$T3_SERVICES';
  175. break;
  176. case 5:
  177. $theVar = $GLOBALS['TBE_MODULES'];
  178. t3lib_div::naturalKeySortRecursive($theVar);
  179. $arrayBrowser->varName = '$TBE_MODULES';
  180. break;
  181. case 6:
  182. $theVar = $GLOBALS['TBE_MODULES_EXT'];
  183. t3lib_div::naturalKeySortRecursive($theVar);
  184. $arrayBrowser->varName = '$TBE_MODULES_EXT';
  185. break;
  186. case 7:
  187. $theVar = $GLOBALS['TBE_STYLES'];
  188. t3lib_div::naturalKeySortRecursive($theVar);
  189. $arrayBrowser->varName = '$TBE_STYLES';
  190. break;
  191. case 8:
  192. $theVar = $GLOBALS['BE_USER']->uc;
  193. t3lib_div::naturalKeySortRecursive($theVar);
  194. $arrayBrowser->varName = '$BE_USER->uc';
  195. break;
  196. case 9:
  197. $theVar = $GLOBALS['TYPO3_USER_SETTINGS'];
  198. t3lib_div::naturalKeySortRecursive($theVar);
  199. $arrayBrowser->varName = '$TYPO3_USER_SETTINGS';
  200. break;
  201. default:
  202. $theVar = array();
  203. break;
  204. }
  205. // Update node:
  206. $update = 0;
  207. $node = t3lib_div::_GET('node');
  208. if (is_array($node)) { // If any plus-signs were clicked, it's registred.
  209. $this->MOD_SETTINGS['node_'.$this->MOD_SETTINGS['function']] = $arrayBrowser->depthKeys($node, $this->MOD_SETTINGS['node_'.$this->MOD_SETTINGS['function']]);
  210. $update = 1;
  211. }
  212. if ($update) {
  213. $GLOBALS['BE_USER']->pushModuleData($this->MCONF['name'],$this->MOD_SETTINGS);
  214. }
  215. $arrayBrowser->depthKeys = $this->MOD_SETTINGS['node_'.$this->MOD_SETTINGS['function']];
  216. $arrayBrowser->regexMode = $this->MOD_SETTINGS['regexsearch'];
  217. $arrayBrowser->fixedLgd = $this->MOD_SETTINGS['fixedLgd'];
  218. $arrayBrowser->searchKeysToo = TRUE;
  219. $search_field = t3lib_div::_GP('search_field');
  220. if (t3lib_div::_POST('search') && trim($search_field)) { // If any POST-vars are send, update the condition array
  221. $arrayBrowser->depthKeys=$arrayBrowser->getSearchKeys($theVar, '', $search_field, array());
  222. }
  223. $tree = $arrayBrowser->tree($theVar, '', '');
  224. $label = $this->MOD_MENU['function'][$this->MOD_SETTINGS['function']];
  225. $this->content.= $this->doc->sectionEnd();
  226. // Variable name:
  227. if (t3lib_div::_GP('varname')) {
  228. $line = t3lib_div::_GP('_') ? t3lib_div::_GP('_') : t3lib_div::_GP('varname');
  229. if (t3lib_div::_GP('writetoexttables')) { // Write the line to extTables.php
  230. // change value to $GLOBALS
  231. $length = strpos($line, '[');
  232. $var = substr($line, 0, $length);
  233. $changedLine = '$GLOBALS[\'' . substr($line, 1, $length - 1) . '\']' . substr($line, $length);
  234. // load current extTables.php
  235. $extTables = t3lib_div::getURL(PATH_typo3conf . TYPO3_extTableDef_script);
  236. if ($var === '$TCA') {
  237. // check if we are editing the TCA
  238. preg_match_all('/\[\'([^\']+)\'\]/', $line, $parts);
  239. if ($parts[1][1] !== 'ctrl') {
  240. // anything else than ctrl section requires to load TCA
  241. $loadTCA = 't3lib_div::loadTCA(\'' . $parts[1][0] . '\');';
  242. if (strpos($extTables, $loadTCA) === FALSE) {
  243. // check if the loadTCA statement is not already present in the file
  244. $changedLine = $loadTCA . LF . $changedLine;
  245. }
  246. }
  247. }
  248. // insert line in extTables.php
  249. $extTables = preg_replace('/<\?php|\?>/is', '', $extTables);
  250. $extTables = '<?php' . (empty($extTables) ? LF : '') . $extTables . $changedLine . LF . '?>';
  251. $success = t3lib_div::writeFile(PATH_typo3conf . TYPO3_extTableDef_script, $extTables);
  252. if ($success) {
  253. // show flash message
  254. $flashMessage = t3lib_div::makeInstance(
  255. 't3lib_FlashMessage',
  256. '',
  257. sprintf($GLOBALS['LANG']->getLL('writeMessage', TRUE), TYPO3_extTableDef_script, '<br />', '<strong>' . nl2br($changedLine) . '</strong>'),
  258. t3lib_FlashMessage::OK
  259. );
  260. } else {
  261. // Error: show flash message
  262. $flashMessage = t3lib_div::makeInstance(
  263. 't3lib_FlashMessage',
  264. '',
  265. sprintf($GLOBALS['LANG']->getLL('writeMessageFailed', TRUE), TYPO3_extTableDef_script),
  266. t3lib_FlashMessage::ERROR
  267. );
  268. }
  269. $this->content .= $flashMessage->render();
  270. }
  271. $this->content .= '<div id="lowlevel-config-var">
  272. <strong>' . $GLOBALS['LANG']->getLL('variable', TRUE) . '</strong><br />
  273. <input type="text" name="_" value="'.trim(htmlspecialchars($line)).'" size="120" /><br/>';
  274. if (TYPO3_extTableDef_script !== '' && ($this->MOD_SETTINGS['function'] === '1' || $this->MOD_SETTINGS['function'] === '4')) {
  275. // write only for $TCA and TBE_STYLES if TYPO3_extTableDef_script is defined
  276. $this->content .= '<br /><input type="submit" name="writetoexttables" value="' .
  277. $GLOBALS['LANG']->getLL('writeValue', TRUE) . '" /></div>';
  278. } else {
  279. $this->content .= $GLOBALS['LANG']->getLL('copyPaste', TRUE) . LF . '</div>';
  280. }
  281. }
  282. $this->content.= '<br /><table border="0" cellpadding="0" cellspacing="0" class="t3-tree t3-tree-config">';
  283. $this->content.= '<tr>
  284. <th class="t3-row-header t3-tree-config-header">' . $label . '</th>
  285. </tr>
  286. <tr>
  287. <td>' . $tree . '</td>
  288. </tr>
  289. </table>
  290. ';
  291. // Setting up the buttons and markers for docheader
  292. $docHeaderButtons = $this->getButtons();
  293. $markers = array(
  294. 'CSH' => $docHeaderButtons['csh'],
  295. 'FUNC_MENU' => $this->getFuncMenu(),
  296. 'CONTENT' => $this->content
  297. );
  298. // Build the <body> for the module
  299. $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
  300. // Renders the module page
  301. $this->content = $this->doc->render(
  302. 'Configuration',
  303. $this->content
  304. );
  305. }
  306. /**
  307. * Print output to browser
  308. *
  309. * @return void
  310. */
  311. function printContent() {
  312. echo $this->content;
  313. }
  314. /**
  315. * Create the panel of buttons for submitting the form or otherwise perform operations.
  316. *
  317. * @return array all available buttons as an assoc. array
  318. */
  319. protected function getButtons() {
  320. $buttons = array(
  321. 'csh' => '',
  322. 'shortcut' => ''
  323. );
  324. // CSH
  325. //$buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']);
  326. // Shortcut
  327. if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
  328. $buttons['shortcut'] = $this->doc->makeShortcutIcon('','function',$this->MCONF['name']);
  329. }
  330. return $buttons;
  331. }
  332. /**
  333. * Create the function menu
  334. *
  335. * @return string HTML of the function menu
  336. */
  337. protected function getFuncMenu() {
  338. $funcMenu = t3lib_BEfunc::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
  339. return $funcMenu;
  340. }
  341. }
  342. if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/lowlevel/config/index.php'])) {
  343. include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/lowlevel/config/index.php']);
  344. }
  345. // Make instance:
  346. $SOBE = t3lib_div::makeInstance('SC_mod_tools_config_index');
  347. $SOBE->init();
  348. $SOBE->main();
  349. $SOBE->printContent();
  350. ?>