backend.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2007-2010 Ingo Renner <ingo@typo3.org>
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 
00028 require_once('init.php');
00029 require_once('template.php');
00030 require_once('interfaces/interface.backend_toolbaritem.php');
00031 
00032 require('classes/class.typo3logo.php');
00033 require('classes/class.modulemenu.php');
00034 require_once('classes/class.donatewindow.php');
00035 
00036     // core toolbar items
00037 require('classes/class.workspaceselector.php');
00038 require('classes/class.clearcachemenu.php');
00039 require('classes/class.shortcutmenu.php');
00040 require('classes/class.backendsearchmenu.php');
00041 
00042 require_once('class.alt_menu_functions.inc');
00043 $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_misc.xml');
00044 
00045 
00046 /**
00047  * Class for rendering the TYPO3 backend version 4.2+
00048  *
00049  * @author  Ingo Renner <ingo@typo3.org>
00050  * @package TYPO3
00051  * @subpackage core
00052  */
00053 class TYPO3backend {
00054 
00055     protected $content;
00056     protected $css;
00057     protected $cssFiles;
00058     protected $js;
00059     protected $jsFiles;
00060     protected $jsFilesAfterInline;
00061     protected $toolbarItems;
00062     private   $menuWidthDefault = 190; // intentionally private as nobody should modify defaults
00063     protected $menuWidth;
00064 
00065     /**
00066      * Object for loading backend modules
00067      *
00068      * @var t3lib_loadModules
00069      */
00070     protected $moduleLoader;
00071 
00072     /**
00073      * module menu generating object
00074      *
00075      * @var ModuleMenu
00076      */
00077     protected $moduleMenu;
00078 
00079     /**
00080      * Pagerenderer
00081      *
00082      * @var t3lib_PageRenderer
00083      */
00084     protected $pageRenderer;
00085 
00086     /**
00087      * constructor
00088      *
00089      * @return  void
00090      */
00091     public function __construct() {
00092 
00093             // Initializes the backend modules structure for use later.
00094         $this->moduleLoader = t3lib_div::makeInstance('t3lib_loadModules');
00095         $this->moduleLoader->load($GLOBALS['TBE_MODULES']);
00096 
00097         $this->moduleMenu = t3lib_div::makeInstance('ModuleMenu');
00098 
00099         $this->pageRenderer = $GLOBALS['TBE_TEMPLATE']->getPageRenderer();
00100         $this->pageRenderer->loadScriptaculous('builder,effects,controls,dragdrop');
00101         $this->pageRenderer->loadExtJS();
00102 
00103             // register the extDirect API providers
00104             // Note: we need to iterate thru the object, because the addProvider method
00105             // does this only with multiple arguments
00106         $this->pageRenderer->addExtOnReadyCode(
00107             'for (var api in Ext.app.ExtDirectAPI) {
00108                 Ext.Direct.addProvider(Ext.app.ExtDirectAPI[api]);
00109             }
00110             TYPO3.Backend = new TYPO3.Viewport(TYPO3.Viewport.configuration);
00111             ',
00112             TRUE
00113         );
00114 
00115 
00116             // add default BE javascript
00117         $this->js      = '';
00118         $this->jsFiles = array(
00119             'contrib/swfupload/swfupload.js',
00120             'contrib/swfupload/plugins/swfupload.swfobject.js',
00121             'contrib/swfupload/plugins/swfupload.cookies.js',
00122             'contrib/swfupload/plugins/swfupload.queue.js',
00123             'md5.js',
00124             'js/common.js',
00125             'js/extjs/backendsizemanager.js',
00126             'js/toolbarmanager.js',
00127             'js/modulemenu.js',
00128             'js/iecompatibility.js',
00129             'js/flashupload.js',
00130             '../t3lib/jsfunc.evalfield.js',
00131             '../t3lib/js/extjs/ux/flashmessages.js',
00132             '../t3lib/js/extjs/ux/ext.ux.tabclosemenu.js',
00133             'js/backend.js',
00134             'js/loginrefresh.js',
00135             'js/extjs/debugPanel.js',
00136             'js/extjs/viewport.js',
00137             'js/extjs/viewportConfiguration.js',
00138         );
00139 
00140             // add default BE css
00141         $this->css      = '';
00142         $this->cssFiles = array();
00143 
00144         $this->toolbarItems = array();
00145         $this->initializeCoreToolbarItems();
00146 
00147         $this->menuWidth = $this->menuWidthDefault;
00148         if (isset($GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW']) && (int) $GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW'] != (int) $this->menuWidth) {
00149             $this->menuWidth = (int) $GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW'];
00150         }
00151 
00152         $this->executeHook('constructPostProcess');
00153     }
00154 
00155     /**
00156      * initializes the core toolbar items
00157      *
00158      * @return  void
00159      */
00160     protected function initializeCoreToolbarItems() {
00161 
00162         $coreToolbarItems = array(
00163             'workspaceSelector' => 'WorkspaceSelector',
00164             'shortcuts'         => 'ShortcutMenu',
00165             'clearCacheActions' => 'ClearCacheMenu',
00166             'backendSearch'     => 'BackendSearchMenu'
00167         );
00168 
00169         foreach($coreToolbarItems as $toolbarItemName => $toolbarItemClassName) {
00170             $toolbarItem = t3lib_div::makeInstance($toolbarItemClassName, $this);
00171 
00172             if(!($toolbarItem instanceof backend_toolbarItem)) {
00173                 throw new UnexpectedValueException('$toolbarItem "'.$toolbarItemName.'" must implement interface backend_toolbarItem', 1195126772);
00174             }
00175 
00176             if($toolbarItem->checkAccess()) {
00177                 $this->toolbarItems[$toolbarItemName] = $toolbarItem;
00178             } else {
00179                 unset($toolbarItem);
00180             }
00181         }
00182     }
00183 
00184     /**
00185      * main function generating the BE scaffolding
00186      *
00187      * @return  void
00188      */
00189     public function render()    {
00190         $this->executeHook('renderPreProcess');
00191 
00192         if (t3lib_div::makeInstance('DonateWindow')->isDonateWindowAllowed()) {
00193             $this->pageRenderer->addJsFile('js/donate.js');
00194         }
00195 
00196             // prepare the scaffolding, at this point extension may still add javascript and css
00197         $logo         = t3lib_div::makeInstance('TYPO3Logo');
00198         $logo->setLogo('gfx/typo3logo_mini.png');
00199 
00200         $menu         = $this->moduleMenu->render();
00201 
00202         if ($this->menuWidth != $this->menuWidthDefault) {
00203             $this->css .= '
00204                 #typo3-top {
00205                     margin-left: ' . $this->menuWidth . 'px;
00206                 }
00207             ';
00208         }
00209 
00210             // create backend scaffolding
00211         $backendScaffolding = '
00212     <div id="typo3-backend">
00213         <div id="typo3-top-container" class="x-hide-display">
00214             <div id="typo3-logo">'.$logo->render().'</div>
00215             <div id="typo3-top" class="typo3-top-toolbar">' .
00216                 $this->renderToolbar() .
00217             '</div>
00218         </div>
00219         <div id="typo3-main-container">
00220             <div id="typo3-side-menu" class="x-hide-display">' .
00221                 $menu .
00222             '</div>
00223             <div id="typo3-content" class="x-hide-display">
00224                 <iframe src="alt_intro.php" name="content" id="content" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto"></iframe>
00225             </div>
00226         </div>
00227     </div>
00228 ';
00229 
00230         /******************************************************
00231          * now put the complete backend document together
00232          ******************************************************/
00233 
00234         foreach($this->cssFiles as $cssFileName => $cssFile) {
00235             $this->pageRenderer->addCssFile($cssFile);
00236 
00237                 // load addditional css files to overwrite existing core styles
00238             if(!empty($GLOBALS['TBE_STYLES']['stylesheets'][$cssFileName])) {
00239                 $this->pageRenderer->addCssFile($GLOBALS['TBE_STYLES']['stylesheets'][$cssFileName]);
00240             }
00241         }
00242 
00243         if(!empty($this->css)) {
00244             $this->pageRenderer->addCssInlineBlock('BackendInlineCSS', $this->css);
00245         }
00246 
00247         foreach ($this->jsFiles as $jsFile) {
00248             $this->pageRenderer->addJsFile($jsFile);
00249         }
00250 
00251             // Those lines can be removed once we have at least one official ExtDirect router within the backend.
00252         $hasExtDirectRouter = FALSE;
00253         if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ExtDirect']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ExtDirect'])) {
00254             foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ExtDirect'] as $key => $value) {
00255                 if (strpos($key, 'TYPO3.Ajax.ExtDirect') !== FALSE) {
00256                     $hasExtDirectRouter = TRUE;
00257                     break;
00258                 }
00259             }
00260         }
00261         if ($hasExtDirectRouter) {
00262             $this->pageRenderer->addJsFile('ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.Ajax.ExtDirect', NULL, FALSE);
00263         }
00264 
00265         $this->generateJavascript();
00266         $this->pageRenderer->addJsInlineCode('BackendInlineJavascript', $this->js);
00267 
00268 
00269             // set document title:
00270         $title = ($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']
00271             ? $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'].' [TYPO3 '.TYPO3_version.']'
00272             : 'TYPO3 '.TYPO3_version
00273         );
00274 
00275             // start page header:
00276         $this->content .= $GLOBALS['TBE_TEMPLATE']->startPage($title);
00277         $this->content .= $backendScaffolding;
00278         $this->content .= $GLOBALS['TBE_TEMPLATE']->endPage();
00279 
00280         $hookConfiguration = array('content' => &$this->content);
00281         $this->executeHook('renderPostProcess', $hookConfiguration);
00282 
00283         echo $this->content;
00284     }
00285 
00286     /**
00287      * renders the items in the top toolbar
00288      *
00289      * @return  string  top toolbar elements as HTML
00290      */
00291     protected function renderToolbar() {
00292 
00293             // move search to last position
00294         $search = $this->toolbarItems['backendSearch'];
00295         unset($this->toolbarItems['backendSearch']);
00296         $this->toolbarItems['backendSearch'] = $search;
00297 
00298         $toolbar = '<ul id="typo3-toolbar">';
00299         $toolbar.= '<li>'.$this->getLoggedInUserLabel().'</li>
00300                     <li><div id="logout-button" class="toolbar-item no-separator">'.$this->moduleMenu->renderLogoutButton().'</div></li>';
00301 
00302         foreach($this->toolbarItems as $toolbarItem) {
00303             $menu = $toolbarItem->render();
00304             if ($menu) {
00305                 $additionalAttributes = $toolbarItem->getAdditionalAttributes();
00306                 $toolbar .= '<li' . $additionalAttributes . '>' .$menu. '</li>';
00307             }
00308         }
00309 
00310         return $toolbar.'</ul>';
00311     }
00312 
00313     /**
00314      * Gets the label of the BE user currently logged in
00315      *
00316      * @return  string      html code snippet displaying the currently logged in user
00317      */
00318     protected function getLoggedInUserLabel() {
00319         global $BE_USER, $BACK_PATH;
00320 
00321                 $icon = t3lib_iconWorks::getSpriteIcon('status-user-'. ($BE_USER->isAdmin() ? 'admin' : 'backend'));
00322 
00323         $label = $GLOBALS['BE_USER']->user['realName'] ?
00324             $BE_USER->user['realName'] . ' (' . $BE_USER->user['username'] . ')' :
00325             $BE_USER->user['username'];
00326 
00327             // Link to user setup if it's loaded and user has access
00328         $link = '';
00329         if (t3lib_extMgm::isLoaded('setup') && $BE_USER->check('modules','user_setup')) {
00330             $link = '<a href="#" onclick="top.goToModule(\'user_setup\');this.blur();return false;">';
00331         }
00332 
00333         $username = '">'.$link.$icon.'<span>'.htmlspecialchars($label).'</span>'.($link?'</a>':'');
00334 
00335             // superuser mode
00336         if($BE_USER->user['ses_backuserid']) {
00337             $username   = ' su-user">'.$icon.
00338             '<span title="' . $GLOBALS['LANG']->getLL('switchtouser') . '">' .
00339             $GLOBALS['LANG']->getLL('switchtousershort') . ' </span>' .
00340             '<span>' . htmlspecialchars($label) . '</span>';
00341         }
00342 
00343         return '<div id="username" class="toolbar-item no-separator'.$username.'</div>';
00344     }
00345 
00346     /**
00347      * Generates the JavaScript code for the backend.
00348      *
00349      * @return  void
00350      */
00351     protected function generateJavascript() {
00352 
00353         $pathTYPO3          = t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')).'/';
00354         $goToModuleSwitch   = $this->moduleMenu->getGotoModuleJavascript();
00355         $moduleFramesHelper = implode(LF, $this->moduleMenu->getFsMod());
00356 
00357             // If another page module was specified, replace the default Page module with the new one
00358         $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
00359         $pageModule    = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
00360 
00361         $menuFrameName = 'menu';
00362         if($GLOBALS['BE_USER']->uc['noMenuMode'] === 'icons') {
00363             $menuFrameName = 'topmenuFrame';
00364         }
00365 
00366         // determine security level from conf vars and default to super challenged
00367         if ($GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel']) {
00368             $this->loginSecurityLevel = $GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel'];
00369         } else {
00370             $this->loginSecurityLevel = 'superchallenged';
00371         }
00372 
00373         $t3Configuration = array(
00374             'siteUrl' => t3lib_div::getIndpEnv('TYPO3_SITE_URL'),
00375             'PATH_typo3' => $pathTYPO3,
00376             'PATH_typo3_enc' => rawurlencode($pathTYPO3),
00377             'username' => htmlspecialchars($GLOBALS['BE_USER']->user['username']),
00378             'uniqueID' => t3lib_div::shortMD5(uniqid('')),
00379             'securityLevel' => $this->loginSecurityLevel,
00380             'TYPO3_mainDir' => TYPO3_mainDir,
00381             'pageModule' => $pageModule,
00382             'condensedMode' => $GLOBALS['BE_USER']->uc['condensedMode'] ? 1 : 0 ,
00383             'inWorkspace' => $GLOBALS['BE_USER']->workspace !== 0 ? 1 : 0,
00384             'workspaceFrontendPreviewEnabled' => $GLOBALS['BE_USER']->user['workspace_preview'] ? 1 : 0,
00385             'veriCode' => $GLOBALS['BE_USER']->veriCode(),
00386             'denyFileTypes' => PHP_EXTENSIONS_DEFAULT,
00387             'moduleMenuWidth' => $this->menuWidth - 1,
00388             'topBarHeight' => (isset($GLOBALS['TBE_STYLES']['dims']['topFrameH']) ? intval($GLOBALS['TBE_STYLES']['dims']['topFrameH']) : 30),
00389             'showRefreshLoginPopup' => isset($GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup']) ? intval($GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup']) : FALSE,
00390             'listModulePath' => t3lib_extMgm::isLoaded('list') ? t3lib_extMgm::extRelPath('list') . 'mod1/' : '',
00391         );
00392         $t3LLLcore = array(
00393             'waitTitle' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_logging_in') ,
00394             'refresh_login_failed' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_failed'),
00395             'refresh_login_failed_message' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_failed_message'),
00396             'refresh_login_title' => sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_title'), htmlspecialchars($GLOBALS['BE_USER']->user['username'])),
00397             'login_expired' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.login_expired'),
00398             'refresh_login_username' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_username'),
00399             'refresh_login_password' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_password'),
00400             'refresh_login_emptyPassword' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_emptyPassword'),
00401             'refresh_login_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_button'),
00402             'refresh_logout_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_logout_button'),
00403             'please_wait' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.please_wait'),
00404             'be_locked' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.be_locked'),
00405             'refresh_login_countdown_singular' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_countdown_singular'),
00406             'refresh_login_countdown' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_countdown'),
00407             'login_about_to_expire' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.login_about_to_expire'),
00408             'login_about_to_expire_title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.login_about_to_expire_title'),
00409             'refresh_login_refresh_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_refresh_button'),
00410             'refresh_direct_logout_button' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_direct_logout_button'),
00411             'tabs_closeAll' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:tabs.closeAll'),
00412             'tabs_closeOther' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:tabs.closeOther'),
00413             'tabs_close' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:tabs.close'),
00414             'donateWindow_title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.title'),
00415             'donateWindow_message' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.message'),
00416             'donateWindow_button_donate' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.button_donate'),
00417             'donateWindow_button_disable' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.button_disable'),
00418             'donateWindow_button_postpone' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:donateWindow.button_postpone'),
00419         );
00420         $t3LLLfileUpload = array(
00421             'windowTitle' => $GLOBALS['LANG']->getLL('fileUpload_windowTitle'),
00422             'buttonSelectFiles' => $GLOBALS['LANG']->getLL('fileUpload_buttonSelectFiles'),
00423             'buttonCancelAll' => $GLOBALS['LANG']->getLL('fileUpload_buttonCancelAll'),
00424             'infoComponentMaxFileSize' => $GLOBALS['LANG']->getLL('fileUpload_infoComponentMaxFileSize'),
00425             'infoComponentFileUploadLimit' => $GLOBALS['LANG']->getLL('fileUpload_infoComponentFileUploadLimit'),
00426             'infoComponentFileTypeLimit' => $GLOBALS['LANG']->getLL('fileUpload_infoComponentFileTypeLimit'),
00427             'infoComponentOverrideFiles' => $GLOBALS['LANG']->getLL('fileUpload_infoComponentOverrideFiles'),
00428             'processRunning' => $GLOBALS['LANG']->getLL('fileUpload_processRunning'),
00429             'uploadWait' => $GLOBALS['LANG']->getLL('fileUpload_uploadWait'),
00430             'uploadStarting' => $GLOBALS['LANG']->getLL('fileUpload_uploadStarting'),
00431             'uploadProgress' => $GLOBALS['LANG']->getLL('fileUpload_uploadProgress'),
00432             'uploadSuccess' => $GLOBALS['LANG']->getLL('fileUpload_uploadSuccess'),
00433             'errorQueueLimitExceeded' => $GLOBALS['LANG']->getLL('fileUpload_errorQueueLimitExceeded'),
00434             'errorQueueFileSizeLimit' => $GLOBALS['LANG']->getLL('fileUpload_errorQueueFileSizeLimit'),
00435             'errorQueueZeroByteFile' =>  $GLOBALS['LANG']->getLL('fileUpload_errorQueueZeroByteFile'),
00436             'errorQueueInvalidFiletype' => $GLOBALS['LANG']->getLL('fileUpload_errorQueueInvalidFiletype'),
00437             'errorUploadHttp' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadHttpError'),
00438             'errorUploadMissingUrl' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadMissingUrl'),
00439             'errorUploadIO' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadIO'),
00440             'errorUploadSecurityError' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadSecurityError'),
00441             'errorUploadLimit' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadLimit'),
00442             'errorUploadFailed' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadFailed'),
00443             'errorUploadFileIDNotFound' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadFileIDNotFound'),
00444             'errorUploadFileValidation' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadFileValidation'),
00445             'errorUploadFileCancelled' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadFileCancelled'),
00446             'errorUploadStopped' => $GLOBALS['LANG']->getLL('fileUpload_errorUploadStopped'),
00447             'allErrorMessageTitle' => $GLOBALS['LANG']->getLL('fileUpload_allErrorMessageTitle'),
00448             'allErrorMessageText' => $GLOBALS['LANG']->getLL('fileUpload_allErrorMessageText'),
00449             'allError401' => $GLOBALS['LANG']->getLL('fileUpload_allError401'),
00450             'allError2038' => $GLOBALS['LANG']->getLL('fileUpload_allError2038'),
00451         );
00452 
00453             // Convert labels/settings back to UTF-8 since json_encode() only works with UTF-8:
00454         if ($GLOBALS['LANG']->charSet !== 'utf-8') {
00455             $t3Configuration['username'] = $GLOBALS['LANG']->csConvObj->conv($t3Configuration['username'], $GLOBALS['LANG']->charSet, 'utf-8');
00456             $GLOBALS['LANG']->csConvObj->convArray($t3LLLcore, $GLOBALS['LANG']->charSet, 'utf-8');
00457             $GLOBALS['LANG']->csConvObj->convArray($t3LLLfileUpload, $GLOBALS['LANG']->charSet, 'utf-8');
00458         }
00459 
00460         $this->js .= '
00461     TYPO3.configuration = ' . json_encode($t3Configuration) . ';
00462     TYPO3.LLL = {
00463         core : ' . json_encode($t3LLLcore) . ',
00464         fileUpload: ' . json_encode($t3LLLfileUpload) . '
00465     };
00466 
00467     /**
00468      * TypoSetup object.
00469      */
00470     function typoSetup()    {   //
00471         this.PATH_typo3 = TYPO3.configuration.PATH_typo3;
00472         this.PATH_typo3_enc = TYPO3.configuration.PATH_typo3_enc;
00473         this.username = TYPO3.configuration.username;
00474         this.uniqueID = TYPO3.configuration.uniqueID;
00475         this.navFrameWidth = 0;
00476         this.securityLevel = TYPO3.configuration.securityLevel;
00477         this.veriCode = TYPO3.configuration.veriCode;
00478         this.denyFileTypes = TYPO3.configuration.denyFileTypes;
00479     }
00480     var TS = new typoSetup();
00481 
00482     var currentModuleLoaded = "";
00483 
00484     /**
00485      * Frameset Module object
00486      *
00487      * Used in main modules with a frameset for submodules to keep the ID between modules
00488      * Typically that is set by something like this in a Web>* sub module:
00489      *      if (top.fsMod) top.fsMod.recentIds["web"] = "\'.intval($this->id).\'";
00490      *      if (top.fsMod) top.fsMod.recentIds["file"] = "...(file reference/string)...";
00491      */
00492     function fsModules()    {   //
00493         this.recentIds=new Array();                 // used by frameset modules to track the most recent used id for list frame.
00494         this.navFrameHighlightedID=new Array();     // used by navigation frames to track which row id was highlighted last time
00495         this.currentMainLoaded="";
00496         this.currentBank="0";
00497     }
00498     var fsMod = new fsModules();' . $moduleFramesHelper . ';';
00499 
00500             // add goToModule code
00501         $this->pageRenderer->addExtOnReadyCode('
00502             top.goToModule = ' . $goToModuleSwitch . ';
00503         ');
00504 
00505             // Check editing of page:
00506         $this->handlePageEditing();
00507         $this->setStartupModule();
00508     }
00509 
00510     /**
00511      * Checking if the "&edit" variable was sent so we can open it for editing the page.
00512      * Code based on code from "alt_shortcut.php"
00513      *
00514      * @return  void
00515      */
00516     protected function handlePageEditing()  {
00517 
00518         if(!t3lib_extMgm::isLoaded('cms'))  {
00519             return;
00520         }
00521 
00522             // EDIT page:
00523         $editId     = preg_replace('/[^[:alnum:]_]/', '', t3lib_div::_GET('edit'));
00524         $editRecord = '';
00525 
00526         if($editId) {
00527 
00528                 // Looking up the page to edit, checking permissions:
00529             $where = ' AND ('.$GLOBALS['BE_USER']->getPagePermsClause(2)
00530                     .' OR '.$GLOBALS['BE_USER']->getPagePermsClause(16).')';
00531 
00532             if(t3lib_div::testInt($editId)) {
00533                 $editRecord = t3lib_BEfunc::getRecordWSOL('pages', $editId, '*', $where);
00534             } else {
00535                 $records = t3lib_BEfunc::getRecordsByField('pages', 'alias', $editId, $where);
00536 
00537                 if(is_array($records))  {
00538                     reset($records);
00539                     $editRecord = current($records);
00540                     t3lib_BEfunc::workspaceOL('pages', $editRecord);
00541                 }
00542             }
00543 
00544                 // If the page was accessible, then let the user edit it.
00545             if(is_array($editRecord) && $GLOBALS['BE_USER']->isInWebMount($editRecord['uid']))  {
00546                     // Setting JS code to open editing:
00547                 $this->js .= '
00548         // Load page to edit:
00549     window.setTimeout("top.loadEditId('.intval($editRecord['uid']).');", 500);
00550             ';
00551                     // Checking page edit parameter:
00552                 if(!$GLOBALS['BE_USER']->getTSConfigVal('options.shortcut_onEditId_dontSetPageTree')) {
00553 
00554                         // Expanding page tree:
00555                     t3lib_BEfunc::openPageTree(intval($editRecord['pid']), !$GLOBALS['BE_USER']->getTSConfigVal('options.shortcut_onEditId_keepExistingExpanded'));
00556                 }
00557             } else {
00558                 $this->js .= '
00559         // Warning about page editing:
00560     alert('.$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('noEditPage'), $editId)).');
00561             ';
00562             }
00563         }
00564     }
00565 
00566     /**
00567      * Sets the startup module from either GETvars module and mpdParams or user configuration.
00568      *
00569      * @return  void
00570      */
00571     protected function setStartupModule() {
00572         $startModule = preg_replace('/[^[:alnum:]_]/', '', t3lib_div::_GET('module'));
00573 
00574         if(!$startModule)   {
00575             if ($GLOBALS['BE_USER']->uc['startModule']) {
00576                 $startModule = $GLOBALS['BE_USER']->uc['startModule'];
00577             } else if($GLOBALS['BE_USER']->uc['startInTaskCenter']) {
00578                 $startModule = 'user_task';
00579             }
00580         }
00581 
00582         $moduleParameters = t3lib_div::_GET('modParams');
00583         if($startModule) {
00584             $this->pageRenderer->addExtOnReadyCode('
00585             // start in module:
00586         function startInModule(modName, cMR_flag, addGetVars)   {
00587             Ext.onReady(function() {
00588                 top.goToModule(modName, cMR_flag, addGetVars);
00589             });
00590         }
00591 
00592         startInModule(\''.$startModule.'\', false, '.t3lib_div::quoteJSvalue($moduleParameters).');
00593             ');
00594         }
00595     }
00596 
00597     /**
00598      * generates the code for the TYPO3 logo, either the default TYPO3 logo or a custom one
00599      *
00600      * @return  string  HTML code snippet to display the TYPO3 logo
00601      */
00602     protected function getLogo() {
00603         $logo = '<a href="http://www.typo3.com/" target="_blank" onclick="'.$GLOBALS['TBE_TEMPLATE']->thisBlur().'">'.
00604                 '<img'.t3lib_iconWorks::skinImg('','gfx/alt_backend_logo.gif','width="117" height="32"').' title="TYPO3 Content Management Framework" alt="" />'.
00605                 '</a>';
00606 
00607             // overwrite with custom logo
00608         if($GLOBALS['TBE_STYLES']['logo'])  {
00609             if(substr($GLOBALS['TBE_STYLES']['logo'], 0, 3) == '../')   {
00610                 $imgInfo = @getimagesize(PATH_site.substr($GLOBALS['TBE_STYLES']['logo'], 3));
00611             }
00612             $logo = '<a href="http://www.typo3.com/" target="_blank" onclick="'.$GLOBALS['TBE_TEMPLATE']->thisBlur().'">'.
00613                 '<img src="'.$GLOBALS['TBE_STYLES']['logo'].'" '.$imgInfo[3].' title="TYPO3 Content Management Framework" alt="" />'.
00614                 '</a>';
00615         }
00616 
00617         return $logo;
00618     }
00619 
00620     /**
00621      * adds a javascript snippet to the backend
00622      *
00623      * @param   string  javascript snippet
00624      * @return  void
00625      */
00626     public function addJavascript($javascript) {
00627             // TODO do we need more checks?
00628         if(!is_string($javascript)) {
00629             throw new InvalidArgumentException('parameter $javascript must be of type string', 1195129553);
00630         }
00631 
00632         $this->js .= $javascript;
00633     }
00634 
00635     /**
00636      * adds a javscript file to the backend after it has been checked that it exists
00637      *
00638      * @param   string  javascript file reference
00639      * @return  boolean true if the javascript file was successfully added, false otherwise
00640      */
00641     public function addJavascriptFile($javascriptFile) {
00642         $jsFileAdded = false;
00643 
00644             //TODO add more checks if neccessary
00645         if(file_exists(t3lib_div::resolveBackPath(PATH_typo3.$javascriptFile))) {
00646             $this->jsFiles[] = $javascriptFile;
00647             $jsFileAdded     = true;
00648         }
00649 
00650         return $jsFileAdded;
00651     }
00652 
00653     /**
00654      * adds a css snippet to the backend
00655      *
00656      * @param   string  css snippet
00657      * @return  void
00658      */
00659     public function addCss($css) {
00660         if(!is_string($css)) {
00661             throw new InvalidArgumentException('parameter $css must be of type string', 1195129642);
00662         }
00663 
00664         $this->css .= $css;
00665     }
00666 
00667     /**
00668      * adds a css file to the backend after it has been checked that it exists
00669      *
00670      * @param   string  the css file's name with out the .css ending
00671      * @param   string  css file reference
00672      * @return  boolean true if the css file was added, false otherwise
00673      */
00674     public function addCssFile($cssFileName, $cssFile) {
00675         $cssFileAdded = false;
00676 
00677         if(empty($this->cssFiles[$cssFileName])) {
00678             $this->cssFiles[$cssFileName] = $cssFile;
00679             $cssFileAdded = true;
00680         }
00681 
00682         return $cssFileAdded;
00683     }
00684 
00685     /**
00686      * adds an item to the toolbar, the class file for the toolbar item must be loaded at this point
00687      *
00688      * @param   string  toolbar item name, f.e. tx_toolbarExtension_coolItem
00689      * @param   string  toolbar item class name, f.e. tx_toolbarExtension_coolItem
00690      * @return  void
00691      */
00692     public function addToolbarItem($toolbarItemName, $toolbarItemClassName) {
00693         $toolbarItem = t3lib_div::makeInstance($toolbarItemClassName, $this);
00694 
00695         if(!($toolbarItem instanceof backend_toolbarItem)) {
00696             throw new UnexpectedValueException('$toolbarItem "'.$toolbarItemName.'" must implement interface backend_toolbarItem', 1195125501);
00697         }
00698 
00699         if($toolbarItem->checkAccess()) {
00700             $this->toolbarItems[$toolbarItemName] = $toolbarItem;
00701         } else {
00702             unset($toolbarItem);
00703         }
00704     }
00705 
00706     /**
00707      * Executes defined hooks functions for the given identifier.
00708      *
00709      * These hook identifiers are valid:
00710      *  + constructPostProcess
00711      *  + renderPreProcess
00712      *  + renderPostProcess
00713      *
00714      * @param string $identifier Specific hook identifier
00715      * @param array $hookConfiguration Additional configuration passed to hook functions
00716      * @return void
00717      */
00718     protected function executeHook($identifier, array $hookConfiguration = array()) {
00719         $options =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/backend.php'];
00720 
00721         if(isset($options[$identifier]) && is_array($options[$identifier])) {
00722             foreach($options[$identifier] as $hookFunction) {
00723                 t3lib_div::callUserFunction($hookFunction, $hookConfiguration, $this);
00724             }
00725         }
00726     }
00727 }
00728 
00729 
00730     // include XCLASS
00731 if(defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/backend.php']) {
00732     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/backend.php']);
00733 }
00734 
00735 
00736     // document generation
00737 $TYPO3backend = t3lib_div::makeInstance('TYPO3backend');
00738 
00739     // include extensions which may add css, javascript or toolbar items
00740 if(is_array($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'])) {
00741     foreach($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'] as $additionalBackendItem) {
00742         include_once($additionalBackendItem);
00743     }
00744 }
00745 
00746 $TYPO3backend->render();
00747 
00748 ?>

Generated on Sat Jul 24 04:17:28 2010 for TYPO3 API by  doxygen 1.4.7