Fixed bug #10597: Admin panel is not available anymore when extension fe_edit is...
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / index_ts.php
old mode 100755 (executable)
new mode 100644 (file)
index a75e221..11a5c32
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -41,7 +41,7 @@
 // *******************************
 // Checking PHP version
 // *******************************
-if (version_compare(phpversion(), '5.1', '<')) die ('TYPO3 requires PHP 5.1.0 or higher.');
+if (version_compare(phpversion(), '5.2', '<')) die ('TYPO3 requires PHP 5.2.0 or higher.');
 
 // *******************************
 // Set error reporting
@@ -75,6 +75,12 @@ if (!defined('PATH_tslib')) {
 if (!@is_dir(PATH_typo3conf))  die('Cannot find configuration. This file is probably executed from the wrong location.');
 
 // *********************
+// Prevent any output until AJAX/compression is initialized to stop
+// AJAX/compression data corruption
+// *********************
+ob_start();
+
+// *********************
 // Timetracking started
 // *********************
 require_once(PATH_t3lib.'class.t3lib_timetrack.php');
@@ -105,7 +111,16 @@ if (!defined('PATH_tslib')) {
        define('PATH_tslib', t3lib_extMgm::extPath('cms').'tslib/');
 }
 
-require_once(PATH_t3lib.'class.t3lib_db.php');
+
+// *********************
+// Autoloader
+// *********************
+$TT->push('Register Autoloader', '');
+       require_once(PATH_t3lib . 'class.t3lib_autoloader.php');
+       t3lib_autoloader::registerAutoloader();
+$TT->pull();
+
+
 $TYPO3_DB = t3lib_div::makeInstance('t3lib_DB');
 $TYPO3_DB->debugOutput = $TYPO3_CONF_VARS['SYS']['sqlDebug'];
 
@@ -127,11 +142,25 @@ if (!get_magic_quotes_gpc())      {
 }
 
 
+// Hook to preprocess the current request:
+if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'])) {
+       foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'] as $hookFunction) {
+               $hookParameters = array();
+               t3lib_div::callUserFunction($hookFunction, $hookParameters, $hookParameters);
+       }
+       unset($hookFunction);
+       unset($hookParameters);
+}
+
+
 // *********************
 // Look for extension ID which will launch alternative output engine
 // *********************
 if ($temp_extId = t3lib_div::_GP('eID'))       {
        if ($classPath = t3lib_div::getFileAbsFileName($TYPO3_CONF_VARS['FE']['eID_include'][$temp_extId]))     {
+               // Remove any output produced until now
+               ob_clean();
+
                require_once(PATH_tslib.'class.tslib_eidtools.php');
                require($classPath);
        }
@@ -151,49 +180,23 @@ $TT->push('Include Frontend libraries','');
 $TT->pull();
 
 // ***********************************
-// Initializing the Caching System
-// ***********************************
-
-$TT->push('Initializing the Caching System','');
-               // TODO implement autoloading so that we only require stuff we really need
-       require_once(PATH_t3lib.'cache/class.t3lib_cache_abstractbackend.php');
-       require_once(PATH_t3lib.'cache/class.t3lib_cache_abstractcache.php');
-       require_once(PATH_t3lib.'cache/class.t3lib_cache_exception.php');
-       require_once(PATH_t3lib.'cache/class.t3lib_cache_factory.php');
-       require_once(PATH_t3lib.'cache/class.t3lib_cache_manager.php');
-       require_once(PATH_t3lib.'cache/class.t3lib_cache_variablecache.php');
-
-       require_once(PATH_t3lib.'cache/exception/class.t3lib_cache_exception_classalreadyloaded.php');
-       require_once(PATH_t3lib.'cache/exception/class.t3lib_cache_exception_duplicateidentifier.php');
-       require_once(PATH_t3lib.'cache/exception/class.t3lib_cache_exception_invalidbackend.php');
-       require_once(PATH_t3lib.'cache/exception/class.t3lib_cache_exception_invalidcache.php');
-       require_once(PATH_t3lib.'cache/exception/class.t3lib_cache_exception_invaliddata.php');
-       require_once(PATH_t3lib.'cache/exception/class.t3lib_cache_exception_nosuchcache.php');
-
-       $cacheManager      = t3lib_div::makeInstance('t3lib_cache_Manager');
-       $cacheFactoryClass = t3lib_div::makeInstanceClassName('t3lib_cache_Factory');
-       $TYPO3_CACHE       = new $cacheFactoryClass($cacheManager);
-       unset($cacheFactoryClass);
-$TT->pull();
-
-// ***********************************
 // Create $TSFE object (TSFE = TypoScript Front End)
 // Connecting to database
 // ***********************************
-$temp_TSFEclassName = t3lib_div::makeInstanceClassName('tslib_fe');
-$TSFE = new $temp_TSFEclassName(
-               $TYPO3_CONF_VARS,
-               t3lib_div::_GP('id'),
-               t3lib_div::_GP('type'),
-               t3lib_div::_GP('no_cache'),
-               t3lib_div::_GP('cHash'),
-               t3lib_div::_GP('jumpurl'),
-               t3lib_div::_GP('MP'),
-               t3lib_div::_GP('RDCT')
-       );
+$TSFE = t3lib_div::makeInstance('tslib_fe',
+       $TYPO3_CONF_VARS,
+       t3lib_div::_GP('id'),
+       t3lib_div::_GP('type'),
+       t3lib_div::_GP('no_cache'),
+       t3lib_div::_GP('cHash'),
+       t3lib_div::_GP('jumpurl'),
+       t3lib_div::_GP('MP'),
+       t3lib_div::_GP('RDCT')
+);
+/* @var $TSFE tslib_fe */
 
 if($TYPO3_CONF_VARS['FE']['pageUnavailable_force'] &&
-   !t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $TYPO3_CONF_VARS['SYS']['devIPmask'])) {
+       !t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $TYPO3_CONF_VARS['SYS']['devIPmask'])) {
        $TSFE->pageUnavailableAndExit('This page is temporarily unavailable.');
 }
 
