2 /***************************************************************
5 * (c) 2007-2010 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');
34 require_once('classes/class.donatewindow.php');
37 require('classes/class.workspaceselector.php');
38 require('classes/class.clearcachemenu.php');
39 require('classes/class.shortcutmenu.php');
40 require('classes/class.backendsearchmenu.php');
42 require_once('class.alt_menu_functions.inc');
43 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_misc.xml');
47 * Class for rendering the TYPO3 backend version 4.2+
49 * @author Ingo Renner <ingo@typo3.org>
60 protected $jsFilesAfterInline;
61 protected $toolbarItems;
62 private $menuWidthDefault = 190; // intentionally private as nobody should modify defaults
66 * Object for loading backend modules
68 * @var t3lib_loadModules
70 protected $moduleLoader;
73 * module menu generating object
77 protected $moduleMenu;
82 * @var t3lib_PageRenderer
84 protected $pageRenderer;
91 public function __construct() {
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();
103 $this->pageRenderer
->addExtOnReadyCode(
104 'TYPO3.Backend = new TYPO3.Viewport(TYPO3.Viewport.configuration);
108 $this->pageRenderer
->addExtDirectCode();
110 // add default BE javascript
112 $this->jsFiles
= array(
113 'contrib/swfupload/swfupload.js',
114 'contrib/swfupload/plugins/swfupload.swfobject.js',
115 'contrib/swfupload/plugins/swfupload.cookies.js',
116 'contrib/swfupload/plugins/swfupload.queue.js',
119 'js/extjs/backendsizemanager.js',
120 'js/toolbarmanager.js',
122 'js/iecompatibility.js',
124 '../t3lib/jsfunc.evalfield.js',
125 '../t3lib/js/extjs/ux/flashmessages.js',
126 '../t3lib/js/extjs/ux/ext.ux.tabclosemenu.js',
128 'js/loginrefresh.js',
129 'js/extjs/debugPanel.js',
130 'js/extjs/viewport.js',
131 'js/extjs/viewportConfiguration.js',
134 // add default BE css
136 $this->cssFiles
= array();
138 $this->toolbarItems
= array();
139 $this->initializeCoreToolbarItems();
141 $this->menuWidth
= $this->menuWidthDefault
;
142 if (isset($GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW']) && (int) $GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW'] != (int) $this->menuWidth
) {
143 $this->menuWidth
= (int) $GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW'];
146 $this->executeHook('constructPostProcess');
150 * initializes the core toolbar items
154 protected function initializeCoreToolbarItems() {
156 $coreToolbarItems = array(
157 'workspaceSelector' => 'WorkspaceSelector',
158 'shortcuts' => 'ShortcutMenu',
159 'clearCacheActions' => 'ClearCacheMenu',
160 'backendSearch' => 'BackendSearchMenu'
163 foreach($coreToolbarItems as $toolbarItemName => $toolbarItemClassName) {
164 $toolbarItem = t3lib_div
::makeInstance($toolbarItemClassName, $this);
166 if(!($toolbarItem instanceof backend_toolbarItem
)) {
167 throw new UnexpectedValueException('$toolbarItem "'.$toolbarItemName.'" must implement interface backend_toolbarItem', 1195126772);
170 if($toolbarItem->checkAccess()) {
171 $this->toolbarItems
[$toolbarItemName] = $toolbarItem;
179 * main function generating the BE scaffolding
183 public function render() {
184 $this->executeHook('renderPreProcess');
186 if (t3lib_div
::makeInstance('DonateWindow')->isDonateWindowAllowed()) {
187 $this->pageRenderer
->addJsFile('js/donate.js');
190 // prepare the scaffolding, at this point extension may still add javascript and css
191 $logo = t3lib_div
::makeInstance('TYPO3Logo');
192 $logo->setLogo('gfx/typo3logo_mini.png');
194 $menu = $this->moduleMenu
->render();
196 if ($this->menuWidth
!= $this->menuWidthDefault
) {
199 margin-left: ' . $this->menuWidth
. 'px;
204 // create backend scaffolding
205 $backendScaffolding = '
206 <div id="typo3-backend">
207 <div id="typo3-top-container" class="x-hide-display">
208 <div id="typo3-logo">'.$logo->render().'</div>
209 <div id="typo3-top" class="typo3-top-toolbar">' .
210 $this->renderToolbar() .
213 <div id="typo3-main-container">
214 <div id="typo3-side-menu" class="x-hide-display">' .
217 <div id="typo3-content" class="x-hide-display">
218 <iframe src="alt_intro.php" name="content" id="content" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto"></iframe>
224 /******************************************************
225 * now put the complete backend document together
226 ******************************************************/
228 foreach($this->cssFiles
as $cssFileName => $cssFile) {
229 $this->pageRenderer
->addCssFile($cssFile);
231 // load addditional css files to overwrite existing core styles
232 if(!empty($GLOBALS['TBE_STYLES']['stylesheets'][$cssFileName])) {
233 $this->pageRenderer
->addCssFile($GLOBALS['TBE_STYLES']['stylesheets'][$cssFileName]);
237 if(!empty($this->css
)) {
238 $this->pageRenderer
->addCssInlineBlock('BackendInlineCSS', $this->css
);
241 foreach ($this->jsFiles
as $jsFile) {
242 $this->pageRenderer
->addJsFile($jsFile);
245 // Those lines can be removed once we have at least one official ExtDirect router within the backend.
246 $hasExtDirectRouter = FALSE;
247 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ExtDirect']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ExtDirect'])) {
248 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ExtDirect'] as $key => $value) {
249 if (strpos($key, 'TYPO3.Ajax.ExtDirect') !== FALSE) {
250 $hasExtDirectRouter = TRUE;
255 if ($hasExtDirectRouter) {
256 $this->pageRenderer
->addJsFile('ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.Ajax.ExtDirect', NULL, FALSE);
259 $this->generateJavascript();
260 $this->pageRenderer
->addJsInlineCode('BackendInlineJavascript', $this->js
);
263 // set document title:
264 $title = ($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']
265 ?
$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'].' [TYPO3 '.TYPO3_version
.']'
266 : 'TYPO3 '.TYPO3_version
269 // start page header:
270 $this->content
.= $GLOBALS['TBE_TEMPLATE']->startPage($title);
271 $this->content
.= $backendScaffolding;
272 $this->content
.= $GLOBALS['TBE_TEMPLATE']->endPage();
274 $hookConfiguration = array('content' => &$this->content
);
275 $this->executeHook('renderPostProcess', $hookConfiguration);
281 * renders the items in the top toolbar
283 * @return string top toolbar elements as HTML
285 protected function renderToolbar() {
287 // move search to last position
288 $search = $this->toolbarItems
['backendSearch'];
289 unset($this->toolbarItems
['backendSearch']);
290 $this->toolbarItems
['backendSearch'] = $search;
292 $toolbar = '<ul id="typo3-toolbar">';
293 $toolbar.= '<li>'.$this->getLoggedInUserLabel().'</li>
294 <li><div id="logout-button" class="toolbar-item no-separator">'.$this->moduleMenu
->renderLogoutButton().'</div></li>';
296 foreach($this->toolbarItems
as $toolbarItem) {
297 $menu = $toolbarItem->render();
299 $additionalAttributes = $toolbarItem->getAdditionalAttributes();
300 $toolbar .= '<li' . $additionalAttributes . '>' .$menu. '</li>';
304 return $toolbar.'</ul>';
308 * Gets the label of the BE user currently logged in
310 * @return string html code snippet displaying the currently logged in user
312 protected function getLoggedInUserLabel() {
313 global $BE_USER, $BACK_PATH;
315 $icon = t3lib_iconWorks
::getSpriteIcon('status-user-'. ($BE_USER->isAdmin() ?
'admin' : 'backend'));
317 $label = $GLOBALS['BE_USER']->user
['realName'] ?
318 $BE_USER->user
['realName'] . ' (' . $BE_USER->user
['username'] . ')' :
319 $BE_USER->user
['username'];
321 // Link to user setup if it's loaded and user has access
323 if (t3lib_extMgm
::isLoaded('setup') && $BE_USER->check('modules','user_setup')) {
324 $link = '<a href="#" onclick="top.goToModule(\'user_setup\');this.blur();return false;">';
327 $username = '">'.$link.$icon.'<span>'.htmlspecialchars($label).'</span>'.($link?
'</a>':'');
330 if($BE_USER->user
['ses_backuserid']) {
331 $username = ' su-user">'.$icon.
332 '<span title="' . $GLOBALS['LANG']->getLL('switchtouser') . '">' .
333 $GLOBALS['LANG']->getLL('switchtousershort') . ' </span>' .
334 '<span>' . htmlspecialchars($label) . '</span>';
337 return '<div id="username" class="toolbar-item no-separator'.$username.'</div>';
341 * Generates the JavaScript code for the backend.
345 protected function generateJavascript() {
347 $pathTYPO3 = t3lib_div
::dirname(t3lib_div
::getIndpEnv('SCRIPT_NAME')).'/';
348 $goToModuleSwitch = $this->moduleMenu
->getGotoModuleJavascript();
349 $moduleFramesHelper = implode(LF
, $this->moduleMenu
->getFsMod());
351 // If another page module was specified, replace the default Page module with the new one
352 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
353 $pageModule = t3lib_BEfunc
::isModuleSetInTBE_MODULES($newPageModule) ?
$newPageModule : 'web_layout';
354 if (!$GLOBALS['BE_USER']->check('modules', $pageModule)) {
358 $menuFrameName = 'menu';
359 if($GLOBALS['BE_USER']->uc
['noMenuMode'] === 'icons') {
360 $menuFrameName = 'topmenuFrame';
363 // determine security level from conf vars and default to super challenged
364 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel']) {
365 $this->loginSecurityLevel
= $GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel'];
367 $this->loginSecurityLevel
= 'superchallenged';
370 $t3Configuration = array(
371 'siteUrl' => t3lib_div
::getIndpEnv('TYPO3_SITE_URL'),
372 'PATH_typo3' => $pathTYPO3,
373 'PATH_typo3_enc' => rawurlencode($pathTYPO3),
374 'username' => htmlspecialchars($GLOBALS['BE_USER']->user
['username']),
375 'uniqueID' => t3lib_div
::shortMD5(uniqid('')),
376 'securityLevel' => $this->loginSecurityLevel
,
377 'TYPO3_mainDir' => TYPO3_mainDir
,
378 'pageModule' => $pageModule,
379 'condensedMode' => $GLOBALS['BE_USER']->uc
['condensedMode'] ?
1 : 0 ,
380 'inWorkspace' => $GLOBALS['BE_USER']->workspace
!== 0 ?
1 : 0,
381 'workspaceFrontendPreviewEnabled' => $GLOBALS['BE_USER']->user
['workspace_preview'] ?
1 : 0,
382 'veriCode' => $GLOBALS['BE_USER']->veriCode(),
383 'denyFileTypes' => PHP_EXTENSIONS_DEFAULT
,
384 'moduleMenuWidth' => $this->menuWidth
- 1,
385 'topBarHeight' => (isset($GLOBALS['TBE_STYLES']['dims']['topFrameH']) ?
intval($GLOBALS['TBE_STYLES']['dims']['topFrameH']) : 30),
386 'showRefreshLoginPopup' => isset($GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup']) ?
intval($GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup']) : FALSE,
387 'listModulePath' => t3lib_extMgm
::isLoaded('list') ? t3lib_extMgm
::extRelPath('list') . 'mod1/' : '',
390 'waitTitle' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_logging_in') ,
391 'refresh_login_failed' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_failed'),
392 'refresh_login_failed_message' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_failed_message'),
393 'refresh_login_title' => sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_title'), htmlspecialchars($GLOBALS['BE_USER']->user
['username'])),
394 'login_expired' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.login_expired'),
395 'refresh_login_username' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_username'),
396 'refresh_login_password' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_password'),
397 'refresh_login_emptyPassword' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_emptyPassword'),
398 'refresh_login_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_button'),
399 'refresh_logout_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_logout_button'),
400 'please_wait' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.please_wait'),
401 'be_locked' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.be_locked'),
402 'refresh_login_countdown_singular' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_countdown_singular'),
403 'refresh_login_countdown' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_countdown'),
404 'login_about_to_expire' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.login_about_to_expire'),
405 'login_about_to_expire_title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.login_about_to_expire_title'),
406 'refresh_login_refresh_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_refresh_button'),
407 'refresh_direct_logout_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_direct_logout_button'),
408 'tabs_closeAll' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:tabs.closeAll'),
409 'tabs_closeOther' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:tabs.closeOther'),
410 'tabs_close' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:tabs.close'),
411 'donateWindow_title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.title'),
412 'donateWindow_message' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.message'),
413 'donateWindow_button_donate' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.button_donate'),
414 'donateWindow_button_disable' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.button_disable'),
415 'donateWindow_button_postpone' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.button_postpone'),
417 $t3LLLfileUpload = array(
418 'windowTitle' => $GLOBALS['LANG']->getLL('fileUpload_windowTitle'),
419 'buttonSelectFiles' => $GLOBALS['LANG']->getLL('fileUpload_buttonSelectFiles'),
420 'buttonCancelAll' => $GLOBALS['LANG']->getLL('fileUpload_buttonCancelAll'),
421 'infoComponentMaxFileSize' => $GLOBALS['LANG']->getLL('fileUpload_infoComponentMaxFileSize'),
422 'infoComponentFileUploadLimit' => $GLOBALS['LANG']->getLL('fileUpload_infoComponentFileUploadLimit'),
423 'infoComponentFileTypeLimit' => $GLOBALS['LANG']->getLL('fileUpload_infoComponentFileTypeLimit'),
424 'infoComponentOverrideFiles' => $GLOBALS['LANG']->getLL('fileUpload_infoComponentOverrideFiles'),
425 'processRunning' => $GLOBALS['LANG']->getLL('fileUpload_processRunning'),
426 'uploadWait' => $GLOBALS['LANG']->getLL('fileUpload_uploadWait'),
427 'uploadStarting' => $GLOBALS['LANG']->getLL('fileUpload_uploadStarting'),
428 'uploadProgress' => $GLOBALS['LANG']->getLL('fileUpload_uploadProgress'),
429 'uploadSuccess' => $GLOBALS['LANG']->getLL('fileUpload_uploadSuccess'),
430 'errorQueueLimitExceeded' => $GLOBALS['LANG']->getLL('fileUpload_errorQueueLimitExceeded'),
431 'errorQueueFileSizeLimit' => $GLOBALS['LANG']->getLL('fileUpload_errorQueueFileSizeLimit'),
432 'errorQueueZeroByteFile' => $GLOBALS['LANG']->getLL('fileUpload_errorQueueZeroByteFile'),
433 'errorQueueInvalidFiletype' => $GLOBALS['LANG']->getLL('fileUpload_errorQueueInvalidFiletype'),
434 'errorUploadHttp' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadHttpError'),
435 'errorUploadMissingUrl' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadMissingUrl'),
436 'errorUploadIO' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadIO'),
437 'errorUploadSecurityError' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadSecurityError'),
438 'errorUploadLimit' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadLimit'),
439 'errorUploadFailed' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadFailed'),
440 'errorUploadFileIDNotFound' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadFileIDNotFound'),
441 'errorUploadFileValidation' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadFileValidation'),
442 'errorUploadFileCancelled' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadFileCancelled'),
443 'errorUploadStopped' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadStopped'),
444 'allErrorMessageTitle' => $GLOBALS['LANG']->getLL('fileUpload_allErrorMessageTitle'),
445 'allErrorMessageText' => $GLOBALS['LANG']->getLL('fileUpload_allErrorMessageText'),
446 'allError401' => $GLOBALS['LANG']->getLL('fileUpload_allError401'),
447 'allError2038' => $GLOBALS['LANG']->getLL('fileUpload_allError2038'),
450 // Convert labels/settings back to UTF-8 since json_encode() only works with UTF-8:
451 if ($GLOBALS['LANG']->charSet
!== 'utf-8') {
452 $t3Configuration['username'] = $GLOBALS['LANG']->csConvObj
->conv($t3Configuration['username'], $GLOBALS['LANG']->charSet
, 'utf-8');
453 $GLOBALS['LANG']->csConvObj
->convArray($t3LLLcore, $GLOBALS['LANG']->charSet
, 'utf-8');
454 $GLOBALS['LANG']->csConvObj
->convArray($t3LLLfileUpload, $GLOBALS['LANG']->charSet
, 'utf-8');
458 TYPO3.configuration = ' . json_encode($t3Configuration) . ';
460 core : ' . json_encode($t3LLLcore) . ',
461 fileUpload: ' . json_encode($t3LLLfileUpload) . '
467 function typoSetup() { //
468 this.PATH_typo3 = TYPO3.configuration.PATH_typo3;
469 this.PATH_typo3_enc = TYPO3.configuration.PATH_typo3_enc;
470 this.username = TYPO3.configuration.username;
471 this.uniqueID = TYPO3.configuration.uniqueID;
472 this.navFrameWidth = 0;
473 this.securityLevel = TYPO3.configuration.securityLevel;
474 this.veriCode = TYPO3.configuration.veriCode;
475 this.denyFileTypes = TYPO3.configuration.denyFileTypes;
477 var TS = new typoSetup();
479 var currentModuleLoaded = "";
482 * Frameset Module object
484 * Used in main modules with a frameset for submodules to keep the ID between modules
485 * Typically that is set by something like this in a Web>* sub module:
486 * if (top.fsMod) top.fsMod.recentIds["web"] = "\'.intval($this->id).\'";
487 * if (top.fsMod) top.fsMod.recentIds["file"] = "...(file reference/string)...";
489 function fsModules() { //
490 this.recentIds=new Array(); // used by frameset modules to track the most recent used id for list frame.
491 this.navFrameHighlightedID=new Array(); // used by navigation frames to track which row id was highlighted last time
492 this.currentMainLoaded="";
493 this.currentBank="0";
495 var fsMod = new fsModules();' . $moduleFramesHelper . ';';
497 // add goToModule code
498 $this->pageRenderer
->addExtOnReadyCode('
499 top.goToModule = ' . $goToModuleSwitch . ';
502 // Check editing of page:
503 $this->handlePageEditing();
504 $this->setStartupModule();
508 * Checking if the "&edit" variable was sent so we can open it for editing the page.
509 * Code based on code from "alt_shortcut.php"
513 protected function handlePageEditing() {
515 if(!t3lib_extMgm
::isLoaded('cms')) {
520 $editId = preg_replace('/[^[:alnum:]_]/', '', t3lib_div
::_GET('edit'));
525 // Looking up the page to edit, checking permissions:
526 $where = ' AND ('.$GLOBALS['BE_USER']->getPagePermsClause(2)
527 .' OR '.$GLOBALS['BE_USER']->getPagePermsClause(16).')';
529 if(t3lib_div
::testInt($editId)) {
530 $editRecord = t3lib_BEfunc
::getRecordWSOL('pages', $editId, '*', $where);
532 $records = t3lib_BEfunc
::getRecordsByField('pages', 'alias', $editId, $where);
534 if(is_array($records)) {
536 $editRecord = current($records);
537 t3lib_BEfunc
::workspaceOL('pages', $editRecord);
541 // If the page was accessible, then let the user edit it.
542 if(is_array($editRecord) && $GLOBALS['BE_USER']->isInWebMount($editRecord['uid'])) {
543 // Setting JS code to open editing:
545 // Load page to edit:
546 window.setTimeout("top.loadEditId('.intval($editRecord['uid']).');", 500);
548 // Checking page edit parameter:
549 if(!$GLOBALS['BE_USER']->getTSConfigVal('options.shortcut_onEditId_dontSetPageTree')) {
551 // Expanding page tree:
552 t3lib_BEfunc
::openPageTree(intval($editRecord['pid']), !$GLOBALS['BE_USER']->getTSConfigVal('options.shortcut_onEditId_keepExistingExpanded'));
556 // Warning about page editing:
557 alert('.$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('noEditPage'), $editId)).');
564 * Sets the startup module from either GETvars module and mpdParams or user configuration.
568 protected function setStartupModule() {
569 $startModule = preg_replace('/[^[:alnum:]_]/', '', t3lib_div
::_GET('module'));
572 if ($GLOBALS['BE_USER']->uc
['startModule']) {
573 $startModule = $GLOBALS['BE_USER']->uc
['startModule'];
574 } else if($GLOBALS['BE_USER']->uc
['startInTaskCenter']) {
575 $startModule = 'user_task';
579 $moduleParameters = t3lib_div
::_GET('modParams');
581 $this->pageRenderer
->addExtOnReadyCode('
583 function startInModule(modName, cMR_flag, addGetVars) {
584 Ext.onReady(function() {
585 top.goToModule(modName, cMR_flag, addGetVars);
589 startInModule(\''.$startModule.'\', false, '.t3lib_div
::quoteJSvalue($moduleParameters).');
595 * generates the code for the TYPO3 logo, either the default TYPO3 logo or a custom one
597 * @return string HTML code snippet to display the TYPO3 logo
599 protected function getLogo() {
600 $logo = '<a href="http://www.typo3.com/" target="_blank" onclick="'.$GLOBALS['TBE_TEMPLATE']->thisBlur().'">'.
601 '<img'.t3lib_iconWorks
::skinImg('','gfx/alt_backend_logo.gif','width="117" height="32"').' title="TYPO3 Content Management Framework" alt="" />'.
604 // overwrite with custom logo
605 if($GLOBALS['TBE_STYLES']['logo']) {
606 if(substr($GLOBALS['TBE_STYLES']['logo'], 0, 3) == '../') {
607 $imgInfo = @getimagesize
(PATH_site
.substr($GLOBALS['TBE_STYLES']['logo'], 3));
609 $logo = '<a href="http://www.typo3.com/" target="_blank" onclick="'.$GLOBALS['TBE_TEMPLATE']->thisBlur().'">'.
610 '<img src="'.$GLOBALS['TBE_STYLES']['logo'].'" '.$imgInfo[3].' title="TYPO3 Content Management Framework" alt="" />'.
618 * adds a javascript snippet to the backend
620 * @param string javascript snippet
623 public function addJavascript($javascript) {
624 // TODO do we need more checks?
625 if(!is_string($javascript)) {
626 throw new InvalidArgumentException('parameter $javascript must be of type string', 1195129553);
629 $this->js
.= $javascript;
633 * adds a javscript file to the backend after it has been checked that it exists
635 * @param string javascript file reference
636 * @return boolean true if the javascript file was successfully added, false otherwise
638 public function addJavascriptFile($javascriptFile) {
639 $jsFileAdded = false;
641 //TODO add more checks if neccessary
642 if(file_exists(t3lib_div
::resolveBackPath(PATH_typo3
.$javascriptFile))) {
643 $this->jsFiles
[] = $javascriptFile;
651 * adds a css snippet to the backend
653 * @param string css snippet
656 public function addCss($css) {
657 if(!is_string($css)) {
658 throw new InvalidArgumentException('parameter $css must be of type string', 1195129642);
665 * adds a css file to the backend after it has been checked that it exists
667 * @param string the css file's name with out the .css ending
668 * @param string css file reference
669 * @return boolean true if the css file was added, false otherwise
671 public function addCssFile($cssFileName, $cssFile) {
672 $cssFileAdded = false;
674 if(empty($this->cssFiles
[$cssFileName])) {
675 $this->cssFiles
[$cssFileName] = $cssFile;
676 $cssFileAdded = true;
679 return $cssFileAdded;
683 * adds an item to the toolbar, the class file for the toolbar item must be loaded at this point
685 * @param string toolbar item name, f.e. tx_toolbarExtension_coolItem
686 * @param string toolbar item class name, f.e. tx_toolbarExtension_coolItem
689 public function addToolbarItem($toolbarItemName, $toolbarItemClassName) {
690 $toolbarItem = t3lib_div
::makeInstance($toolbarItemClassName, $this);
692 if(!($toolbarItem instanceof backend_toolbarItem
)) {
693 throw new UnexpectedValueException('$toolbarItem "'.$toolbarItemName.'" must implement interface backend_toolbarItem', 1195125501);
696 if($toolbarItem->checkAccess()) {
697 $this->toolbarItems
[$toolbarItemName] = $toolbarItem;
704 * Executes defined hooks functions for the given identifier.
706 * These hook identifiers are valid:
707 * + constructPostProcess
709 * + renderPostProcess
711 * @param string $identifier Specific hook identifier
712 * @param array $hookConfiguration Additional configuration passed to hook functions
715 protected function executeHook($identifier, array $hookConfiguration = array()) {
716 $options =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/backend.php'];
718 if(isset($options[$identifier]) && is_array($options[$identifier])) {
719 foreach($options[$identifier] as $hookFunction) {
720 t3lib_div
::callUserFunction($hookFunction, $hookConfiguration, $this);
728 if(defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/backend.php']) {
729 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/backend.php']);
733 // document generation
734 $TYPO3backend = t3lib_div
::makeInstance('TYPO3backend');
736 // include extensions which may add css, javascript or toolbar items
737 if(is_array($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'])) {
738 foreach($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'] as $additionalBackendItem) {
739 include_once($additionalBackendItem);
743 $TYPO3backend->render();