TYPO3 API  SVNRelease
index.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 /**
00028  * Module: Config
00029  *
00030  * This module lets you view the config variables around TYPO3.
00031  *
00032  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00033  */
00034 /**
00035  * [CLASS/FUNCTION INDEX of SCRIPT]
00036  *
00037  *
00038  *
00039  *   72: class SC_mod_tools_config_index
00040  *   89:     function init()
00041  *  103:     function jumpToUrl(URL)
00042  *  117:     function menuConfig()
00043  *  144:     function main()
00044  *  268:     function printContent()
00045  *
00046  * TOTAL FUNCTIONS: 5
00047  * (This index is automatically created/updated by the extension "extdeveval")
00048  *
00049  */
00050 
00051 unset($MCONF);
00052 require ('conf.php');
00053 require ($BACK_PATH.'init.php');
00054 require ($BACK_PATH.'template.php');
00055 $GLOBALS['LANG']->includeLLFile('EXT:lowlevel/config/locallang.xml');
00056 
00057 $BE_USER->modAccess($MCONF,1);
00058 
00059 
00060 
00061 
00062 
00063 
00064 
00065 /**
00066  * Script class for the Config module
00067  *
00068  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00069  * @package TYPO3
00070  * @subpackage tx_lowlevel
00071  */
00072 class SC_mod_tools_config_index {
00073 
00074     var $MCONF = array();
00075     var $MOD_MENU = array();
00076     var $MOD_SETTINGS = array();
00077 
00078     /**
00079      * document template object
00080      *
00081      * @var noDoc
00082      */
00083     var $doc;
00084 
00085     var $include_once = array();
00086     var $content;
00087 
00088 
00089 
00090     /**
00091      * Initialization
00092      *
00093      * @return  void
00094      */
00095     function init() {
00096         global $BACK_PATH;
00097 
00098         $this->MCONF = $GLOBALS['MCONF'];
00099 
00100         $this->menuConfig();
00101 
00102         $this->doc = t3lib_div::makeInstance('template');
00103         $this->doc->backPath = $BACK_PATH;
00104         $this->doc->setModuleTemplate('templates/config.html');
00105 
00106                 // JavaScript
00107         $this->doc->JScode = '
00108         <script language="javascript" type="text/javascript">
00109             script_ended = 0;
00110             function jumpToUrl(URL) {
00111                 window.location.href = URL;
00112             }
00113         </script>
00114         ';
00115 
00116         $this->doc->form = '<form action="" method="post">';
00117     }
00118 
00119     /**
00120      * Menu Configuration
00121      *
00122      * @return  void
00123      */
00124     function menuConfig()   {
00125         global $TYPO3_CONF_VARS;
00126 
00127             // MENU-ITEMS:
00128             // If array, then it's a selector box menu
00129             // If empty string it's just a variable, that'll be saved.
00130             // Values NOT in this array will not be saved in the settings-array for the module.
00131         $this->MOD_MENU = array(
00132             'function' => array(
00133                 0 => $GLOBALS['LANG']->getLL('typo3ConfVars', true),
00134                 1 => $GLOBALS['LANG']->getLL('tca', true),
00135                 2 => $GLOBALS['LANG']->getLL('tcaDescr', true),
00136                 3 => $GLOBALS['LANG']->getLL('loadedExt', true),
00137                 4 => $GLOBALS['LANG']->getLL('t3services', true),
00138                 5 => $GLOBALS['LANG']->getLL('tbemodules', true),
00139                 6 => $GLOBALS['LANG']->getLL('tbemodulesext', true),
00140                 7 => $GLOBALS['LANG']->getLL('tbeStyles', true),
00141                 8 => $GLOBALS['LANG']->getLL('beUser', true),
00142                 9 => $GLOBALS['LANG']->getLL('usersettings', true),
00143             ),
00144             'regexsearch' => '',
00145             'fixedLgd' => ''
00146         );
00147 
00148             // CLEANSE SETTINGS
00149         $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
00150     }
00151 
00152     /**
00153      * [Describe function...]
00154      *
00155      * @return  [type]      ...
00156      */
00157     function main() {
00158 
00159         $arrayBrowser = t3lib_div::makeInstance('t3lib_arrayBrowser');
00160 
00161         $this->content= $this->doc->header($GLOBALS['LANG']->getLL('configuration', true));
00162         $this->content.= $this->doc->spacer(5);
00163 
00164         $this->content .= '<div id="lowlevel-config">
00165                         <label for="search_field">' . $GLOBALS['LANG']->getLL('enterSearchPhrase', true) . '</label>
00166                         <input type="text" id="search_field" name="search_field" value="' . htmlspecialchars($search_field) . '"' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' />
00167                         <input type="submit" name="search" id="search" value="' . $GLOBALS['LANG']->getLL('search', true) . '" />';
00168         $this->content .= t3lib_BEfunc::getFuncCheck(0,'SET[regexsearch]',$this->MOD_SETTINGS['regexsearch'],'','','id="checkRegexsearch"') .
00169                         '<label for="checkRegexsearch">' . $GLOBALS['LANG']->getLL('useRegExp', true) . '</label>';
00170 
00171         $this->content.= t3lib_BEfunc::getFuncCheck(0, 'SET[fixedLgd]', $this->MOD_SETTINGS['fixedLgd'], '', '', 'id="checkFixedLgd"') .
00172                         '<label for="checkFixedLgd">' . $GLOBALS['LANG']->getLL('cropLines', true) . '</label>
00173                         </div>';
00174 
00175         $this->content.= $this->doc->spacer(5);
00176 
00177         switch($this->MOD_SETTINGS['function']) {
00178             case 0:
00179                 $theVar = $GLOBALS['TYPO3_CONF_VARS'];
00180                 t3lib_div::naturalKeySortRecursive($theVar);
00181                 $arrayBrowser->varName = '$TYPO3_CONF_VARS';
00182             break;
00183             case 1:
00184                 foreach ($GLOBALS['TCA'] as $table => $config) {
00185                     t3lib_div::loadTCA($table);
00186                 }
00187                 $theVar = $GLOBALS['TCA'];
00188                 t3lib_div::naturalKeySortRecursive($theVar);
00189                 $arrayBrowser->varName = '$TCA';
00190             break;
00191             case 2:
00192                 $theVar = $GLOBALS['TCA_DESCR'];
00193                 t3lib_div::naturalKeySortRecursive($theVar);
00194                 $arrayBrowser->varName = '$TCA_DESCR';
00195             break;
00196             case 3:
00197                 $theVar = $GLOBALS['TYPO3_LOADED_EXT'];
00198                 t3lib_div::naturalKeySortRecursive($theVar);
00199                 $arrayBrowser->varName = '$TYPO3_LOADED_EXT';
00200             break;
00201             case 4:
00202                 $theVar = $GLOBALS['T3_SERVICES'];
00203                 t3lib_div::naturalKeySortRecursive($theVar);
00204                 $arrayBrowser->varName = '$T3_SERVICES';
00205             break;
00206             case 5:
00207                 $theVar = $GLOBALS['TBE_MODULES'];
00208                 t3lib_div::naturalKeySortRecursive($theVar);
00209                 $arrayBrowser->varName = '$TBE_MODULES';
00210             break;
00211             case 6:
00212                 $theVar = $GLOBALS['TBE_MODULES_EXT'];
00213                 t3lib_div::naturalKeySortRecursive($theVar);
00214                 $arrayBrowser->varName = '$TBE_MODULES_EXT';
00215             break;
00216             case 7:
00217                 $theVar = $GLOBALS['TBE_STYLES'];
00218                 t3lib_div::naturalKeySortRecursive($theVar);
00219                 $arrayBrowser->varName = '$TBE_STYLES';
00220             break;
00221             case 8:
00222                 $theVar = $GLOBALS['BE_USER']->uc;
00223                 t3lib_div::naturalKeySortRecursive($theVar);
00224                 $arrayBrowser->varName = '$BE_USER->uc';
00225             break;
00226             case 9:
00227                 $theVar = $GLOBALS['TYPO3_USER_SETTINGS'];
00228                 t3lib_div::naturalKeySortRecursive($theVar);
00229                 $arrayBrowser->varName = '$TYPO3_USER_SETTINGS';
00230             break;
00231             default:
00232                 $theVar = array();
00233             break;
00234         }
00235 
00236 
00237             // Update node:
00238         $update = 0;
00239         $node = t3lib_div::_GET('node');
00240         if (is_array($node))    {       // If any plus-signs were clicked, it's registred.
00241             $this->MOD_SETTINGS['node_'.$this->MOD_SETTINGS['function']] = $arrayBrowser->depthKeys($node, $this->MOD_SETTINGS['node_'.$this->MOD_SETTINGS['function']]);
00242             $update = 1;
00243         }
00244         if ($update) {
00245             $GLOBALS['BE_USER']->pushModuleData($this->MCONF['name'],$this->MOD_SETTINGS);
00246         }
00247 
00248         $arrayBrowser->depthKeys = $this->MOD_SETTINGS['node_'.$this->MOD_SETTINGS['function']];
00249         $arrayBrowser->regexMode = $this->MOD_SETTINGS['regexsearch'];
00250         $arrayBrowser->fixedLgd = $this->MOD_SETTINGS['fixedLgd'];
00251         $arrayBrowser->searchKeysToo = TRUE;
00252 
00253 
00254         $search_field = t3lib_div::_GP('search_field');
00255         if (t3lib_div::_POST('search') && trim($search_field))  {       // If any POST-vars are send, update the condition array
00256             $arrayBrowser->depthKeys=$arrayBrowser->getSearchKeys($theVar, '',  $search_field, array());
00257         }
00258 
00259         $tree = $arrayBrowser->tree($theVar, '', '');
00260 
00261         $label = $this->MOD_MENU['function'][$this->MOD_SETTINGS['function']];
00262         $this->content.= $this->doc->sectionEnd();
00263 
00264             // Variable name:
00265         if (t3lib_div::_GP('varname'))  {
00266             $line = t3lib_div::_GP('_') ? t3lib_div::_GP('_') : t3lib_div::_GP('varname');
00267             if (t3lib_div::_GP('writetoexttables')) { // Write the line to extTables.php
00268                     // change value to $GLOBALS
00269                 $length = strpos($line, '[');
00270                 $var = substr($line, 0, $length);
00271                 $changedLine = '$GLOBALS[\'' . substr($line, 1, $length - 1) . '\']' . substr($line, $length);
00272                     // insert line  in extTables.php
00273                 $extTables = t3lib_div::getURL(PATH_typo3conf . TYPO3_extTableDef_script);
00274                 $extTables = '<?php' . preg_replace('/<\?php|\?>/is', '', $extTables) . $changedLine . LF . '?>';
00275                 $success = t3lib_div::writeFile(PATH_typo3conf . TYPO3_extTableDef_script, $extTables);
00276                 if ($success) {
00277                         // show flash message
00278                     $flashMessage = t3lib_div::makeInstance(
00279                         't3lib_FlashMessage',
00280                         '',
00281                         sprintf($GLOBALS['LANG']->getLL('writeMessage', TRUE), TYPO3_extTableDef_script,  '<br />', '<strong>' . $changedLine . '</strong>'),
00282                         t3lib_FlashMessage::OK
00283                     );
00284                 } else {
00285                     // Error: show flash message
00286                     $flashMessage = t3lib_div::makeInstance(
00287                         't3lib_FlashMessage',
00288                         '',
00289                         sprintf($GLOBALS['LANG']->getLL('writeMessageFailed', TRUE), TYPO3_extTableDef_script),
00290                         t3lib_FlashMessage::ERROR
00291                     );
00292                 }
00293                 $this->content .= $flashMessage->render();
00294             }
00295             $this->content .= '<div id="lowlevel-config-var">
00296                 <strong>' . $GLOBALS['LANG']->getLL('variable', TRUE) . '</strong><br />
00297                 <input type="text" name="_" value="'.trim(htmlspecialchars($line)).'" size="120" /><br/>';
00298 
00299             if (TYPO3_extTableDef_script !== '' && ($this->MOD_SETTINGS['function'] === '1' || $this->MOD_SETTINGS['function'] === '4')) {
00300                     // write only for $TCA and TBE_STYLES if  TYPO3_extTableDef_script is defined
00301                 $this->content .= '<br /><input type="submit" name="writetoexttables" value="' .
00302                     $GLOBALS['LANG']->getLL('writeValue', TRUE) . '" /></div>';
00303             } else {
00304                 $this->content .= $GLOBALS['LANG']->getLL('copyPaste', TRUE) . LF . '</div>';
00305             }
00306 
00307         }
00308 
00309         $this->content.= '<br /><table border="0" cellpadding="0" cellspacing="0" class="t3-tree t3-tree-config">';
00310         $this->content.= '<tr>
00311                     <th class="t3-row-header t3-tree-config-header">' . $label . '</th>
00312                 </tr>
00313                 <tr>
00314                     <td>' . $tree . '</td>
00315                 </tr>
00316             </table>
00317         ';
00318 
00319 
00320             // Setting up the buttons and markers for docheader
00321         $docHeaderButtons = $this->getButtons();
00322         $markers = array(
00323             'CSH' => $docHeaderButtons['csh'],
00324             'FUNC_MENU' => $this->getFuncMenu(),
00325             'CONTENT' => $this->content
00326         );
00327 
00328             // Build the <body> for the module
00329         $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
00330             // Renders the module page
00331         $this->content = $this->doc->render(
00332             'Configuration',
00333             $this->content
00334         );
00335     }
00336 
00337     /**
00338      * Print output to browser
00339      *
00340      * @return  void
00341      */
00342     function printContent() {
00343         echo $this->content;
00344     }
00345 
00346     /**
00347      * Create the panel of buttons for submitting the form or otherwise perform operations.
00348      *
00349      * @return  array   all available buttons as an assoc. array
00350      */
00351     protected function getButtons() {
00352 
00353         $buttons = array(
00354             'csh' => '',
00355             'shortcut' => ''
00356         );
00357             // CSH
00358         //$buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']);
00359 
00360             // Shortcut
00361         if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
00362             $buttons['shortcut'] = $this->doc->makeShortcutIcon('','function',$this->MCONF['name']);
00363         }
00364         return $buttons;
00365     }
00366 
00367     /**
00368      * Create the function menu
00369      *
00370      * @return  string  HTML of the function menu
00371      */
00372     protected function getFuncMenu() {
00373         $funcMenu = t3lib_BEfunc::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
00374         return $funcMenu;
00375     }
00376 }
00377 
00378 
00379 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/lowlevel/config/index.php'])) {
00380     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/lowlevel/config/index.php']);
00381 }
00382 
00383 
00384 
00385 
00386 // Make instance:
00387 $SOBE = t3lib_div::makeInstance('SC_mod_tools_config_index');
00388 $SOBE->init();
00389 $SOBE->main();
00390 $SOBE->printContent();
00391 ?>