[TASK] Remove comments for revised in TYPO3 3.6
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / index_ts.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2013 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 * This is the MAIN DOCUMENT of the TypoScript driven standard front-end (from the "cms" extension)
29 * Basically put this is the "index.php" script which all requests for TYPO3 delivered pages goes to in the frontend (the website)
30 * The script configures constants, includes libraries and does a little logic here and there in order to instantiate the right classes to create the webpage.
31 * All the real data processing goes on in the "tslib/" classes which this script will include and use as needed.
32 *
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
34 */
35
36 define('TYPO3_MODE', 'FE');
37
38 \TYPO3\CMS\Core\Core\Bootstrap::getInstance()
39 ->startOutputBuffering()
40 ->loadConfigurationAndInitialize()
41 ->loadTypo3LoadedExtAndExtLocalconf(TRUE)
42 ->applyAdditionalConfigurationSettings();
43
44 // Timetracking started
45 if ($_COOKIE[\TYPO3\CMS\Core\Authentication\BackendUserAuthentication::getCookieName()]) {
46 $TT = new \TYPO3\CMS\Core\TimeTracker\TimeTracker();
47 } else {
48 $TT = new \TYPO3\CMS\Core\TimeTracker\NullTimeTracker();
49 }
50
51 $TT->start();
52
53 \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeTypo3DbGlobal();
54 // Hook to preprocess the current request:
55 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'])) {
56 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'] as $hookFunction) {
57 $hookParameters = array();
58 \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($hookFunction, $hookParameters, $hookParameters);
59 }
60 unset($hookFunction);
61 unset($hookParameters);
62 }
63 // Look for extension ID which will launch alternative output engine
64 if ($temp_extId = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('eID')) {
65 if ($classPath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($TYPO3_CONF_VARS['FE']['eID_include'][$temp_extId])) {
66 // Remove any output produced until now
67 ob_clean();
68 require $classPath;
69 }
70 die;
71 }
72
73 /** @var $TSFE \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController */
74 $TSFE = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
75 'TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController',
76 $TYPO3_CONF_VARS,
77 \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'),
78 \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('type'),
79 \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('no_cache'),
80 \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('cHash'),
81 \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('jumpurl'),
82 \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('MP'),
83 \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('RDCT')
84 );
85
86 if ($TYPO3_CONF_VARS['FE']['pageUnavailable_force']
87 && !\TYPO3\CMS\Core\Utility\GeneralUtility::cmpIP(
88 \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REMOTE_ADDR'),
89 $TYPO3_CONF_VARS['SYS']['devIPmask'])
90 ) {
91 $TSFE->pageUnavailableAndExit('This page is temporarily unavailable.');
92 }
93
94 $TSFE->connectToDB();
95 $TSFE->sendRedirect();
96
97 // Output compression
98 // Remove any output produced until now
99 ob_clean();
100 if ($TYPO3_CONF_VARS['FE']['compressionLevel'] && extension_loaded('zlib')) {
101 if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($TYPO3_CONF_VARS['FE']['compressionLevel'])) {
102 // Prevent errors if ini_set() is unavailable (safe mode)
103 @ini_set('zlib.output_compression_level', $TYPO3_CONF_VARS['FE']['compressionLevel']);
104 }
105 ob_start(array(\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Utility\\CompressionUtility'), 'compressionOutputHandler'));
106 }
107
108 // FE_USER
109 $TT->push('Front End user initialized', '');
110 /** @var $TSFE \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController */
111 $TSFE->initFEuser();
112 $TT->pull();
113
114 // BE_USER
115 /** @var $BE_USER \TYPO3\CMS\Backend\FrontendBackendUserAuthentication */
116 $BE_USER = $TSFE->initializeBackendUser();
117
118 // Process the ID, type and other parameters
119 // After this point we have an array, $page in TSFE, which is the page-record of the current page, $id
120 $TT->push('Process ID', '');
121 // Initialize admin panel since simulation settings are required here:
122 if ($TSFE->isBackendUserLoggedIn()) {
123 $BE_USER->initializeAdminPanel();
124 \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->loadExtensionTables(TRUE);
125 } else {
126 \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->loadCachedTca();
127 }
128 $TSFE->checkAlternativeIdMethods();
129 $TSFE->clear_preview();
130 $TSFE->determineId();
131 // Now, if there is a backend user logged in and he has NO access to this page, then re-evaluate the id shown!
132 if ($TSFE->isBackendUserLoggedIn() && (!$BE_USER->extPageReadAccess($TSFE->page) || \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ADMCMD_noBeUser'))) {
133 // \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('ADMCMD_noBeUser') is placed here because
134 // \TYPO3\CMS\Version\Hook\PreviewHook might need to know if a backend user is logged in!
135 // Remove user
136 unset($BE_USER);
137 $TSFE->beUserLogin = 0;
138 // Re-evaluate the page-id.
139 $TSFE->checkAlternativeIdMethods();
140 $TSFE->clear_preview();
141 $TSFE->determineId();
142 }
143 $TSFE->makeCacheHash();
144 $TT->pull();
145
146 // Admin Panel & Frontend editing
147 if ($TSFE->isBackendUserLoggedIn()) {
148 $BE_USER->initializeFrontendEdit();
149 if ($BE_USER->adminPanel instanceof \TYPO3\CMS\Frontend\View\AdminPanelView) {
150 \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeLanguageObject();
151 }
152 if ($BE_USER->frontendEdit instanceof \TYPO3\CMS\Core\FrontendEditing\FrontendEditingController) {
153 $BE_USER->frontendEdit->initConfigOptions();
154 }
155 }
156
157 // Starts the template
158 $TT->push('Start Template', '');
159 $TSFE->initTemplate();
160 $TT->pull();
161 // Get from cache
162 $TT->push('Get Page from cache', '');
163 $TSFE->getFromCache();
164 $TT->pull();
165 // Get config if not already gotten
166 // After this, we should have a valid config-array ready
167 $TSFE->getConfigArray();
168 // Convert POST data to internal "renderCharset" if different from the metaCharset
169 $TSFE->convPOSTCharset();
170 // Setting language and locale
171 $TT->push('Setting language and locale', '');
172 $TSFE->settingLanguage();
173 $TSFE->settingLocale();
174 $TT->pull();
175 // Check JumpUrl
176 $TSFE->setExternalJumpUrl();
177 $TSFE->checkJumpUrlReferer();
178
179 $TSFE->handleDataSubmission();
180
181 // Check for shortcut page and redirect
182 $TSFE->checkPageForShortcutRedirect();
183 // Generate page
184 $TSFE->setUrlIdToken();
185 $TT->push('Page generation', '');
186 if ($TSFE->isGeneratePage()) {
187 $TSFE->generatePage_preProcessing();
188 $temp_theScript = $TSFE->generatePage_whichScript();
189 if ($temp_theScript) {
190 include $temp_theScript;
191 } else {
192 include PATH_tslib . 'pagegen.php';
193 }
194 $TSFE->generatePage_postProcessing();
195 } elseif ($TSFE->isINTincScript()) {
196 include PATH_tslib . 'pagegen.php';
197 }
198 $TT->pull();
199 // $TSFE->config['INTincScript']
200 if ($TSFE->isINTincScript()) {
201 $TT->push('Non-cached objects', '');
202 $TSFE->INTincScript();
203 $TT->pull();
204 }
205 // Output content
206 $sendTSFEContent = FALSE;
207 if ($TSFE->isOutputting()) {
208 $TT->push('Print Content', '');
209 $TSFE->processOutput();
210 $sendTSFEContent = TRUE;
211 $TT->pull();
212 }
213 // Store session data for fe_users
214 $TSFE->storeSessionData();
215 // Statistics
216 $TYPO3_MISC['microtime_end'] = microtime(TRUE);
217 $TSFE->setParseTime();
218 if ($TSFE->isOutputting() && (!empty($TSFE->TYPO3_CONF_VARS['FE']['debug']) || !empty($TSFE->config['config']['debug']))) {
219 $TSFE->content .= LF . '<!-- Parsetime: ' . $TSFE->scriptParseTime . 'ms -->';
220 }
221 // Check JumpUrl
222 $TSFE->jumpurl();
223 // Preview info
224 $TSFE->previewInfo();
225 // Hook for end-of-frontend
226 $TSFE->hook_eofe();
227 // Finish timetracking
228 $TT->pull();
229 // Check memory usage
230 \TYPO3\CMS\Core\Utility\MonitorUtility::peakMemoryUsage();
231 // beLoginLinkIPList
232 echo $TSFE->beLoginLinkIPList();
233 // Admin panel
234 if (is_object($BE_USER) && $BE_USER->isAdminPanelVisible() && $TSFE->isBackendUserLoggedIn()) {
235 $TSFE->content = str_ireplace('</head>', $BE_USER->adminPanel->getAdminPanelHeaderData() . '</head>', $TSFE->content);
236 $TSFE->content = str_ireplace('</body>', $BE_USER->displayAdminPanel() . '</body>', $TSFE->content);
237 }
238 if ($sendTSFEContent) {
239 echo $TSFE->content;
240 }
241 // Debugging Output
242 if (isset($error) && is_object($error) && @is_callable(array($error, 'debugOutput'))) {
243 $error->debugOutput();
244 }
245 if (TYPO3_DLOG) {
246 \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('END of FRONTEND session', 'cms', 0, array('_FLUSH' => TRUE));
247 }
248 \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->shutdown();
249 ?>