@@ -202,7 +205,7 @@ $TSFE->connectToDB();
 
        // In case of a keyword-authenticated preview, re-initialize the TSFE object:
 if ($temp_previewConfig = $TSFE->ADMCMD_preview())     {
-       $TSFE = new $temp_TSFEclassName(
+       $TSFE = t3lib_div::makeInstance('tslib_fe',
                $TYPO3_CONF_VARS,
                t3lib_div::_GP('id'),
                t3lib_div::_GP('type'),
@@ -219,11 +222,17 @@ if ($TSFE->RDCT)  {$TSFE->sendRedirect();}
 
 
 // *******************
-// output compression
+// Output compression
 // *******************
-if ($TYPO3_CONF_VARS['FE']['compressionLevel'])        {
-       ob_start();
-       require_once(PATH_t3lib.'class.gzip_encode.php');
+// Remove any output produced until now
+ob_clean();
+if ($TYPO3_CONF_VARS['FE']['compressionLevel'] && extension_loaded('zlib'))    {
+       if (t3lib_div::testInt($TYPO3_CONF_VARS['FE']['compressionLevel'])) {
+               // Prevent errors if ini_set() is unavailable (safe mode)
+               @ini_set('zlib.output_compression_level', $TYPO3_CONF_VARS['FE']['compressionLevel']);
+       }
+       require_once(PATH_tslib . 'class.tslib_fecompression.php');
+       ob_start(array(t3lib_div::makeInstance('tslib_fecompression'), 'compressionOutputHandler'));
 }
 
 // *********
@@ -267,9 +276,8 @@ if ($_COOKIE['be_typo_user']) {             // If the backend cookie is set, we proceed and
                        $BE_USER->fetchGroupData();
                        $TSFE->beUserLogin = 1;
                }
-               if ($BE_USER->checkLockToIP() && $BE_USER->checkBackendAccessSettingsFromInitPhp())     {
-                       $BE_USER->extInitFeAdmin();
-               } else {        // Unset the user initialization.
+                       // Unset the user initialization.
+               if (!$BE_USER->checkLockToIP() || !$BE_USER->checkBackendAccessSettingsFromInitPhp() || !$BE_USER->user['uid']) {
                        $BE_USER='';
                        $TSFE->beUserLogin=0;
                }
@@ -326,61 +334,21 @@ $TT->push('Process ID','');
        $TSFE->makeCacheHash();
 $TT->pull();
 
-
 // *****************************************
-// Frontend editing
+// Admin Panel & Frontend editing
 // *****************************************
-if ($TSFE->beUserLogin && $BE_USER->extAdmEnabled)     {
-       require_once(t3lib_extMgm::extPath('lang').'lang.php');
-       $LANG = t3lib_div::makeInstance('language');
-       $LANG->init($BE_USER->uc['lang']);
-
-       $BE_USER->extSaveFeAdminConfig();
-
-               // Setting some values based on the admin panel
-       $TSFE->forceTemplateParsing = $BE_USER->extGetFeAdminValue('tsdebug', 'forceTemplateParsing');
-       $TSFE->displayEditIcons = $BE_USER->extGetFeAdminValue('edit', 'displayIcons');
-       $TSFE->displayFieldEditIcons = $BE_USER->extGetFeAdminValue('edit', 'displayFieldIcons');
-
-       if ($BE_USER->extGetFeAdminValue('tsdebug','displayQueries')) {
-               if ($GLOBALS['TYPO3_DB']->explainOutput == 0) {         // do not override if the value is already set in t3lib_db
-                               // Enable execution of EXPLAIN SELECT queries
-                       $GLOBALS['TYPO3_DB']->explainOutput = 3;
-               }
-       }
-
-       if (t3lib_div::_GP('ADMCMD_editIcons')) {
-               $TSFE->displayFieldEditIcons=1;
-               $BE_USER->uc['TSFE_adminConfig']['edit_editNoPopup']=1;
-       }
-       if (t3lib_div::_GP('ADMCMD_simUser'))   {
-               $BE_USER->uc['TSFE_adminConfig']['preview_simulateUserGroup']=intval(t3lib_div::_GP('ADMCMD_simUser'));
-               $BE_USER->ext_forcePreview=1;
-       }
-       if (t3lib_div::_GP('ADMCMD_simTime'))   {
-               $BE_USER->uc['TSFE_adminConfig']['preview_simulateDate']=intval(t3lib_div::_GP('ADMCMD_simTime'));
-               $BE_USER->ext_forcePreview=1;
-       }
-
-       // Include classes for editing IF editing module in Admin Panel is open
-       if (($BE_USER->extAdmModuleEnabled('edit') && $BE_USER->extIsAdmMenuOpen('edit')) || $TSFE->displayEditIcons == 1)      {
-               $TSFE->includeTCA();
-               if ($BE_USER->extIsEditAction())        {
-                       require_once (PATH_t3lib.'class.t3lib_tcemain.php');
-                       $BE_USER->extEditAction();
-               }
-               if ($BE_USER->extIsFormShown()) {
-                       require_once(PATH_t3lib.'class.t3lib_tceforms.php');
-                       require_once(PATH_t3lib.'class.t3lib_iconworks.php');
-                       require_once(PATH_t3lib.'class.t3lib_loaddbgroup.php');
-                       require_once(PATH_t3lib.'class.t3lib_transferdata.php');
-               }
+if ($TSFE->beUserLogin) {
+       $BE_USER->initializeAdminPanel();
+       $BE_USER->initializeFrontendEdit();
+       if ($BE_USER->adminPanel instanceof tslib_AdminPanel) {
+               $LANG = t3lib_div::makeInstance('language');
+               $LANG->init($BE_USER->uc['lang']);
+       }
+       if ($BE_USER->frontendEdit instanceof t3lib_frontendedit) {
+               $BE_USER->frontendEdit->initConfigOptions();
        }
-
-       if ($TSFE->forceTemplateParsing || $TSFE->displayEditIcons || $TSFE->displayFieldEditIcons)     { $TSFE->set_no_cache(); }
 }
 
-
 // *******************************************
 // Get compressed $TCA-Array();
 // After this, we should now have a valid $TCA, though minimized
@@ -410,7 +378,6 @@ $TT->pull();
 // ******************************************************
 $TSFE->getConfigArray();
 
-
 // ********************************
 // Convert POST data to internal "renderCharset" if different from the metaCharset
 // *******************************
@@ -508,18 +475,9 @@ if ($TSFE->isOutputting()) {
                                // Special feature: Include libraries
                        reset($EXTiS_config);
                        while(list(,$EXTiS_cPart)=each($EXTiS_config))  {
-                               if ($EXTiS_cPart['conf']['includeLibs'])        {
-                                       $EXTiS_resourceList = t3lib_div::trimExplode(',',$EXTiS_cPart['conf']['includeLibs'],1);
-                                       $TT->setTSlogMessage('Files for inclusion: "'.implode(', ',$EXTiS_resourceList).'"');
-                                       reset($EXTiS_resourceList);
-                                       while(list(,$EXTiS_theLib) = each($EXTiS_resourceList)) {
-                                               $EXTiS_incFile = $TSFE->tmpl->getFileName($EXTiS_theLib);
-                                               if ($EXTiS_incFile)     {
-                                                       require_once($EXTiS_incFile);
-                                               } else {
-                                                       $TT->setTSlogMessage('Include file "'.$EXTiS_theLib.'" did not exist!',2);
-                                               }
-                                       }
+                               if (isset($EXTiS_cPart['conf']['includeLibs']) && $EXTiS_cPart['conf']['includeLibs']) {
+                                       $EXTiS_resourceList = t3lib_div::trimExplode(',',$EXTiS_cPart['conf']['includeLibs'], true);
+                                       $TSFE->includeLibraries($EXTiS_resourceList);
                                }
                        }
 
@@ -581,8 +539,8 @@ $TSFE->previewInfo();
 // ******************
 // Publishing static
 // ******************
-if (is_object($BE_USER))       {
-       if ($BE_USER->extAdmModuleEnabled('publish') && $BE_USER->extPublishList)       {
+if (is_object($BE_USER) && ($BE_USER->adminPabel instanceof tslib_AdminPanel)) {
+       if ($BE_USER->adminPanel->isAdminModuleEnabled('publish') && $BE_USER->adminPanel->getExtPublishList()) {
                include_once(PATH_tslib.'publish.php');
        }
 }
@@ -609,30 +567,18 @@ echo $TSFE->beLoginLinkIPList();
 // *************
 // Admin panel
 // *************
-if (is_object($BE_USER)
-       && $TSFE->beUserLogin
-       && $TSFE->config['config']['admPanel']
-       && $BE_USER->extAdmEnabled
-//     && $BE_USER->extPageReadAccess($TSFE->page)     // This is already done, if there is a BE_USER object at this point!
-       && !$BE_USER->extAdminConfig['hide'])   {
-               echo $BE_USER->extPrintFeAdminDialog();
+if (is_object($BE_USER) && $TSFE->beUserLogin) {
+       echo $BE_USER->displayAdminPanel();
 }
 
-
 // *************
 // Debugging Output
 // *************
 if(@is_callable(array($error,'debugOutput'))) {
        $error->debugOutput();
 }
-if (TYPO3_DLOG)        t3lib_div::devLog('END of FRONTEND session','',0,array('_FLUSH'=>TRUE));
-
-
-// *************
-// Compressions
-// *************
-if ($TYPO3_CONF_VARS['FE']['compressionLevel'])        {
-       new gzip_encode($TYPO3_CONF_VARS['FE']['compressionLevel'], false, $TYPO3_CONF_VARS['FE']['compressionDebugInfo']);
+if (TYPO3_DLOG) {
+       t3lib_div::devLog('END of FRONTEND session', 'cms', 0, array('_FLUSH' => TRUE));
 }
 
-?>
+?>
\ No newline at end of file