Fixed bug #13294: IRRE deleted combo records are still validated by TBE_EDITOR (Thank...
[Packages/TYPO3.CMS.git] / typo3 / backend.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2007-2010 Ingo Renner <ingo@typo3.org>
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 require_once('init.php');
29 require_once('template.php');
30 require_once('interfaces/interface.backend_toolbaritem.php');
31
32 require('classes/class.typo3logo.php');
33 require('classes/class.modulemenu.php');
34 require_once('classes/class.donatewindow.php');
35
36 // core toolbar items
37 require('classes/class.workspaceselector.php');
38 require('classes/class.clearcachemenu.php');
39 require('classes/class.shortcutmenu.php');
40 require('classes/class.backendsearchmenu.php');
41
42 require_once('class.alt_menu_functions.inc');
43 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_misc.xml');
44
45
46 /**
47 * Class for rendering the TYPO3 backend version 4.2+
48 *
49 * @author Ingo Renner <ingo@typo3.org>
50 * @package TYPO3
51 * @subpackage core
52 */
53 class TYPO3backend {
54
55 protected $content;
56 protected $css;
57 protected $cssFiles;
58 protected $js;
59 protected $jsFiles;
60 protected $jsFilesAfterInline;
61 protected $toolbarItems;
62 private $menuWidthDefault = 190; // intentionally private as nobody should modify defaults
63 protected $menuWidth;
64 protected $debug;
65
66 /**
67 * Object for loading backend modules
68 *
69 * @var t3lib_loadModules
70 */
71 protected $moduleLoader;
72
73 /**
74 * module menu generating object
75 *
76 * @var ModuleMenu
77 */
78 protected $moduleMenu;
79
80 /**
81 * Pagerenderer
82 *
83 * @var t3lib_PageRenderer
84 */
85 protected $pageRenderer;
86
87 /**
88 * constructor
89 *
90 * @return void
91 */
92 public function __construct() {
93 // set debug flag for BE development only
94 $this->debug = intval($GLOBALS['TYPO3_CONF_VARS']['BE']['debug']) === 1;
95
96 // Initializes the backend modules structure for use later.
97 $this->moduleLoader = t3lib_div::makeInstance('t3lib_loadModules');
98 $this->moduleLoader->load($GLOBALS['TBE_MODULES']);
99
100 $this->moduleMenu = t3lib_div::makeInstance('ModuleMenu');
101
102 $this->pageRenderer = $GLOBALS['TBE_TEMPLATE']->getPageRenderer();
103 $this->pageRenderer->loadScriptaculous('builder,effects,controls,dragdrop');
104 $this->pageRenderer->loadExtJS();
105
106 $this->pageRenderer->addExtOnReadyCode(
107 'TYPO3.Backend = new TYPO3.Viewport(TYPO3.Viewport.configuration);
108 if (typeof console === "undefined") {
109 console = TYPO3.Backend.DebugConsole;
110 }
111 TYPO3.ContextHelpWindow.init();',
112 TRUE
113 );
114 $this->pageRenderer->addJsInlineCode(
115 'consoleOverrideWithDebugPanel',
116 '//already done'
117 );
118 $this->pageRenderer->addExtDirectCode();
119
120 // add default BE javascript
121 $this->js = '';
122 $this->jsFiles = array(
123 'contrib/swfupload/swfupload.js',
124 'contrib/swfupload/plugins/swfupload.swfobject.js',
125 'contrib/swfupload/plugins/swfupload.cookies.js',
126 'contrib/swfupload/plugins/swfupload.queue.js',
127 'md5.js',
128 'js/common.js',
129 'js/toolbarmanager.js',
130 'js/modulemenu.js',
131 'js/iecompatibility.js',
132 'js/flashupload.js',
133 '../t3lib/jsfunc.evalfield.js',
134 '../t3lib/js/extjs/ux/flashmessages.js',
135 '../t3lib/js/extjs/ux/ext.ux.tabclosemenu.js',
136 '../t3lib/js/extjs/notifications.js',
137 'js/backend.js',
138 'js/loginrefresh.js',
139 'js/extjs/debugPanel.js',
140 'js/extjs/viewport.js',
141 'js/extjs/iframepanel.js',
142 'js/extjs/viewportConfiguration.js',
143 );
144
145 if ($this->debug) {
146 unset($this->jsFiles['js/loginrefresh.js']);
147 }
148
149 // add default BE css
150 $this->css = '';
151 $this->cssFiles = array();
152
153 $this->toolbarItems = array();
154 $this->initializeCoreToolbarItems();
155
156 $this->menuWidth = $this->menuWidthDefault;
157 if (isset($GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW']) && (int) $GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW'] != (int) $this->menuWidth) {
158 $this->menuWidth = (int) $GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW'];
159 }
160
161 $this->executeHook('constructPostProcess');
162 }
163
164 /**
165 * initializes the core toolbar items
166 *
167 * @return void
168 */
169 protected function initializeCoreToolbarItems() {
170
171 $coreToolbarItems = array(
172 'workspaceSelector' => 'WorkspaceSelector',
173 'shortcuts' => 'ShortcutMenu',
174 'clearCacheActions' => 'ClearCacheMenu',
175 'backendSearch' => 'BackendSearchMenu'
176 );
177
178 foreach($coreToolbarItems as $toolbarItemName => $toolbarItemClassName) {
179 $toolbarItem = t3lib_div::makeInstance($toolbarItemClassName, $this);
180
181 if(!($toolbarItem instanceof backend_toolbarItem)) {
182 throw new UnexpectedValueException('$toolbarItem "'.$toolbarItemName.'" must implement interface backend_toolbarItem', 1195126772);
183 }
184
185 if($toolbarItem->checkAccess()) {
186 $this->toolbarItems[$toolbarItemName] = $toolbarItem;
187 } else {
188 unset($toolbarItem);
189 }
190 }
191 }
192
193 /**
194 * main function generating the BE scaffolding
195 *
196 * @return void
197 */
198 public function render() {
199 $this->executeHook('renderPreProcess');
200
201 if (t3lib_div::makeInstance('DonateWindow')->isDonateWindowAllowed()) {
202 $this->pageRenderer->addJsFile('js/donate.js');
203 }
204
205 // prepare the scaffolding, at this point extension may still add javascript and css
206 $logo = t3lib_div::makeInstance('TYPO3Logo');
207 $logo->setLogo('gfx/typo3logo_mini.png');
208
209
210
211 // create backend scaffolding
212 $backendScaffolding = '
213 <div id="typo3-top-container" class="x-hide-display">
214 <div id="typo3-logo">'.$logo->render().'</div>
215 <div id="typo3-top" class="typo3-top-toolbar">' .
216 $this->renderToolbar() .
217 '</div>
218 </div>
219
220 ';
221
222 /******************************************************
223 * now put the complete backend document together
224 ******************************************************/
225
226 foreach($this->cssFiles as $cssFileName => $cssFile) {
227 $this->pageRenderer->addCssFile($cssFile);
228
229 // load addditional css files to overwrite existing core styles
230 if(!empty($GLOBALS['TBE_STYLES']['stylesheets'][$cssFileName])) {
231 $this->pageRenderer->addCssFile($GLOBALS['TBE_STYLES']['stylesheets'][$cssFileName]);
232 }
233 }
234
235 if(!empty($this->css)) {
236 $this->pageRenderer->addCssInlineBlock('BackendInlineCSS', $this->css);
237 }
238
239 foreach ($this->jsFiles as $jsFile) {
240 $this->pageRenderer->addJsFile($jsFile);
241 }
242
243 // Those lines can be removed once we have at least one official ExtDirect router within the backend.
244 $hasExtDirectRouter = FALSE;
245 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ExtDirect']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ExtDirect'])) {
246 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ExtDirect'] as $key => $value) {
247 if (strpos($key, 'TYPO3.Ajax.ExtDirect') !== FALSE) {
248 $hasExtDirectRouter = TRUE;
249 break;
250 }
251 }
252 }
253 if ($hasExtDirectRouter) {
254 $this->pageRenderer->addJsFile('ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.Ajax.ExtDirect', NULL, FALSE);
255 }
256
257 $this->generateJavascript();
258 $this->pageRenderer->addJsInlineCode('BackendInlineJavascript', $this->js);
259
260
261 // set document title:
262 $title = ($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']
263 ? $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'].' [TYPO3 '.TYPO3_version.']'
264 : 'TYPO3 '.TYPO3_version
265 );
266
267 // start page header:
268 $this->content .= $GLOBALS['TBE_TEMPLATE']->startPage($title);
269 $this->content .= $backendScaffolding;
270 $this->content .= $GLOBALS['TBE_TEMPLATE']->endPage();
271
272 $hookConfiguration = array('content' => &$this->content);
273 $this->executeHook('renderPostProcess', $hookConfiguration);
274
275 echo $this->content;
276 }
277
278 /**
279 * renders the items in the top toolbar
280 *
281 * @return string top toolbar elements as HTML
282 */
283 protected function renderToolbar() {
284
285 // move search to last position
286 $search = $this->toolbarItems['backendSearch'];
287 unset($this->toolbarItems['backendSearch']);
288 $this->toolbarItems['backendSearch'] = $search;
289
290 $toolbar = '<ul id="typo3-toolbar">';
291 $toolbar.= '<li>'.$this->getLoggedInUserLabel().'</li>
292 <li><div id="logout-button" class="toolbar-item no-separator">'.$this->moduleMenu->renderLogoutButton().'</div></li>';
293
294 foreach($this->toolbarItems as $toolbarItem) {
295 $menu = $toolbarItem->render();
296 if ($menu) {
297 $additionalAttributes = $toolbarItem->getAdditionalAttributes();
298 $toolbar .= '<li' . $additionalAttributes . '>' .$menu. '</li>';
299 }
300 }
301
302 return $toolbar.'</ul>';
303 }
304
305 /**
306 * Gets the label of the BE user currently logged in
307 *
308 * @return string html code snippet displaying the currently logged in user
309 */
310 protected function getLoggedInUserLabel() {
311 global $BE_USER, $BACK_PATH;
312
313 $icon = t3lib_iconWorks::getSpriteIcon('status-user-'. ($BE_USER->isAdmin() ? 'admin' : 'backend'));
314
315 $label = $GLOBALS['BE_USER']->user['realName'] ?
316 $BE_USER->user['realName'] . ' (' . $BE_USER->user['username'] . ')' :
317 $BE_USER->user['username'];
318
319 // Link to user setup if it's loaded and user has access
320 $link = '';
321 if (t3lib_extMgm::isLoaded('setup') && $BE_USER->check('modules','user_setup')) {
322 $link = '<a href="#" onclick="top.goToModule(\'user_setup\');this.blur();return false;">';
323 }
324
325 $username = '">'.$link.$icon.'<span>'.htmlspecialchars($label).'</span>'.($link?'</a>':'');
326
327 // superuser mode
328 if($BE_USER->user['ses_backuserid']) {
329 $username = ' su-user">'.$icon.
330 '<span title="' . $GLOBALS['LANG']->getLL('switchtouser') . '">' .
331 $GLOBALS['LANG']->getLL('switchtousershort') . ' </span>' .
332 '<span>' . htmlspecialchars($label) . '</span>';
333 }
334
335 return '<div id="username" class="toolbar-item no-separator'.$username.'</div>';
336 }
337
338 /**
339 * Generates the JavaScript code for the backend.
340 *
341 * @return void
342 */
343 protected function generateJavascript() {
344
345 $pathTYPO3 = t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')).'/';
346
347 // If another page module was specified, replace the default Page module with the new one
348 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
349 $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
350 if (!$GLOBALS['BE_USER']->check('modules', $pageModule)) {
351 $pageModule = '';
352 }
353
354 $menuFrameName = 'menu';
355 if($GLOBALS['BE_USER']->uc['noMenuMode'] === 'icons') {
356 $menuFrameName = 'topmenuFrame';
357 }
358
359 // determine security level from conf vars and default to super challenged
360 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel']) {
361 $this->loginSecurityLevel = $GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel'];
362 } else {
363 $this->loginSecurityLevel = 'superchallenged';
364 }
365
366 $t3Configuration = array(
367 'siteUrl' => t3lib_div::getIndpEnv('TYPO3_SITE_URL'),
368 'PATH_typo3' => $pathTYPO3,
369 'PATH_typo3_enc' => rawurlencode($pathTYPO3),
370 'username' => htmlspecialchars($GLOBALS['BE_USER']->user['username']),
371 'uniqueID' => t3lib_div::shortMD5(uniqid('')),
372 'securityLevel' => $this->loginSecurityLevel,
373 'TYPO3_mainDir' => TYPO3_mainDir,
374 'pageModule' => $pageModule,
375 'condensedMode' => $GLOBALS['BE_USER']->uc['condensedMode'] ? 1 : 0 ,
376 'inWorkspace' => $GLOBALS['BE_USER']->workspace !== 0 ? 1 : 0,
377 'workspaceFrontendPreviewEnabled' => $GLOBALS['BE_USER']->user['workspace_preview'] ? 1 : 0,
378 'veriCode' => $GLOBALS['BE_USER']->veriCode(),
379 'denyFileTypes' => PHP_EXTENSIONS_DEFAULT,
380 'moduleMenuWidth' => $this->menuWidth - 1,
381 'topBarHeight' => (isset($GLOBALS['TBE_STYLES']['dims']['topFrameH']) ? intval($GLOBALS['TBE_STYLES']['dims']['topFrameH']) : 30),
382 'showRefreshLoginPopup' => isset($GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup']) ? intval($GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup']) : FALSE,
383 'listModulePath' => t3lib_extMgm::isLoaded('list') ? t3lib_extMgm::extRelPath('list') . 'mod1/' : '',
384 'debugInWindow' => $GLOBALS['BE_USER']->uc['debugInWindow'] ? 1 : 0,
385 'ContextHelpWindows' => array(
386 'width' => 600,
387 'height' => 400
388 )
389 );
390 $t3LLLcore = array(
391 'waitTitle' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_logging_in') ,
392 'refresh_login_failed' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_failed'),
393 'refresh_login_failed_message' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_failed_message'),
394 'refresh_login_title' => sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_title'), htmlspecialchars($GLOBALS['BE_USER']->user['username'])),
395 'login_expired' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.login_expired'),
396 'refresh_login_username' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_username'),
397 'refresh_login_password' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_password'),
398 'refresh_login_emptyPassword' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_emptyPassword'),
399 'refresh_login_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_button'),
400 'refresh_logout_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_logout_button'),
401 'please_wait' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.please_wait'),
402 'loadingIndicator' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:loadingIndicator'),
403 'be_locked' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.be_locked'),
404 'refresh_login_countdown_singular' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_countdown_singular'),
405 'refresh_login_countdown' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_countdown'),
406 'login_about_to_expire' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.login_about_to_expire'),
407 'login_about_to_expire_title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.login_about_to_expire_title'),
408 'refresh_login_refresh_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_refresh_button'),
409 'refresh_direct_logout_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_direct_logout_button'),
410 'tabs_closeAll' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:tabs.closeAll'),
411 'tabs_closeOther' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:tabs.closeOther'),
412 'tabs_close' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:tabs.close'),
413 'tabs_openInBrowserWindow' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:tabs.openInBrowserWindow'),
414 'donateWindow_title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.title'),
415 'donateWindow_message' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.message'),
416 'donateWindow_button_donate' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.button_donate'),
417 'donateWindow_button_disable' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.button_disable'),
418 'donateWindow_button_postpone' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.button_postpone'),
419 );
420 $t3LLLfileUpload = array(
421 'windowTitle' => $GLOBALS['LANG']->getLL('fileUpload_windowTitle'),
422 'buttonSelectFiles' => $GLOBALS['LANG']->getLL('fileUpload_buttonSelectFiles'),
423 'buttonCancelAll' => $GLOBALS['LANG']->getLL('fileUpload_buttonCancelAll'),
424 'infoComponentMaxFileSize' => $GLOBALS['LANG']->getLL('fileUpload_infoComponentMaxFileSize'),
425 'infoComponentFileUploadLimit' => $GLOBALS['LANG']->getLL('fileUpload_infoComponentFileUploadLimit'),
426 'infoComponentFileTypeLimit' => $GLOBALS['LANG']->getLL('fileUpload_infoComponentFileTypeLimit'),
427 'infoComponentOverrideFiles' => $GLOBALS['LANG']->getLL('fileUpload_infoComponentOverrideFiles'),
428 'processRunning' => $GLOBALS['LANG']->getLL('fileUpload_processRunning'),
429 'uploadWait' => $GLOBALS['LANG']->getLL('fileUpload_uploadWait'),
430 'uploadStarting' => $GLOBALS['LANG']->getLL('fileUpload_uploadStarting'),
431 'uploadProgress' => $GLOBALS['LANG']->getLL('fileUpload_uploadProgress'),
432 'uploadSuccess' => $GLOBALS['LANG']->getLL('fileUpload_uploadSuccess'),
433 'errorQueueLimitExceeded' => $GLOBALS['LANG']->getLL('fileUpload_errorQueueLimitExceeded'),
434 'errorQueueFileSizeLimit' => $GLOBALS['LANG']->getLL('fileUpload_errorQueueFileSizeLimit'),
435 'errorQueueZeroByteFile' => $GLOBALS['LANG']->getLL('fileUpload_errorQueueZeroByteFile'),
436 'errorQueueInvalidFiletype' => $GLOBALS['LANG']->getLL('fileUpload_errorQueueInvalidFiletype'),
437 'errorUploadHttp' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadHttpError'),
438 'errorUploadMissingUrl' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadMissingUrl'),
439 'errorUploadIO' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadIO'),
440 'errorUploadSecurityError' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadSecurityError'),
441 'errorUploadLimit' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadLimit'),
442 'errorUploadFailed' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadFailed'),
443 'errorUploadFileIDNotFound' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadFileIDNotFound'),
444 'errorUploadFileValidation' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadFileValidation'),
445 'errorUploadFileCancelled' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadFileCancelled'),
446 'errorUploadStopped' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadStopped'),
447 'allErrorMessageTitle' => $GLOBALS['LANG']->getLL('fileUpload_allErrorMessageTitle'),
448 'allErrorMessageText' => $GLOBALS['LANG']->getLL('fileUpload_allErrorMessageText'),
449 'allError401' => $GLOBALS['LANG']->getLL('fileUpload_allError401'),
450 'allError2038' => $GLOBALS['LANG']->getLL('fileUpload_allError2038'),
451 );
452
453 // Convert labels/settings back to UTF-8 since json_encode() only works with UTF-8:
454 if ($GLOBALS['LANG']->charSet !== 'utf-8') {
455 $t3Configuration['username'] = $GLOBALS['LANG']->csConvObj->conv($t3Configuration['username'], $GLOBALS['LANG']->charSet, 'utf-8');
456 $GLOBALS['LANG']->csConvObj->convArray($t3LLLcore, $GLOBALS['LANG']->charSet, 'utf-8');
457 $GLOBALS['LANG']->csConvObj->convArray($t3LLLfileUpload, $GLOBALS['LANG']->charSet, 'utf-8');
458 }
459
460 $this->js .= '
461 TYPO3.configuration = ' . json_encode($t3Configuration) . ';
462 TYPO3.LLL = {
463 core : ' . json_encode($t3LLLcore) . ',
464 fileUpload: ' . json_encode($t3LLLfileUpload) . '
465 };
466
467 /**
468 * TypoSetup object.
469 */
470 function typoSetup() { //
471 this.PATH_typo3 = TYPO3.configuration.PATH_typo3;
472 this.PATH_typo3_enc = TYPO3.configuration.PATH_typo3_enc;
473 this.username = TYPO3.configuration.username;
474 this.uniqueID = TYPO3.configuration.uniqueID;
475 this.navFrameWidth = 0;
476 this.securityLevel = TYPO3.configuration.securityLevel;
477 this.veriCode = TYPO3.configuration.veriCode;
478 this.denyFileTypes = TYPO3.configuration.denyFileTypes;
479 }
480 var TS = new typoSetup();
481 //backwards compatibility
482 /**
483 * Frameset Module object
484 *
485 * Used in main modules with a frameset for submodules to keep the ID between modules
486 * Typically that is set by something like this in a Web>* sub module:
487 * if (top.fsMod) top.fsMod.recentIds["web"] = "\'.intval($this->id).\'";
488 * if (top.fsMod) top.fsMod.recentIds["file"] = "...(file reference/string)...";
489 */
490 function fsModules() { //
491 this.recentIds=new Array(); // used by frameset modules to track the most recent used id for list frame.
492 this.navFrameHighlightedID=new Array(); // used by navigation frames to track which row id was highlighted last time
493 this.currentMainLoaded="";
494 this.currentBank="0";
495 }
496 var fsMod = new fsModules();
497
498 top.goToModule = function(modName, cMR_flag, addGetVars) {
499 TYPO3.ModuleMenu.App.showModule(modName, addGetVars);
500 }
501 ' . $this->setStartupModule();
502
503 // Check editing of page:
504 $this->handlePageEditing();
505
506 }
507
508 /**
509 * Checking if the "&edit" variable was sent so we can open it for editing the page.
510 * Code based on code from "alt_shortcut.php"
511 *
512 * @return void
513 */
514 protected function handlePageEditing() {
515
516 if(!t3lib_extMgm::isLoaded('cms')) {
517 return;
518 }
519
520 // EDIT page:
521 $editId = preg_replace('/[^[:alnum:]_]/', '', t3lib_div::_GET('edit'));
522 $editRecord = '';
523
524 if($editId) {
525
526 // Looking up the page to edit, checking permissions:
527 $where = ' AND ('.$GLOBALS['BE_USER']->getPagePermsClause(2)
528 .' OR '.$GLOBALS['BE_USER']->getPagePermsClause(16).')';
529
530 if(t3lib_div::testInt($editId)) {
531 $editRecord = t3lib_BEfunc::getRecordWSOL('pages', $editId, '*', $where);
532 } else {
533 $records = t3lib_BEfunc::getRecordsByField('pages', 'alias', $editId, $where);
534
535 if(is_array($records)) {
536 reset($records);
537 $editRecord = current($records);
538 t3lib_BEfunc::workspaceOL('pages', $editRecord);
539 }
540 }
541
542 // If the page was accessible, then let the user edit it.
543 if(is_array($editRecord) && $GLOBALS['BE_USER']->isInWebMount($editRecord['uid'])) {
544 // Setting JS code to open editing:
545 $this->js .= '
546 // Load page to edit:
547 window.setTimeout("top.loadEditId('.intval($editRecord['uid']).');", 500);
548 ';
549 // Checking page edit parameter:
550 if(!$GLOBALS['BE_USER']->getTSConfigVal('options.shortcut_onEditId_dontSetPageTree')) {
551
552 // Expanding page tree:
553 t3lib_BEfunc::openPageTree(intval($editRecord['pid']), !$GLOBALS['BE_USER']->getTSConfigVal('options.shortcut_onEditId_keepExistingExpanded'));
554 }
555 } else {
556 $this->js .= '
557 // Warning about page editing:
558 alert('.$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('noEditPage'), $editId)).');
559 ';
560 }
561 }
562 }
563
564 /**
565 * Sets the startup module from either GETvars module and mpdParams or user configuration.
566 *
567 * @return void
568 */
569 protected function setStartupModule() {
570 $startModule = preg_replace('/[^[:alnum:]_]/', '', t3lib_div::_GET('module'));
571
572 if(!$startModule) {
573 if ($GLOBALS['BE_USER']->uc['startModule']) {
574 $startModule = $GLOBALS['BE_USER']->uc['startModule'];
575 } else if($GLOBALS['BE_USER']->uc['startInTaskCenter']) {
576 $startModule = 'user_task';
577 }
578 }
579
580 $moduleParameters = t3lib_div::_GET('modParams');
581 if($startModule) {
582 return '
583 // start in module:
584 top.startInModule = [\'' . $startModule . '\', ' . t3lib_div::quoteJSvalue($moduleParameters) . '];
585 ';
586 } else {
587 return '';
588 }
589
590 }
591
592 /**
593 * generates the code for the TYPO3 logo, either the default TYPO3 logo or a custom one
594 *
595 * @return string HTML code snippet to display the TYPO3 logo
596 */
597 protected function getLogo() {
598 $logo = '<a href="http://www.typo3.com/" target="_blank">'.
599 '<img'.t3lib_iconWorks::skinImg('','gfx/alt_backend_logo.gif','width="117" height="32"').' title="TYPO3 Content Management Framework" alt="" />'.
600 '</a>';
601
602 // overwrite with custom logo
603 if($GLOBALS['TBE_STYLES']['logo']) {
604 if(substr($GLOBALS['TBE_STYLES']['logo'], 0, 3) == '../') {
605 $imgInfo = @getimagesize(PATH_site.substr($GLOBALS['TBE_STYLES']['logo'], 3));
606 }
607 $logo = '<a href="http://www.typo3.com/" target="_blank">'.
608 '<img src="'.$GLOBALS['TBE_STYLES']['logo'].'" '.$imgInfo[3].' title="TYPO3 Content Management Framework" alt="" />'.
609 '</a>';
610 }
611
612 return $logo;
613 }
614
615 /**
616 * adds a javascript snippet to the backend
617 *
618 * @param string javascript snippet
619 * @return void
620 */
621 public function addJavascript($javascript) {
622 // TODO do we need more checks?
623 if(!is_string($javascript)) {
624 throw new InvalidArgumentException('parameter $javascript must be of type string', 1195129553);
625 }
626
627 $this->js .= $javascript;
628 }
629
630 /**
631 * adds a javscript file to the backend after it has been checked that it exists
632 *
633 * @param string javascript file reference
634 * @return boolean true if the javascript file was successfully added, false otherwise
635 */
636 public function addJavascriptFile($javascriptFile) {
637 $jsFileAdded = false;
638
639 //TODO add more checks if neccessary
640 if(file_exists(t3lib_div::resolveBackPath(PATH_typo3.$javascriptFile))) {
641 $this->jsFiles[] = $javascriptFile;
642 $jsFileAdded = true;
643 }
644
645 return $jsFileAdded;
646 }
647
648 /**
649 * adds a css snippet to the backend
650 *
651 * @param string css snippet
652 * @return void
653 */
654 public function addCss($css) {
655 if(!is_string($css)) {
656 throw new InvalidArgumentException('parameter $css must be of type string', 1195129642);
657 }
658
659 $this->css .= $css;
660 }
661
662 /**
663 * adds a css file to the backend after it has been checked that it exists
664 *
665 * @param string the css file's name with out the .css ending
666 * @param string css file reference
667 * @return boolean true if the css file was added, false otherwise
668 */
669 public function addCssFile($cssFileName, $cssFile) {
670 $cssFileAdded = false;
671
672 if(empty($this->cssFiles[$cssFileName])) {
673 $this->cssFiles[$cssFileName] = $cssFile;
674 $cssFileAdded = true;
675 }
676
677 return $cssFileAdded;
678 }
679
680 /**
681 * adds an item to the toolbar, the class file for the toolbar item must be loaded at this point
682 *
683 * @param string toolbar item name, f.e. tx_toolbarExtension_coolItem
684 * @param string toolbar item class name, f.e. tx_toolbarExtension_coolItem
685 * @return void
686 */
687 public function addToolbarItem($toolbarItemName, $toolbarItemClassName) {
688 $toolbarItem = t3lib_div::makeInstance($toolbarItemClassName, $this);
689
690 if(!($toolbarItem instanceof backend_toolbarItem)) {
691 throw new UnexpectedValueException('$toolbarItem "'.$toolbarItemName.'" must implement interface backend_toolbarItem', 1195125501);
692 }
693
694 if($toolbarItem->checkAccess()) {
695 $this->toolbarItems[$toolbarItemName] = $toolbarItem;
696 } else {
697 unset($toolbarItem);
698 }
699 }
700
701 /**
702 * Executes defined hooks functions for the given identifier.
703 *
704 * These hook identifiers are valid:
705 * + constructPostProcess
706 * + renderPreProcess
707 * + renderPostProcess
708 *
709 * @param string $identifier Specific hook identifier
710 * @param array $hookConfiguration Additional configuration passed to hook functions
711 * @return void
712 */
713 protected function executeHook($identifier, array $hookConfiguration = array()) {
714 $options =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/backend.php'];
715
716 if(isset($options[$identifier]) && is_array($options[$identifier])) {
717 foreach($options[$identifier] as $hookFunction) {
718 t3lib_div::callUserFunction($hookFunction, $hookConfiguration, $this);
719 }
720 }
721 }
722 }
723
724
725 // include XCLASS
726 if(defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/backend.php']) {
727 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/backend.php']);
728 }
729
730
731 // document generation
732 $TYPO3backend = t3lib_div::makeInstance('TYPO3backend');
733
734 // include extensions which may add css, javascript or toolbar items
735 if(is_array($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'])) {
736 foreach($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'] as $additionalBackendItem) {
737 include_once($additionalBackendItem);
738 }
739 }
740
741 $TYPO3backend->render();
742
743 ?>