2 /***************************************************************
5 * (c) 2007-2009 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.workspaceselector.php');
37 require('classes/class.clearcachemenu.php');
38 require('classes/class.shortcutmenu.php');
39 require('classes/class.backendsearchmenu.php');
41 require_once(PATH_t3lib
.'class.t3lib_loadmodules.php');
42 require_once(PATH_t3lib
.'class.t3lib_basicfilefunc.php');
43 require_once('class.alt_menu_functions.inc');
44 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_misc.xml');
48 * Class for rendering the TYPO3 backend version 4.2+
50 * @author Ingo Renner <ingo@typo3.org>
61 protected $toolbarItems;
62 private $menuWidthDefault = 160; // 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;
84 public function __construct() {
86 // Initializes the backend modules structure for use later.
87 $this->moduleLoader
= t3lib_div
::makeInstance('t3lib_loadModules');
88 $this->moduleLoader
->load($GLOBALS['TBE_MODULES']);
90 $this->moduleMenu
= t3lib_div
::makeInstance('ModuleMenu');
92 // add default BE javascript
94 $this->jsFiles
= array(
95 'contrib/prototype/prototype.js',
96 'contrib/scriptaculous/scriptaculous.js?load=builder,effects,controls,dragdrop',
97 'contrib/extjs/adapter/ext/ext-base.js',
98 'contrib/extjs/ext-all.js',
103 'js/toolbarmanager.js',
105 'js/iecompatibility.js',
106 '../t3lib/jsfunc.evalfield.js'
109 // add default BE css
111 $this->cssFiles
= array(
112 'backend-scaffolding' => 'css/backend-scaffolding.css',
113 'backend-style' => 'css/backend-style.css',
114 'modulemenu' => 'css/modulemenu.css',
115 'extJS' => 'contrib/extjs/resources/css/ext-all.css',
116 'extJS-gray' => 'contrib/extjs/resources/css/xtheme-gray.css'
119 $this->toolbarItems
= array();
120 $this->initializeCoreToolbarItems();
122 $this->menuWidth
= $this->menuWidthDefault
;
123 if (isset($GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW']) && (int) $GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW'] != (int) $this->menuWidth
) {
124 $this->menuWidth
= (int) $GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW'];
129 * initializes the core toolbar items
133 protected function initializeCoreToolbarItems() {
135 $coreToolbarItems = array(
136 'workspaceSelector' => 'WorkspaceSelector',
137 'shortcuts' => 'ShortcutMenu',
138 'clearCacheActions' => 'ClearCacheMenu',
139 'backendSearch' => 'BackendSearchMenu'
142 foreach($coreToolbarItems as $toolbarItemName => $toolbarItemClassName) {
143 $toolbarItem = t3lib_div
::makeInstance($toolbarItemClassName, $this);
145 if(!($toolbarItem instanceof backend_toolbarItem
)) {
146 throw new UnexpectedValueException('$toolbarItem "'.$toolbarItemName.'" must implement interface backend_toolbarItem', 1195126772);
149 if($toolbarItem->checkAccess()) {
150 $this->toolbarItems
[$toolbarItemName] = $toolbarItem;
158 * main function generating the BE scaffolding
162 public function render() {
164 // prepare the scaffolding, at this point extension may still add javascript and css
165 $logo = t3lib_div
::makeInstance('TYPO3Logo');
166 $logo->setLogo('gfx/typo3logo_mini.png');
168 $menu = $this->moduleMenu
->render();
170 if ($this->menuWidth
!= $this->menuWidthDefault
) {
174 width: ' . ($this->menuWidth
- 1) . 'px;
179 margin-left: ' . $this->menuWidth
. 'px;
184 // create backend scaffolding
185 $backendScaffolding = '
186 <div id="typo3-backend">
187 <div id="typo3-top-container">
188 <div id="typo3-logo">'.$logo->render().'</div>
189 <div id="typo3-top" class="typo3-top-toolbar">'
190 .$this->renderToolbar()
193 <div id="typo3-main-container">
194 <div id="typo3-side-menu">
197 <div id="typo3-content">
198 <iframe src="alt_intro.php" name="content" id="content" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto"></iframe>
204 /******************************************************
205 * now put the complete backend document together
206 ******************************************************/
208 // remove duplicate entries
209 $this->jsFiles
= array_unique($this->jsFiles
);
212 foreach($this->jsFiles
as $jsFile) {
213 $GLOBALS['TBE_TEMPLATE']->JScode
.= '
214 <script type="text/javascript" src="'.$jsFile.'"></script>';
216 $GLOBALS['TBE_TEMPLATE']->JScode
.= chr(10);
217 $this->generateJavascript();
218 $GLOBALS['TBE_TEMPLATE']->JScode
.= $GLOBALS['TBE_TEMPLATE']->wrapScriptTags($this->js
);
220 // FIXME abusing the JS container to add CSS, need to fix template.php
221 foreach($this->cssFiles
as $cssFileName => $cssFile) {
222 $GLOBALS['TBE_TEMPLATE']->JScode
.= '
223 <link rel="stylesheet" type="text/css" href="'.$cssFile.'" />
226 // load addditional css files to overwrite existing core styles
227 if(!empty($GLOBALS['TBE_STYLES']['stylesheets'][$cssFileName])) {
228 $GLOBALS['TBE_TEMPLATE']->JScode
.= '
229 <link rel="stylesheet" type="text/css" href="'.$GLOBALS['TBE_STYLES']['stylesheets'][$cssFileName].'" />
234 if(!empty($this->css
)) {
235 $GLOBALS['TBE_TEMPLATE']->JScode
.= '
236 <style type="text/css" id="internalStyle">
241 // set document title:
242 $title = ($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']
243 ?
$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'].' [TYPO3 '.TYPO3_version
.']'
244 : 'TYPO3 '.TYPO3_version
247 // start page header:
248 $this->content
.= $GLOBALS['TBE_TEMPLATE']->startPage($title);
249 $this->content
.= $backendScaffolding;
250 $this->content
.= $GLOBALS['TBE_TEMPLATE']->endPage();
256 * renders the items in the top toolbar
258 * @return string top toolbar elements as HTML
260 protected function renderToolbar() {
262 // move search to last position
263 $search = $this->toolbarItems
['backendSearch'];
264 unset($this->toolbarItems
['backendSearch']);
265 $this->toolbarItems
['backendSearch'] = $search;
267 $toolbar = '<ul id="typo3-toolbar">';
268 $toolbar.= '<li>'.$this->getLoggedInUserLabel().'</li>
269 <li><div id="logout-button" class="toolbar-item no-separator">'.$this->moduleMenu
->renderLogoutButton().'</div></li>';
271 foreach($this->toolbarItems
as $toolbarItem) {
272 $menu = $toolbarItem->render();
274 $additionalAttributes = $toolbarItem->getAdditionalAttributes();
275 $toolbar .= '<li' . $additionalAttributes . '>' .$menu. '</li>';
279 return $toolbar.'</ul>';
283 * gets the label of the currently loged in BE user
285 * @return string html code snippet displaying the currently logged in user
287 protected function getLoggedInUserLabel() {
288 global $BE_USER, $BACK_PATH;
290 $icon = '<img'.t3lib_iconWorks
::skinImg(
292 $BE_USER->isAdmin() ?
293 'gfx/i/be_users_admin.gif' :
294 'gfx/i/be_users.gif',
295 'width="18" height="16"'
297 .' title="" alt="" />';
299 $label = $GLOBALS['BE_USER']->user
['realName'] ?
300 $BE_USER->user
['realName'].' ['.$BE_USER->user
['username'].']' :
301 $BE_USER->user
['username'];
303 // Link to user setup if it's loaded and user has access
305 if (t3lib_extMgm
::isLoaded('setup') && $BE_USER->check('modules','user_setup')) {
306 $link = '<a href="#" onclick="top.goToModule(\'user_setup\');this.blur();return false;">';
309 $username = '">'.$link.$icon.'<span>'.htmlspecialchars($label).'</span>'.($link?
'</a>':'');
312 if($BE_USER->user
['ses_backuserid']) {
313 $username = ' su-user">'.$icon.
314 '<span title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:switchtouser').'">SU: </span>'.
315 '<span>'.htmlspecialchars($label).'</span>';
318 return '<div id="username" class="toolbar-item no-separator'.$username.'</div>';
322 * Generates the JavaScript code for the backend.
326 protected function generateJavascript() {
328 $pathTYPO3 = t3lib_div
::dirname(t3lib_div
::getIndpEnv('SCRIPT_NAME')).'/';
329 $goToModuleSwitch = $this->moduleMenu
->getGotoModuleJavascript();
330 $moduleFramesHelper = implode(chr(10), $this->moduleMenu
->getFsMod());
332 // If another page module was specified, replace the default Page module with the new one
333 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
334 $pageModule = t3lib_BEfunc
::isModuleSetInTBE_MODULES($newPageModule) ?
$newPageModule : 'web_layout';
336 $menuFrameName = 'menu';
337 if($GLOBALS['BE_USER']->uc
['noMenuMode'] === 'icons') {
338 $menuFrameName = 'topmenuFrame';
341 // create challenge for the (re)login form and save it in the session.
342 $challenge = md5(uniqid('').getmypid());
344 $_SESSION['login_challenge'] = $challenge;
346 // determine security level from conf vars and default to super challenged
347 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel']) {
348 $this->loginSecurityLevel
= $GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel'];
350 $this->loginSecurityLevel
= 'superchallenged';
354 Ext.BLANK_IMAGE_URL = "' .
355 // t3lib_div::locationHeaderUrl() will include '/typo3/' in the URL
356 htmlspecialchars(t3lib_div
::locationHeaderUrl('gfx/clear.gif')) .
360 * Function similar to PHPs rawurlencode();
362 function rawurlencode(str) {
363 var output = escape(str);
364 output = str_replace("*","%2A", output);
365 output = str_replace("+","%2B", output);
366 output = str_replace("/","%2F", output);
367 output = str_replace("@","%40", output);
372 * Function to similar to PHPs rawurlencode() which removes TYPO3_SITE_URL;
374 function rawurlencodeAndRemoveSiteUrl(str) { //
375 var siteUrl = "' . t3lib_div
::getIndpEnv('TYPO3_SITE_URL') . '";
376 return rawurlencode(str_replace(siteUrl, \'\', str));
380 * String-replace function
382 function str_replace(match,replace,string) { //
383 var input = ""+string;
384 var matchStr = ""+match;
385 if (!matchStr) {return string;}
388 var pos = input.indexOf(matchStr);
390 output+=""+input.substr(pointer, pos-pointer)+replace;
391 pointer=pos+matchStr.length;
392 pos = input.indexOf(match,pos+1);
394 output+=""+input.substr(pointer);
401 function typoSetup() { //
402 this.PATH_typo3 = "'.$pathTYPO3.'";
403 this.PATH_typo3_enc = "'.rawurlencode($pathTYPO3).'";
404 this.username = "'.htmlspecialchars($GLOBALS['BE_USER']->user
['username']).'";
405 this.uniqueID = "'.t3lib_div
::shortMD5(uniqid('')).'";
406 this.navFrameWidth = 0;
407 this.securityLevel = "'.$this->loginSecurityLevel
.'";
409 var TS = new typoSetup();
412 * Functions for session-expiry detection:
415 this.loginRefreshed = busy_loginRefreshed;
416 this.openRefreshWindow = busy_OpenRefreshWindow;
417 this.openLockedWaitWindow = busy_openLockedWaitWindow;
420 this.reloginCancelled=0;
424 // starts the timer and resets the earlyRelogin variable so that
425 // the countdown works properly.
426 this.startTimer = function() {
427 this.earlyRelogin = 0;
431 this.stopTimer = function() {
435 // simple timer that polls the server to determine imminent timeout.
436 this.timer = new Ajax.PeriodicalUpdater("","ajax.php", {
440 parameters: "ajaxID=BackendLogin::isTimedOut&skipSessionUpdate=1",
441 onSuccess: function(e) {
442 var login = e.responseJSON.login.evalJSON();
445 busy.openLockedWaitWindow();
446 } else if(login.timed_out) {
447 busy.openRefreshWindow();
449 if (busy.locked && !login.locked && !login.timed_out) {
451 Ext.MessageBox.hide();
456 // this function runs the countdown and opens the login window
457 // as soon as the countdown expires.
458 this.countDown = function(progressControl, progressTextFormatPlural, progressTextFormatSingular, secondsRemaining, totalSeconds) {
460 if(busy.earlyRelogin == 0) {
461 if(secondsRemaining > 1) {
462 progressControl.updateText(String.format(progressTextFormatPlural, secondsRemaining));
463 progressControl.updateProgress(secondsRemaining/(1.0*totalSeconds));
464 setTimeout(function () {
465 busy.countDown(progressControl, progressTextFormatPlural, progressTextFormatSingular,secondsRemaining - 1, totalSeconds);
467 } else if(secondsRemaining > 0) {
468 progressControl.updateText(String.format(progressTextFormatSingular, secondsRemaining));
469 progressControl.updateProgress(secondsRemaining/(1.0*totalSeconds));
470 setTimeout(function () {
471 busy.countDown(progressControl, progressTextFormatPlural, progressTextFormatSingular,secondsRemaining - 1, totalSeconds);
474 busy.openRefreshW = 1;
480 // Closes the countdown window and opens a new one with a login form.
481 this.openLogin = function() {
483 doChallengeResponse = function(superchallenged) {
484 password = $$("#loginform form")[0].p_field.value;
487 if (superchallenged) {
488 password = MD5(password); // this makes it superchallenged!!
490 str = $("login_username").value+":"+password+":"+$("challenge").value;
491 $("userident").value = MD5(str);
492 $("password").value = "";
498 submitForm = function() {
499 if(TS.securityLevel == "superchallenged") {
500 doChallengeResponse(1);
501 } else if (TS.securityLevel == "challenged") {
502 doChallengeResponse(0);
504 $("userident").value = $$("#loginform form")[0].p_field.value;
505 $("password").value= "";
508 login.getForm().submit({
510 waitTitle: "' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.refresh_login_logging_in') . '",
512 params: "ajaxID=BackendLogin::login&login_status=login",
513 success: function() {
515 setTimeout(busy.startTimer(), 2000);
519 failure: function() {
520 // TODO: add failure to notification system instead of alert
521 // Ext.tip.msg("Login failed", "Username or Password incorrect!");
522 Ext.Msg.alert("' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.refresh_login_failed') . '", "' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.refresh_login_failed_message') . '");
527 logout = new Ajax.Request("ajax.php", {
529 parameters: "ajaxID=BackendLogin::logout"
532 Ext.onReady(function(){
533 login = new Ext.FormPanel({
536 title: "' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.refresh_login_title') . '",
537 defaultType: "textfield",
539 bodyStyle: "padding: 5px 5px 3px 5px; border-width: 0; margin-bottom: 7px;",
543 bodyStyle: "margin-bottom: 7px; border: none;",
544 html: "' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.login_expired') . '"
546 fieldLabel: "' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.refresh_login_username') . '",
548 id: "login_username",
552 fieldLabel: "' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.refresh_login_password') . '",
556 inputType: "password"
566 value: "' . $challenge . '"
570 key: Ext.EventObject.ENTER,
575 text: "' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.refresh_login_button') . '",
579 text: "' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.refresh_logout_button') . '",
581 handler: function() {
582 top.location.href = "' . t3lib_div
::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir
. '";
587 win = new Ext.Window({
603 function busy_loginRefreshed() { //
608 function busy_openLockedWaitWindow() {
609 Ext.MessageBox.show({
610 title: "' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.please_wait') . '",
611 msg: "' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.be_locked') . '",
613 icon: Ext.MessageBox.INFO,
618 function busy_OpenRefreshWindow() {
619 this.openRefreshW = 1;
624 var progressTextFormatSingular = "' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.refresh_login_countdown_singular') . '";
625 var progressTextFormatPlural = "' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.refresh_login_countdown') . '";
626 var progressText = String.format(progressTextFormatPlural, seconds);
627 var progressControl = new Ext.ProgressBar({
634 win = new Ext.Window({
641 bodyStyle: "padding: 5px 5px 3px 5px; border-width: 0; margin-bottom: 7px;",
645 html: "' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.login_about_to_expire') . '"
649 title: "' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.login_about_to_expire_title') . '",
653 text: "' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.refresh_login_refresh_button') . '",
654 handler: function() {
655 refresh = new Ajax.Request("ajax.php", {
657 parameters: "ajaxID=BackendLogin::refreshLogin"
660 busy.earlyRelogin = 1;
661 setTimeout("busy.startTimer()", 2000);
664 text: "' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.refresh_direct_logout_button') . '",
665 handler: function() {
666 top.location.href = "' . t3lib_div
::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir
. 'logout.php";
671 busy.countDown(progressControl, progressTextFormatPlural, progressTextFormatSingular, seconds, seconds);
675 * Launcing information window for records/files (fileref as "table" argument)
677 function launchView(table,uid,bP) { //
678 var backPath= bP ? bP : "";
679 var thePreviewWindow="";
680 thePreviewWindow = window.open(TS.PATH_typo3+"show_item.php?table="+encodeURIComponent(table)+"&uid="+encodeURIComponent(uid),"ShowItem"+TS.uniqueID,"height=400,width=550,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
681 if (thePreviewWindow && thePreviewWindow.focus) {
682 thePreviewWindow.focus();
687 * Opens plain window with url
689 function openUrlInWindow(url,windowName) { //
690 regularWindow = window.open(url,windowName,"status=1,menubar=1,resizable=1,location=1,directories=0,scrollbars=1,toolbar=1");
691 regularWindow.focus();
696 * Loads a page id for editing in the page edit module:
698 function loadEditId(id,addGetVars) { //
699 top.fsMod.recentIds["web"]=id;
700 top.fsMod.navFrameHighlightedID["web"]="pages"+id+"_0"; // For highlighting
702 if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
703 top.content.nav_frame.refresh_nav();
706 top.goToModule("'.$pageModule.'", 0, addGetVars?addGetVars:"");
710 * Returns incoming URL (to a module) unless nextLoadModuleUrl is set. If that is the case nextLoadModuleUrl is returned (and cleared)
711 * Used by the shortcut frame to set a "intermediate URL"
713 var nextLoadModuleUrl="";
714 function getModuleUrl(inUrl) { //
716 if (top.nextLoadModuleUrl) {
717 nMU=top.nextLoadModuleUrl;
718 top.nextLoadModuleUrl="";
726 * Print properties of an object
728 function debugObj(obj,name) { //
732 acc+=i+": "+obj[i]+"\n";
735 alert("Object: "+name+"\n\n"+acc);
739 * Initialize login expiration warning object
741 var busy = new busy();
742 busy.loginRefreshed();
745 * Function used to switch modules
747 var currentModuleLoaded = "";
748 var goToModule = '.$goToModuleSwitch.'
751 * Frameset Module object
753 * Used in main modules with a frameset for submodules to keep the ID between modules
754 * Typically that is set by something like this in a Web>* sub module:
755 * if (top.fsMod) top.fsMod.recentIds["web"] = "\'.intval($this->id).\'";
756 * if (top.fsMod) top.fsMod.recentIds["file"] = "...(file reference/string)...";
758 function fsModules() { //
759 this.recentIds=new Array(); // used by frameset modules to track the most recent used id for list frame.
760 this.navFrameHighlightedID=new Array(); // used by navigation frames to track which row id was highlighted last time
761 this.currentMainLoaded="";
762 this.currentBank="0";
764 var fsMod = new fsModules();
765 '.$moduleFramesHelper.'
767 // Used by Frameset Modules
768 var condensedMode = '.($GLOBALS['BE_USER']->uc
['condensedMode']?
1:0).';
769 var currentSubScript = "";
770 var currentSubNavScript = "";
772 // Used for tab-panels:
773 var DTM_currentTabs = new Array();
775 // status of WS FE preview
776 var WorkspaceFrontendPreviewEnabled = ' . (($GLOBALS['BE_USER']->workspace
!= 0 && !$GLOBALS['BE_USER']->user
['workspace_preview']) ?
'false' : 'true') . ';
779 // Check editing of page:
780 $this->handlePageEditing();
781 $this->setStartupModule();
785 * Checking if the "&edit" variable was sent so we can open it for editing the page.
786 * Code based on code from "alt_shortcut.php"
790 protected function handlePageEditing() {
792 if(!t3lib_extMgm
::isLoaded('cms')) {
797 $editId = preg_replace('/[^[:alnum:]_]/', '', t3lib_div
::_GET('edit'));
802 // Looking up the page to edit, checking permissions:
803 $where = ' AND ('.$GLOBALS['BE_USER']->getPagePermsClause(2)
804 .' OR '.$GLOBALS['BE_USER']->getPagePermsClause(16).')';
806 if(t3lib_div
::testInt($editId)) {
807 $editRecord = t3lib_BEfunc
::getRecordWSOL('pages', $editId, '*', $where);
809 $records = t3lib_BEfunc
::getRecordsByField('pages', 'alias', $editId, $where);
811 if(is_array($records)) {
813 $editRecord = current($records);
814 t3lib_BEfunc
::workspaceOL('pages', $editRecord);
818 // If the page was accessible, then let the user edit it.
819 if(is_array($editRecord) && $GLOBALS['BE_USER']->isInWebMount($editRecord['uid'])) {
820 // Setting JS code to open editing:
822 // Load page to edit:
823 window.setTimeout("top.loadEditId('.intval($editRecord['uid']).');", 500);
825 // Checking page edit parameter:
826 if(!$GLOBALS['BE_USER']->getTSConfigVal('options.shortcut_onEditId_dontSetPageTree')) {
828 // Expanding page tree:
829 t3lib_BEfunc
::openPageTree(intval($editRecord['pid']), !$GLOBALS['BE_USER']->getTSConfigVal('options.shortcut_onEditId_keepExistingExpanded'));
833 // Warning about page editing:
834 alert('.$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('noEditPage'), $editId)).');
841 * Sets the startup module from either GETvars module and mpdParams or user configuration.
845 protected function setStartupModule() {
846 $startModule = preg_replace('/[^[:alnum:]_]/', '', t3lib_div
::_GET('module'));
849 if ($GLOBALS['BE_USER']->uc
['startModule']) {
850 $startModule = $GLOBALS['BE_USER']->uc
['startModule'];
851 } else if($GLOBALS['BE_USER']->uc
['startInTaskCenter']) {
852 $startModule = 'user_task';
856 $moduleParameters = t3lib_div
::_GET('modParams');
860 function startInModule(modName, cMR_flag, addGetVars) {
861 Event.observe(document, \'dom:loaded\', function() {
862 top.goToModule(modName, cMR_flag, addGetVars);
866 startInModule(\''.$startModule.'\', false, \''.$moduleParameters.'\');
872 * generates the code for the TYPO3 logo, either the default TYPO3 logo or a custom one
874 * @return string HTML code snippet to display the TYPO3 logo
876 protected function getLogo() {
877 $logo = '<a href="http://www.typo3.com/" target="_blank" onclick="'.$GLOBALS['TBE_TEMPLATE']->thisBlur().'">'.
878 '<img'.t3lib_iconWorks
::skinImg('','gfx/alt_backend_logo.gif','width="117" height="32"').' title="TYPO3 Content Management Framework" alt="" />'.
881 // overwrite with custom logo
882 if($GLOBALS['TBE_STYLES']['logo']) {
883 if(substr($GLOBALS['TBE_STYLES']['logo'], 0, 3) == '../') {
884 $imgInfo = @getimagesize
(PATH_site
.substr($GLOBALS['TBE_STYLES']['logo'], 3));
886 $logo = '<a href="http://www.typo3.com/" target="_blank" onclick="'.$GLOBALS['TBE_TEMPLATE']->thisBlur().'">'.
887 '<img src="'.$GLOBALS['TBE_STYLES']['logo'].'" '.$imgInfo[3].' title="TYPO3 Content Management Framework" alt="" />'.
895 * adds a javascript snippet to the backend
897 * @param string javascript snippet
900 public function addJavascript($javascript) {
901 // TODO do we need more checks?
902 if(!is_string($javascript)) {
903 throw new InvalidArgumentException('parameter $javascript must be of type string', 1195129553);
906 $this->js
.= $javascript;
910 * adds a javscript file to the backend after it has been checked that it exists
912 * @param string javascript file reference
913 * @return boolean true if the javascript file was successfully added, false otherwise
915 public function addJavascriptFile($javascriptFile) {
916 $jsFileAdded = false;
918 //TODO add more checks if neccessary
919 if(file_exists(t3lib_div
::resolveBackPath(PATH_typo3
.$javascriptFile))) {
920 $this->jsFiles
[] = $javascriptFile;
928 * adds a css snippet to the backend
930 * @param string css snippet
933 public function addCss($css) {
934 if(!is_string($css)) {
935 throw new InvalidArgumentException('parameter $css must be of type string', 1195129642);
942 * adds a css file to the backend after it has been checked that it exists
944 * @param string the css file's name with out the .css ending
945 * @param string css file reference
946 * @return boolean true if the css file was added, false otherwise
948 public function addCssFile($cssFileName, $cssFile) {
949 $cssFileAdded = false;
951 //TODO add more checks if neccessary
952 if(file_exists(t3lib_div
::resolveBackPath(PATH_typo3
.$cssFile))) {
953 // prevent overwriting existing css files
954 if(empty($this->cssFiles
[$cssFileName])) {
955 $this->cssFiles
[$cssFileName] = $cssFile;
956 $cssFileAdded = true;
960 return $cssFileAdded;
964 * adds an item to the toolbar, the class file for the toolbar item must be loaded at this point
966 * @param string toolbar item name, f.e. tx_toolbarExtension_coolItem
967 * @param string toolbar item class name, f.e. tx_toolbarExtension_coolItem
970 public function addToolbarItem($toolbarItemName, $toolbarItemClassName) {
971 $toolbarItem = t3lib_div
::makeInstance($toolbarItemClassName, $this);
973 if(!($toolbarItem instanceof backend_toolbarItem
)) {
974 throw new UnexpectedValueException('$toolbarItem "'.$toolbarItemName.'" must implement interface backend_toolbarItem', 1195125501);
977 if($toolbarItem->checkAccess()) {
978 $this->toolbarItems
[$toolbarItemName] = $toolbarItem;
987 if(defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/backend.php']) {
988 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/backend.php']);
992 // document generation
993 $TYPO3backend = t3lib_div
::makeInstance('TYPO3backend');
995 // include extensions which may add css, javascript or toolbar items
996 if(is_array($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'])) {
997 foreach($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'] as $additionalBackendItem) {
998 include_once($additionalBackendItem);
1002 $TYPO3backend->render();