2 /***************************************************************
5 * (c) 2007-2011 Ingo Renner <ingo@typo3.org>
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.
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.
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.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 require_once('init.php');
29 require_once('template.php');
30 require_once('interfaces/interface.backend_toolbaritem.php');
32 require('classes/class.typo3logo.php');
33 require('classes/class.modulemenu.php');
36 require('classes/class.clearcachemenu.php');
37 require('classes/class.shortcutmenu.php');
38 require('classes/class.livesearch.php');
40 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_misc.xml');
44 * Class for rendering the TYPO3 backend version 4.2+
46 * @author Ingo Renner <ingo@typo3.org>
57 protected $jsFilesAfterInline;
58 protected $toolbarItems;
59 private $menuWidthDefault = 190; // intentionally private as nobody should modify defaults
64 * Object for loading backend modules
66 * @var t3lib_loadModules
68 protected $moduleLoader;
71 * module menu generating object
75 protected $moduleMenu;
80 * @var t3lib_PageRenderer
82 protected $pageRenderer;
89 public function __construct() {
90 // set debug flag for BE development only
91 $this->debug
= intval($GLOBALS['TYPO3_CONF_VARS']['BE']['debug']) === 1;
93 // Initializes the backend modules structure for use later.
94 $this->moduleLoader
= t3lib_div
::makeInstance('t3lib_loadModules');
95 $this->moduleLoader
->load($GLOBALS['TBE_MODULES']);
97 $this->moduleMenu
= t3lib_div
::makeInstance('ModuleMenu');
99 $this->pageRenderer
= $GLOBALS['TBE_TEMPLATE']->getPageRenderer();
100 $this->pageRenderer
->loadScriptaculous('builder,effects,controls,dragdrop');
101 $this->pageRenderer
->loadExtJS();
102 $this->pageRenderer
->enableExtJSQuickTips();
105 $this->pageRenderer
->addJsInlineCode(
106 'consoleOverrideWithDebugPanel',
109 $this->pageRenderer
->addExtDirectCode();
111 // add default BE javascript
113 $this->jsFiles
= array(
114 'common' => 'js/common.js',
115 'locallang' => $this->getLocalLangFileName(),
116 'modernizr' => 'contrib/modernizr/modernizr.min.js',
117 'swfupload' => 'contrib/swfupload/swfupload.js',
118 'swfupload.swfobject' => 'contrib/swfupload/plugins/swfupload.swfobject.js',
119 'swfupload.cookies' => 'contrib/swfupload/plugins/swfupload.cookies.js',
120 'swfupload.queue' => 'contrib/swfupload/plugins/swfupload.queue.js',
122 'toolbarmanager' => 'js/toolbarmanager.js',
123 'modulemenu' => 'js/modulemenu.js',
124 'iecompatibility' => 'js/iecompatibility.js',
125 'flashupload' => 'js/flashupload.js',
126 'evalfield' => '../t3lib/jsfunc.evalfield.js',
127 'flashmessages' => '../t3lib/js/extjs/ux/flashmessages.js',
128 'tabclosemenu' => '../t3lib/js/extjs/ux/ext.ux.tabclosemenu.js',
129 'notifications' => '../t3lib/js/extjs/notifications.js',
130 'backend' => 'js/backend.js',
131 'loginrefresh' => 'js/loginrefresh.js',
132 'debugPanel' => 'js/extjs/debugPanel.js',
133 'viewport' => 'js/extjs/viewport.js',
134 'iframepanel' => 'js/extjs/iframepanel.js',
135 'viewportConfiguration' => 'js/extjs/viewportConfiguration.js',
136 'util' => '../t3lib/js/extjs/util.js',
140 unset($this->jsFiles
['loginrefresh']);
143 // add default BE css
145 $this->cssFiles
= array();
147 $this->toolbarItems
= array();
148 $this->initializeCoreToolbarItems();
150 $this->menuWidth
= $this->menuWidthDefault
;
151 if (isset($GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW']) && (int) $GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW'] != (int) $this->menuWidth
) {
152 $this->menuWidth
= (int) $GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW'];
155 $this->executeHook('constructPostProcess');
159 * initializes the core toolbar items
163 protected function initializeCoreToolbarItems() {
165 $coreToolbarItems = array(
166 'shortcuts' => 'ShortcutMenu',
167 'clearCacheActions' => 'ClearCacheMenu',
168 'liveSearch' => 'LiveSearch'
171 foreach($coreToolbarItems as $toolbarItemName => $toolbarItemClassName) {
172 $toolbarItem = t3lib_div
::makeInstance($toolbarItemClassName, $this);
174 if(!($toolbarItem instanceof backend_toolbarItem
)) {
175 throw new UnexpectedValueException('$toolbarItem "'.$toolbarItemName.'" must implement interface backend_toolbarItem', 1195126772);
178 if($toolbarItem->checkAccess()) {
179 $this->toolbarItems
[$toolbarItemName] = $toolbarItem;
187 * main function generating the BE scaffolding
191 public function render() {
192 $this->executeHook('renderPreProcess');
194 // prepare the scaffolding, at this point extension may still add javascript and css
195 $logo = t3lib_div
::makeInstance('TYPO3Logo');
196 $logo->setLogo('gfx/typo3logo_mini.png');
200 // create backend scaffolding
201 $backendScaffolding = '
202 <div id="typo3-top-container" class="x-hide-display">
203 <div id="typo3-logo">'.$logo->render().'</div>
204 <div id="typo3-top" class="typo3-top-toolbar">' .
205 $this->renderToolbar() .
211 /******************************************************
212 * now put the complete backend document together
213 ******************************************************/
215 foreach($this->cssFiles
as $cssFileName => $cssFile) {
216 $this->pageRenderer
->addCssFile($cssFile);
218 // load addditional css files to overwrite existing core styles
219 if(!empty($GLOBALS['TBE_STYLES']['stylesheets'][$cssFileName])) {
220 $this->pageRenderer
->addCssFile($GLOBALS['TBE_STYLES']['stylesheets'][$cssFileName]);
224 if(!empty($this->css
)) {
225 $this->pageRenderer
->addCssInlineBlock('BackendInlineCSS', $this->css
);
228 foreach ($this->jsFiles
as $jsFile) {
229 $this->pageRenderer
->addJsFile($jsFile);
233 $this->generateJavascript();
234 $this->pageRenderer
->addJsInlineCode('BackendInlineJavascript', $this->js
);
236 $this->loadResourcesForRegisteredNavigationComponents();
238 // add state provider
239 $GLOBALS['TBE_TEMPLATE']->setExtDirectStateProvider();
240 $states = $GLOBALS['BE_USER']->uc
['BackendComponents']['States'];
241 //save states in BE_USER->uc
243 Ext.state.Manager.setProvider(new TYPO3.state.ExtDirectProvider({
244 key: "BackendComponents.States",
249 $extOnReadyCode .= 'Ext.state.Manager.getProvider().initState(' . json_encode($states) . ');';
252 TYPO3.Backend = new TYPO3.Viewport(TYPO3.Viewport.configuration);
253 if (typeof console === "undefined") {
254 console = TYPO3.Backend.DebugConsole;
256 TYPO3.ContextHelpWindow.init();';
257 $this->pageRenderer
->addExtOnReadyCode($extOnReadyCode);
260 // set document title:
261 $title = ($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']
262 ?
$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'].' [TYPO3 '.TYPO3_version
.']'
263 : 'TYPO3 '.TYPO3_version
266 $this->content
= $backendScaffolding;
267 // Renders the module page
268 $this->content
= $GLOBALS['TBE_TEMPLATE']->render(
273 $hookConfiguration = array('content' => &$this->content
);
274 $this->executeHook('renderPostProcess', $hookConfiguration);
280 * Loads the css and javascript files of all registered navigation widgets
284 protected function loadResourcesForRegisteredNavigationComponents() {
285 if (!is_array($GLOBALS['TBE_MODULES']['_navigationComponents'])) {
289 $loadedComponents = array();
290 foreach ($GLOBALS['TBE_MODULES']['_navigationComponents'] as $module => $info) {
291 if (in_array($info['componentId'], $loadedComponents)) {
294 $loadedComponents[] = $info['componentId'];
296 $component = strtolower(substr($info['componentId'], strrpos($info['componentId'], '-') +
1));
297 $componentDirectory = 'components/' . $component . '/';
299 if ($info['isCoreComponent']) {
300 $absoluteComponentPath = PATH_t3lib
. 'js/extjs/' . $componentDirectory;
301 $relativeComponentPath = '../' . str_replace(PATH_site
, '', $absoluteComponentPath);
303 $absoluteComponentPath = t3lib_extMgm
::extPath($info['extKey']) . $componentDirectory;
304 $relativeComponentPath = t3lib_extMgm
::extRelPath($info['extKey']) . $componentDirectory;
307 $cssFiles = t3lib_div
::getFilesInDir($absoluteComponentPath . 'css/', 'css');
308 if (file_exists($absoluteComponentPath . 'css/loadorder.txt')) {
309 //don't allow inclusion outside directory
310 $loadOrder = str_replace('../', '', t3lib_div
::getURL($absoluteComponentPath . 'css/loadorder.txt'));
311 $cssFilesOrdered = t3lib_div
::trimExplode(LF
, $loadOrder, TRUE);
312 $cssFiles = array_merge($cssFilesOrdered, $cssFiles);
314 foreach ($cssFiles as $cssFile) {
315 $this->pageRenderer
->addCssFile($relativeComponentPath . 'css/' . $cssFile);
318 $jsFiles = t3lib_div
::getFilesInDir($absoluteComponentPath . 'javascript/', 'js');
319 if (file_exists($absoluteComponentPath . 'javascript/loadorder.txt')) {
320 //don't allow inclusion outside directory
321 $loadOrder = str_replace('../', '', t3lib_div
::getURL($absoluteComponentPath . 'javascript/loadorder.txt'));
322 $jsFilesOrdered = t3lib_div
::trimExplode(LF
, $loadOrder, TRUE);
323 $jsFiles = array_merge($jsFilesOrdered, $jsFiles);
326 foreach ($jsFiles as $jsFile) {
327 $this->pageRenderer
->addJsFile($relativeComponentPath . 'javascript/' . $jsFile);
333 * renders the items in the top toolbar
335 * @return string top toolbar elements as HTML
337 protected function renderToolbar() {
339 // move search to last position
340 if (array_key_exists('liveSearch', $this->toolbarItems
)) {
341 $search = $this->toolbarItems
['liveSearch'];
342 unset($this->toolbarItems
['liveSearch']);
343 $this->toolbarItems
['liveSearch'] = $search;
346 $toolbar = '<ul id="typo3-toolbar">';
347 $toolbar.= '<li>'.$this->getLoggedInUserLabel().'</li>
348 <li><div id="logout-button" class="toolbar-item no-separator">'.$this->moduleMenu
->renderLogoutButton().'</div></li>';
350 foreach($this->toolbarItems
as $toolbarItem) {
351 $menu = $toolbarItem->render();
353 $additionalAttributes = $toolbarItem->getAdditionalAttributes();
354 $toolbar .= '<li' . $additionalAttributes . '>' .$menu. '</li>';
358 return $toolbar.'</ul>';
362 * Gets the label of the BE user currently logged in
364 * @return string html code snippet displaying the currently logged in user
366 protected function getLoggedInUserLabel() {
367 $icon = t3lib_iconWorks
::getSpriteIcon('status-user-' . ($GLOBALS['BE_USER']->isAdmin() ?
'admin' : 'backend'));
369 $label = $GLOBALS['BE_USER']->user
['realName'] ?
370 $GLOBALS['BE_USER']->user
['realName'] . ' (' . $GLOBALS['BE_USER']->user
['username'] . ')' :
371 $GLOBALS['BE_USER']->user
['username'];
373 // Link to user setup if it's loaded and user has access
375 if (t3lib_extMgm
::isLoaded('setup') && $GLOBALS['BE_USER']->check('modules','user_setup')) {
376 $link = '<a href="#" onclick="top.goToModule(\'user_setup\');this.blur();return false;">';
379 $username = '">'.$link.$icon.'<span>'.htmlspecialchars($label).'</span>'.($link?
'</a>':'');
382 if ($GLOBALS['BE_USER']->user
['ses_backuserid']) {
383 $username = ' su-user">'.$icon.
384 '<span title="' . $GLOBALS['LANG']->getLL('switchtouser') . '">' .
385 $GLOBALS['LANG']->getLL('switchtousershort') . ' </span>' .
386 '<span>' . htmlspecialchars($label) . '</span>';
389 return '<div id="username" class="toolbar-item no-separator'.$username.'</div>';
393 * Returns the file name to the LLL JavaScript, containing the localized labels,
394 * which can be used in JavaScript code.
396 * @return string File name of the JS file, relative to TYPO3_mainDir
398 protected function getLocalLangFileName() {
399 $code = $this->generateLocalLang();
400 $filePath = 'typo3temp/locallang-BE-' . sha1($code) . '.js';
401 if (!file_exists(PATH_site
. $filePath)) {
402 // writeFileToTypo3tempDir() returns NULL on success (please double-read!)
403 if (t3lib_div
::writeFileToTypo3tempDir(PATH_site
. $filePath, $code) !== NULL) {
404 throw new RuntimeException('LocalLangFile could not be written to ' . $filePath, 1295193026);
407 return '../' . $filePath;
411 * Reads labels required in JavaScript code from the localization system and returns them as JSON
412 * array in TYPO3.LLL.
414 * @return string JavaScript code containing the LLL labels in TYPO3.LLL
416 protected function generateLocalLang() {
418 'waitTitle' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_logging_in') ,
419 'refresh_login_failed' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_failed'),
420 'refresh_login_failed_message' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_failed_message'),
421 'refresh_login_title' => sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_title'), htmlspecialchars($GLOBALS['BE_USER']->user
['username'])),
422 'login_expired' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.login_expired'),
423 'refresh_login_username' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_username'),
424 'refresh_login_password' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_password'),
425 'refresh_login_emptyPassword' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_emptyPassword'),
426 'refresh_login_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_button'),
427 'refresh_logout_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_logout_button'),
428 'please_wait' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.please_wait'),
429 'loadingIndicator' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:loadingIndicator'),
430 'be_locked' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.be_locked'),
431 'refresh_login_countdown_singular' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_countdown_singular'),
432 'refresh_login_countdown' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_countdown'),
433 'login_about_to_expire' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.login_about_to_expire'),
434 'login_about_to_expire_title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.login_about_to_expire_title'),
435 'refresh_login_refresh_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_refresh_button'),
436 'refresh_direct_logout_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_direct_logout_button'),
437 'tabs_closeAll' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:tabs.closeAll'),
438 'tabs_closeOther' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:tabs.closeOther'),
439 'tabs_close' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:tabs.close'),
440 'tabs_openInBrowserWindow' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:tabs.openInBrowserWindow'),
441 'csh_tooltip_loading' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:csh_tooltip_loading'),
445 'fileUpload' => array(
449 'infoComponentMaxFileSize',
450 'infoComponentFileUploadLimit',
451 'infoComponentFileTypeLimit',
452 'infoComponentOverrideFiles',
458 'errorQueueLimitExceeded',
459 'errorQueueFileSizeLimit',
460 'errorQueueZeroByteFile',
461 'errorQueueInvalidFiletype',
463 'errorUploadMissingUrl',
465 'errorUploadSecurityError',
468 'errorUploadFileIDNotFound',
469 'errorUploadFileValidation',
470 'errorUploadFileCancelled',
471 'errorUploadStopped',
472 'allErrorMessageTitle',
473 'allErrorMessageText',
477 'liveSearch' => array(
485 'helpDescriptionPages',
486 'helpDescriptionContent',
489 'tooltipModuleMenuSplit',
490 'tooltipNavigationContainerSplitDrag',
491 'tooltipDebugPanelSplitDrag',
495 $generatedLabels = array();
496 $generatedLabels['core'] = $coreLabels;
498 // first loop over all categories (fileUpload, liveSearch, ..)
499 foreach ($labels as $categoryName => $categoryLabels) {
500 // then loop over every single label
501 foreach ($categoryLabels as $label) {
502 // LLL identifier must be called $categoryName_$label, e.g. liveSearch_loadingText
503 $generatedLabels[$categoryName][$label] = $GLOBALS['LANG']->getLL($categoryName . '_' . $label);
507 // Convert labels/settings back to UTF-8 since json_encode() only works with UTF-8:
508 if ($GLOBALS['LANG']->charSet
!== 'utf-8') {
509 $GLOBALS['LANG']->csConvObj
->convArray($generatedLabels, $GLOBALS['LANG']->charSet
, 'utf-8');
512 return 'TYPO3.LLL = ' . json_encode($generatedLabels) . ';';
516 * Generates the JavaScript code for the backend.
520 protected function generateJavascript() {
522 $pathTYPO3 = t3lib_div
::dirname(t3lib_div
::getIndpEnv('SCRIPT_NAME')).'/';
524 // If another page module was specified, replace the default Page module with the new one
525 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
526 $pageModule = t3lib_BEfunc
::isModuleSetInTBE_MODULES($newPageModule) ?
$newPageModule : 'web_layout';
527 if (!$GLOBALS['BE_USER']->check('modules', $pageModule)) {
531 $menuFrameName = 'menu';
532 if($GLOBALS['BE_USER']->uc
['noMenuMode'] === 'icons') {
533 $menuFrameName = 'topmenuFrame';
536 // determine security level from conf vars and default to super challenged
537 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel']) {
538 $this->loginSecurityLevel
= $GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel'];
540 $this->loginSecurityLevel
= 'superchallenged';
543 $t3Configuration = array(
544 'siteUrl' => t3lib_div
::getIndpEnv('TYPO3_SITE_URL'),
545 'PATH_typo3' => $pathTYPO3,
546 'PATH_typo3_enc' => rawurlencode($pathTYPO3),
547 'username' => htmlspecialchars($GLOBALS['BE_USER']->user
['username']),
548 'uniqueID' => t3lib_div
::shortMD5(uniqid('')),
549 'securityLevel' => $this->loginSecurityLevel
,
550 'TYPO3_mainDir' => TYPO3_mainDir
,
551 'pageModule' => $pageModule,
552 'condensedMode' => $GLOBALS['BE_USER']->uc
['condensedMode'] ?
1 : 0 ,
553 'inWorkspace' => $GLOBALS['BE_USER']->workspace
!== 0 ?
1 : 0,
554 'workspaceFrontendPreviewEnabled' => $GLOBALS['BE_USER']->user
['workspace_preview'] ?
1 : 0,
555 'veriCode' => $GLOBALS['BE_USER']->veriCode(),
556 'denyFileTypes' => PHP_EXTENSIONS_DEFAULT
,
557 'moduleMenuWidth' => $this->menuWidth
- 1,
558 'topBarHeight' => (isset($GLOBALS['TBE_STYLES']['dims']['topFrameH']) ?
intval($GLOBALS['TBE_STYLES']['dims']['topFrameH']) : 30),
559 'showRefreshLoginPopup' => isset($GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup']) ?
intval($GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup']) : FALSE,
560 'listModulePath' => t3lib_extMgm
::isLoaded('recordlist') ? t3lib_extMgm
::extRelPath('recordlist') . 'mod1/' : '',
561 'debugInWindow' => $GLOBALS['BE_USER']->uc
['debugInWindow'] ?
1 : 0,
562 'ContextHelpWindows' => array(
566 'firstWebmountPid' => intval($GLOBALS['WEBMOUNTS'][0]),
568 if ($GLOBALS['LANG']->charSet
!== 'utf-8') {
569 $t3Configuration['username'] = $GLOBALS['LANG']->csConvObj
->conv($t3Configuration['username'], $GLOBALS['LANG']->charSet
, 'utf-8');
573 TYPO3.configuration = ' . json_encode($t3Configuration) . ';
578 function typoSetup() { //
579 this.PATH_typo3 = TYPO3.configuration.PATH_typo3;
580 this.PATH_typo3_enc = TYPO3.configuration.PATH_typo3_enc;
581 this.username = TYPO3.configuration.username;
582 this.uniqueID = TYPO3.configuration.uniqueID;
583 this.navFrameWidth = 0;
584 this.securityLevel = TYPO3.configuration.securityLevel;
585 this.veriCode = TYPO3.configuration.veriCode;
586 this.denyFileTypes = TYPO3.configuration.denyFileTypes;
588 var TS = new typoSetup();
589 //backwards compatibility
591 * Frameset Module object
593 * Used in main modules with a frameset for submodules to keep the ID between modules
594 * Typically that is set by something like this in a Web>* sub module:
595 * if (top.fsMod) top.fsMod.recentIds["web"] = "\'.intval($this->id).\'";
596 * if (top.fsMod) top.fsMod.recentIds["file"] = "...(file reference/string)...";
598 function fsModules() { //
599 this.recentIds=new Array(); // used by frameset modules to track the most recent used id for list frame.
600 this.navFrameHighlightedID=new Array(); // used by navigation frames to track which row id was highlighted last time
601 this.currentMainLoaded="";
602 this.currentBank="0";
604 var fsMod = new fsModules();
606 top.goToModule = function(modName, cMR_flag, addGetVars) {
607 TYPO3.ModuleMenu.App.showModule(modName, addGetVars);
609 ' . $this->setStartupModule();
611 // Check editing of page:
612 $this->handlePageEditing();
617 * Checking if the "&edit" variable was sent so we can open it for editing the page.
618 * Code based on code from "alt_shortcut.php"
622 protected function handlePageEditing() {
624 if(!t3lib_extMgm
::isLoaded('cms')) {
629 $editId = preg_replace('/[^[:alnum:]_]/', '', t3lib_div
::_GET('edit'));
634 // Looking up the page to edit, checking permissions:
635 $where = ' AND ('.$GLOBALS['BE_USER']->getPagePermsClause(2)
636 .' OR '.$GLOBALS['BE_USER']->getPagePermsClause(16).')';
638 if(t3lib_div
::testInt($editId)) {
639 $editRecord = t3lib_BEfunc
::getRecordWSOL('pages', $editId, '*', $where);
641 $records = t3lib_BEfunc
::getRecordsByField('pages', 'alias', $editId, $where);
643 if(is_array($records)) {
645 $editRecord = current($records);
646 t3lib_BEfunc
::workspaceOL('pages', $editRecord);
650 // If the page was accessible, then let the user edit it.
651 if(is_array($editRecord) && $GLOBALS['BE_USER']->isInWebMount($editRecord['uid'])) {
652 // Setting JS code to open editing:
654 // Load page to edit:
655 window.setTimeout("top.loadEditId('.intval($editRecord['uid']).');", 500);
658 // "Shortcuts" have been renamed to "Bookmarks"
659 // @deprecated remove shortcuts code in TYPO3 4.7
660 $shortcutSetPageTree = $GLOBALS['BE_USER']->getTSConfigVal('options.shortcut_onEditId_dontSetPageTree');
661 $bookmarkSetPageTree = $GLOBALS['BE_USER']->getTSConfigVal('options.bookmark_onEditId_dontSetPageTree');
662 if ($shortcutSetPageTree !== '') {
663 t3lib_div
::deprecationLog('options.shortcut_onEditId_dontSetPageTree - since TYPO3 4.5, will be removed in TYPO3 4.7 - use options.bookmark_onEditId_dontSetPageTree instead');
666 // Checking page edit parameter:
667 if (!$shortcutSetPageTree && !$bookmarkSetPageTree) {
669 $shortcutKeepExpanded = $GLOBALS['BE_USER']->getTSConfigVal('options.shortcut_onEditId_keepExistingExpanded');
670 $bookmarkKeepExpanded = $GLOBALS['BE_USER']->getTSConfigVal('options.bookmark_onEditId_keepExistingExpanded');
671 $keepExpanded = ($shortcutKeepExpanded ||
$bookmarkKeepExpanded);
673 // Expanding page tree:
674 t3lib_BEfunc
::openPageTree(intval($editRecord['pid']), !$keepExpanded);
676 if ($shortcutKeepExpanded) {
677 t3lib_div
::deprecationLog('options.shortcut_onEditId_keepExistingExpanded - since TYPO3 4.5, will be removed in TYPO3 4.7 - use options.bookmark_onEditId_keepExistingExpanded instead');
682 // Warning about page editing:
683 alert('.$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('noEditPage'), $editId)).');
690 * Sets the startup module from either GETvars module and mpdParams or user configuration.
694 protected function setStartupModule() {
695 $startModule = preg_replace('/[^[:alnum:]_]/', '', t3lib_div
::_GET('module'));
698 if ($GLOBALS['BE_USER']->uc
['startModule']) {
699 $startModule = $GLOBALS['BE_USER']->uc
['startModule'];
700 } elseif ($GLOBALS['BE_USER']->uc
['startInTaskCenter']) {
701 $startModule = 'user_task';
705 $moduleParameters = t3lib_div
::_GET('modParams');
709 top.startInModule = [\'' . $startModule . '\', ' . t3lib_div
::quoteJSvalue($moduleParameters) . '];
718 * adds a javascript snippet to the backend
720 * @param string javascript snippet
723 public function addJavascript($javascript) {
724 // TODO do we need more checks?
725 if(!is_string($javascript)) {
726 throw new InvalidArgumentException('parameter $javascript must be of type string', 1195129553);
729 $this->js
.= $javascript;
733 * adds a javscript file to the backend after it has been checked that it exists
735 * @param string javascript file reference
736 * @return boolean TRUE if the javascript file was successfully added, false otherwise
738 public function addJavascriptFile($javascriptFile) {
739 $jsFileAdded = false;
741 //TODO add more checks if neccessary
742 if(file_exists(t3lib_div
::resolveBackPath(PATH_typo3
.$javascriptFile))) {
743 $this->jsFiles
[] = $javascriptFile;
751 * adds a css snippet to the backend
753 * @param string css snippet
756 public function addCss($css) {
757 if(!is_string($css)) {
758 throw new InvalidArgumentException('parameter $css must be of type string', 1195129642);
765 * adds a css file to the backend after it has been checked that it exists
767 * @param string the css file's name with out the .css ending
768 * @param string css file reference
769 * @return boolean TRUE if the css file was added, false otherwise
771 public function addCssFile($cssFileName, $cssFile) {
772 $cssFileAdded = false;
774 if(empty($this->cssFiles
[$cssFileName])) {
775 $this->cssFiles
[$cssFileName] = $cssFile;
776 $cssFileAdded = TRUE;
779 return $cssFileAdded;
783 * adds an item to the toolbar, the class file for the toolbar item must be loaded at this point
785 * @param string toolbar item name, f.e. tx_toolbarExtension_coolItem
786 * @param string toolbar item class name, f.e. tx_toolbarExtension_coolItem
789 public function addToolbarItem($toolbarItemName, $toolbarItemClassName) {
790 $toolbarItem = t3lib_div
::makeInstance($toolbarItemClassName, $this);
792 if(!($toolbarItem instanceof backend_toolbarItem
)) {
793 throw new UnexpectedValueException('$toolbarItem "'.$toolbarItemName.'" must implement interface backend_toolbarItem', 1195125501);
796 if($toolbarItem->checkAccess()) {
797 $this->toolbarItems
[$toolbarItemName] = $toolbarItem;
804 * Executes defined hooks functions for the given identifier.
806 * These hook identifiers are valid:
807 * + constructPostProcess
809 * + renderPostProcess
811 * @param string $identifier Specific hook identifier
812 * @param array $hookConfiguration Additional configuration passed to hook functions
815 protected function executeHook($identifier, array $hookConfiguration = array()) {
816 $options =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/backend.php'];
818 if(isset($options[$identifier]) && is_array($options[$identifier])) {
819 foreach($options[$identifier] as $hookFunction) {
820 t3lib_div
::callUserFunction($hookFunction, $hookConfiguration, $this);
828 if(defined('TYPO3_MODE') && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['typo3/backend.php']) {
829 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE
]['XCLASS']['typo3/backend.php']);
833 // document generation
834 $TYPO3backend = t3lib_div
::makeInstance('TYPO3backend');
836 // include extensions which may add css, javascript or toolbar items
837 if(is_array($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'])) {
838 foreach($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'] as $additionalBackendItem) {
839 include_once($additionalBackendItem);
843 $TYPO3backend->render();