Follow-up to #11044: Changing to a backend module was not possible anymore in Interne...
[Packages/TYPO3.CMS.git] / typo3 / backend.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2007-2009 Ingo Renner <ingo@typo3.org>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28 require_once('init.php');
29 require_once('template.php');
30 require_once('interfaces/interface.backend_toolbaritem.php');
31
32 require('classes/class.typo3logo.php');
33 require('classes/class.modulemenu.php');
34
35 // core toolbar items
36 require('classes/class.workspaceselector.php');
37 require('classes/class.clearcachemenu.php');
38 require('classes/class.shortcutmenu.php');
39 require('classes/class.backendsearchmenu.php');
40
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');
45
46
47 /**
48 * Class for rendering the TYPO3 backend version 4.2+
49 *
50 * @author Ingo Renner <ingo@typo3.org>
51 * @package TYPO3
52 * @subpackage core
53 */
54 class TYPO3backend {
55
56 protected $content;
57 protected $css;
58 protected $cssFiles;
59 protected $js;
60 protected $jsFiles;
61 protected $jsFilesAfterInline;
62 protected $toolbarItems;
63 private $menuWidthDefault = 160; // intentionally private as nobody should modify defaults
64 protected $menuWidth;
65
66 /**
67 * Object for loading backend modules
68 *
69 * @var t3lib_loadModules
70 */
71 protected $moduleLoader;
72
73 /**
74 * module menu generating object
75 *
76 * @var ModuleMenu
77 */
78 protected $moduleMenu;
79
80 /**
81 * constructor
82 *
83 * @return void
84 */
85 public function __construct() {
86
87 // Initializes the backend modules structure for use later.
88 $this->moduleLoader = t3lib_div::makeInstance('t3lib_loadModules');
89 $this->moduleLoader->load($GLOBALS['TBE_MODULES']);
90
91 $this->moduleMenu = t3lib_div::makeInstance('ModuleMenu');
92
93 // add default BE javascript
94 $this->js = '';
95 $this->jsFiles = array(
96 'contrib/prototype/prototype.js',
97 'contrib/scriptaculous/scriptaculous.js?load=builder,effects,controls,dragdrop',
98 'contrib/extjs/adapter/ext/ext-base.js',
99 'contrib/extjs/ext-all.js',
100 'contrib/swfupload/swfupload.js',
101 'contrib/swfupload/plugins/swfupload.swfobject.js',
102 'contrib/swfupload/plugins/swfupload.cookies.js',
103 'contrib/swfupload/plugins/swfupload.queue.js',
104 'md5.js',
105 'js/common.js',
106 'js/sizemanager.js',
107 'js/toolbarmanager.js',
108 'js/modulemenu.js',
109 'js/iecompatibility.js',
110 'js/flashupload.js',
111 '../t3lib/jsfunc.evalfield.js'
112 );
113 $this->jsFilesAfterInline = array(
114 'js/backend.js',
115 'js/loginrefresh.js',
116 );
117 // add default BE css
118 $this->css = '';
119 $this->cssFiles = array(
120 'backend-scaffolding' => 'css/backend-scaffolding.css',
121 'backend-style' => 'css/backend-style.css',
122 'modulemenu' => 'css/modulemenu.css',
123 'extJS' => 'contrib/extjs/resources/css/ext-all.css',
124 'extJS-gray' => 'contrib/extjs/resources/css/xtheme-gray.css'
125 );
126
127 $this->toolbarItems = array();
128 $this->initializeCoreToolbarItems();
129
130 $this->menuWidth = $this->menuWidthDefault;
131 if (isset($GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW']) && (int) $GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW'] != (int) $this->menuWidth) {
132 $this->menuWidth = (int) $GLOBALS['TBE_STYLES']['dims']['leftMenuFrameW'];
133 }
134 }
135
136 /**
137 * initializes the core toolbar items
138 *
139 * @return void
140 */
141 protected function initializeCoreToolbarItems() {
142
143 $coreToolbarItems = array(
144 'workspaceSelector' => 'WorkspaceSelector',
145 'shortcuts' => 'ShortcutMenu',
146 'clearCacheActions' => 'ClearCacheMenu',
147 'backendSearch' => 'BackendSearchMenu'
148 );
149
150 foreach($coreToolbarItems as $toolbarItemName => $toolbarItemClassName) {
151 $toolbarItem = t3lib_div::makeInstance($toolbarItemClassName, $this);
152
153 if(!($toolbarItem instanceof backend_toolbarItem)) {
154 throw new UnexpectedValueException('$toolbarItem "'.$toolbarItemName.'" must implement interface backend_toolbarItem', 1195126772);
155 }
156
157 if($toolbarItem->checkAccess()) {
158 $this->toolbarItems[$toolbarItemName] = $toolbarItem;
159 } else {
160 unset($toolbarItem);
161 }
162 }
163 }
164
165 /**
166 * main function generating the BE scaffolding
167 *
168 * @return void
169 */
170 public function render() {
171
172 // prepare the scaffolding, at this point extension may still add javascript and css
173 $logo = t3lib_div::makeInstance('TYPO3Logo');
174 $logo->setLogo('gfx/typo3logo_mini.png');
175
176 $menu = $this->moduleMenu->render();
177
178 if ($this->menuWidth != $this->menuWidthDefault) {
179 $this->css .= '
180 #typo3-logo,
181 #typo3-side-menu {
182 width: ' . ($this->menuWidth - 1) . 'px;
183 }
184
185 #typo3-top,
186 #typo3-content {
187 margin-left: ' . $this->menuWidth . 'px;
188 }
189 ';
190 }
191
192 // create backend scaffolding
193 $backendScaffolding = '
194 <div id="typo3-backend">
195 <div id="typo3-top-container">
196 <div id="typo3-logo">'.$logo->render().'</div>
197 <div id="typo3-top" class="typo3-top-toolbar">'
198 .$this->renderToolbar()
199 .'</div>
200 </div>
201 <div id="typo3-main-container">
202 <div id="typo3-side-menu">
203 '.$menu.'
204 </div>
205 <div id="typo3-content">
206 <iframe src="alt_intro.php" name="content" id="content" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto"></iframe>
207 </div>
208 </div>
209 </div>
210 ';
211
212 /******************************************************
213 * now put the complete backend document together
214 ******************************************************/
215
216 // remove duplicate entries
217 $this->jsFiles = array_unique($this->jsFiles);
218
219 // add javascript
220 foreach($this->jsFiles as $jsFile) {
221 $GLOBALS['TBE_TEMPLATE']->JScode .= '
222 <script type="text/javascript" src="' . $jsFile . '"></script>';
223 }
224 $GLOBALS['TBE_TEMPLATE']->JScode .= chr(10);
225 $this->generateJavascript();
226 $GLOBALS['TBE_TEMPLATE']->JScode .= $GLOBALS['TBE_TEMPLATE']->wrapScriptTags($this->js) . chr(10);
227
228 foreach($this->jsFilesAfterInline as $jsFile) {
229 $GLOBALS['TBE_TEMPLATE']->JScode .= '
230 <script type="text/javascript" src="' . $jsFile . '"></script>';
231 }
232
233
234 // FIXME abusing the JS container to add CSS, need to fix template.php
235 foreach($this->cssFiles as $cssFileName => $cssFile) {
236 $GLOBALS['TBE_TEMPLATE']->JScode .= '
237 <link rel="stylesheet" type="text/css" href="'.$cssFile.'" />
238 ';
239
240 // load addditional css files to overwrite existing core styles
241 if(!empty($GLOBALS['TBE_STYLES']['stylesheets'][$cssFileName])) {
242 $GLOBALS['TBE_TEMPLATE']->JScode .= '
243 <link rel="stylesheet" type="text/css" href="'.$GLOBALS['TBE_STYLES']['stylesheets'][$cssFileName].'" />
244 ';
245 }
246 }
247
248 if(!empty($this->css)) {
249 $GLOBALS['TBE_TEMPLATE']->JScode .= '
250 <style type="text/css" id="internalStyle">
251 '.$this->css.'
252 </style>';
253 }
254
255 // set document title:
256 $title = ($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']
257 ? $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'].' [TYPO3 '.TYPO3_version.']'
258 : 'TYPO3 '.TYPO3_version
259 );
260
261 // start page header:
262 $this->content .= $GLOBALS['TBE_TEMPLATE']->startPage($title);
263 $this->content .= $backendScaffolding;
264 $this->content .= $GLOBALS['TBE_TEMPLATE']->endPage();
265
266 echo $this->content;
267 }
268
269 /**
270 * renders the items in the top toolbar
271 *
272 * @return string top toolbar elements as HTML
273 */
274 protected function renderToolbar() {
275
276 // move search to last position
277 $search = $this->toolbarItems['backendSearch'];
278 unset($this->toolbarItems['backendSearch']);
279 $this->toolbarItems['backendSearch'] = $search;
280
281 $toolbar = '<ul id="typo3-toolbar">';
282 $toolbar.= '<li>'.$this->getLoggedInUserLabel().'</li>
283 <li><div id="logout-button" class="toolbar-item no-separator">'.$this->moduleMenu->renderLogoutButton().'</div></li>';
284
285 foreach($this->toolbarItems as $toolbarItem) {
286 $menu = $toolbarItem->render();
287 if ($menu) {
288 $additionalAttributes = $toolbarItem->getAdditionalAttributes();
289 $toolbar .= '<li' . $additionalAttributes . '>' .$menu. '</li>';
290 }
291 }
292
293 return $toolbar.'</ul>';
294 }
295
296 /**
297 * gets the label of the currently loged in BE user
298 *
299 * @return string html code snippet displaying the currently logged in user
300 */
301 protected function getLoggedInUserLabel() {
302 global $BE_USER, $BACK_PATH;
303
304 $icon = '<img'.t3lib_iconWorks::skinImg(
305 '',
306 $BE_USER->isAdmin() ?
307 'gfx/i/be_users_admin.gif' :
308 'gfx/i/be_users.gif',
309 'width="18" height="16"'
310 )
311 .' title="" alt="" />';
312
313 $label = $GLOBALS['BE_USER']->user['realName'] ?
314 $BE_USER->user['realName'].' ['.$BE_USER->user['username'].']' :
315 $BE_USER->user['username'];
316
317 // Link to user setup if it's loaded and user has access
318 $link = '';
319 if (t3lib_extMgm::isLoaded('setup') && $BE_USER->check('modules','user_setup')) {
320 $link = '<a href="#" onclick="top.goToModule(\'user_setup\');this.blur();return false;">';
321 }
322
323 $username = '">'.$link.$icon.'<span>'.htmlspecialchars($label).'</span>'.($link?'</a>':'');
324
325 // superuser mode
326 if($BE_USER->user['ses_backuserid']) {
327 $username = ' su-user">'.$icon.
328 '<span title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:switchtouser').'">SU: </span>'.
329 '<span>'.htmlspecialchars($label).'</span>';
330 }
331
332 return '<div id="username" class="toolbar-item no-separator'.$username.'</div>';
333 }
334
335 /**
336 * Generates the JavaScript code for the backend.
337 *
338 * @return void
339 */
340 protected function generateJavascript() {
341
342 $pathTYPO3 = t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')).'/';
343 $goToModuleSwitch = $this->moduleMenu->getGotoModuleJavascript();
344 $moduleFramesHelper = implode(chr(10), $this->moduleMenu->getFsMod());
345
346 // If another page module was specified, replace the default Page module with the new one
347 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
348 $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
349
350 $menuFrameName = 'menu';
351 if($GLOBALS['BE_USER']->uc['noMenuMode'] === 'icons') {
352 $menuFrameName = 'topmenuFrame';
353 }
354
355 // create challenge for the (re)login form and save it in the session.
356 $challenge = md5(uniqid('').getmypid());
357 session_start();
358 $_SESSION['login_challenge'] = $challenge;
359
360 // determine security level from conf vars and default to super challenged
361 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel']) {
362 $this->loginSecurityLevel = $GLOBALS['TYPO3_CONF_VARS']['BE']['loginSecurityLevel'];
363 } else {
364 $this->loginSecurityLevel = 'superchallenged';
365 }
366
367 $this->js .= '
368 Ext.BLANK_IMAGE_URL = "' .
369 // t3lib_div::locationHeaderUrl() will include '/typo3/' in the URL
370 htmlspecialchars(t3lib_div::locationHeaderUrl('gfx/clear.gif')) .
371 '";
372
373
374 TYPO3.configuration = ' . json_encode(array(
375 'siteUrl' => t3lib_div::getIndpEnv('TYPO3_SITE_URL'),
376 'PATH_typo3' => $pathTYPO3,
377 'PATH_typo3_enc' => rawurlencode($pathTYPO3),
378 'username' => htmlspecialchars($GLOBALS['BE_USER']->user['username']),
379 'uniqueID' => t3lib_div::shortMD5(uniqid('')),
380 'securityLevel' => $this->loginSecurityLevel,
381 'challenge' => $challenge,
382 'TYPO3_mainDir' => TYPO3_mainDir,
383 'pageModule' => $pageModule,
384 'condensedMode' => $GLOBALS['BE_USER']->uc['condensedMode'] ? 1 : 0 ,
385 'workspaceFrontendPreviewEnabled' => (($GLOBALS['BE_USER']->workspace != 0 && !$GLOBALS['BE_USER']->user['workspace_preview']) ? 'false' : 'true'),
386 'veriCode' => $GLOBALS['BE_USER']->veriCode(),
387 'denyFileTypes' => PHP_EXTENSIONS_DEFAULT,
388 )) . ';
389 TYPO3.LLL = {
390 core : ' . json_encode(array(
391 'waitTitle' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_logging_in') ,
392 'refresh_login_failed' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_failed'),
393 'refresh_login_failed_message' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_failed_message'),
394 'refresh_login_title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_title'),
395 'login_expired' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.login_expired'),
396 'refresh_login_username' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_username'),
397 'refresh_login_password' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_password'),
398 'refresh_login_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 )) . ',
409 fileUpload: ' . json_encode(array(
410 'windowTitle' => "File Upload Progress",
411 'buttonSelectFiles' => "Select Files",
412 'buttonCancelAll' => "Cancel All Uploads",
413 'infoComponentMaxFileSize' => "You can upload files with a maximum size of {0}.",
414 'infoComponentFileUploadLimit' => "You can upload a total of {0}.",
415 'infoComponentFileTypeLimit' => "You can upload the following file types {0}.",
416 'infoComponentOverrideFiles' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.xml:overwriteExistingFiles', 1),
417 'processRunning' => "Another process is already uploading",
418 'uploadWait' => "Waiting to start upload of {0}",
419 'uploadStarting' => "Starting upload of {0}",
420 'uploadProgress' => "{0}% of {1} uploaded",
421 'uploadSuccess' => "{0} was successfully uploaded!",
422 'errorQueueLimitExceeded' => "Too many files selected",
423 'errorQueueFileSizeLimit' => "{0} is too big",
424 'errorQueueZeroByteFile' => "{0} is empty",
425 'errorQueueInvalidFiletype' => "Filetype not allowed for {0}",
426 'errorUploadHttp' => "Too many files selected",
427 'errorUploadMissingUrl' => "Internal error: No Upload URL set",
428 'errorUploadIO' => "Internal error: Problems while reading/writing the file",
429 'errorUploadSecurityError' => "Internal error: {0}",
430 'errorUploadLimit' => "Upload limit exceeded",
431 'errorUploadFailed' => "Upload failed",
432 'errorUploadFileIDNotFound' => "Internal error: File ID not found",
433 'errorUploadFileValidation' => "Internal error while validating the file",
434 'errorUploadFileCancelled' => "Upload of {0} canceled",
435 'errorUploadStopped' => "Upload of {0} stopped",
436 )) . '};
437
438 /**
439 * TypoSetup object.
440 */
441 function typoSetup() { //
442 this.PATH_typo3 = TYPO3.configuration.PATH_typo3;
443 this.PATH_typo3_enc = TYPO3.configuration.PATH_typo3_enc;
444 this.username = TYPO3.configuration.username;
445 this.uniqueID = TYPO3.configuration.uniqueID;
446 this.navFrameWidth = 0;
447 this.securityLevel = TYPO3.configuration.securityLevel;
448 this.veriCode = TYPO3.configuration.veriCode;
449 this.denyFileTypes = TYPO3.configuration.denyFileTypes;
450 }
451 var TS = new typoSetup();
452
453 var currentModuleLoaded = "";
454 var goToModule = ' . $goToModuleSwitch . ';
455
456 /**
457 * Frameset Module object
458 *
459 * Used in main modules with a frameset for submodules to keep the ID between modules
460 * Typically that is set by something like this in a Web>* sub module:
461 * if (top.fsMod) top.fsMod.recentIds["web"] = "\'.intval($this->id).\'";
462 * if (top.fsMod) top.fsMod.recentIds["file"] = "...(file reference/string)...";
463 */
464 function fsModules() { //
465 this.recentIds=new Array(); // used by frameset modules to track the most recent used id for list frame.
466 this.navFrameHighlightedID=new Array(); // used by navigation frames to track which row id was highlighted last time
467 this.currentMainLoaded="";
468 this.currentBank="0";
469 }
470 var fsMod = new fsModules();' . $moduleFramesHelper . ';';
471
472
473
474 // Check editing of page:
475 $this->handlePageEditing();
476 $this->setStartupModule();
477 }
478
479 /**
480 * Checking if the "&edit" variable was sent so we can open it for editing the page.
481 * Code based on code from "alt_shortcut.php"
482 *
483 * @return void
484 */
485 protected function handlePageEditing() {
486
487 if(!t3lib_extMgm::isLoaded('cms')) {
488 return;
489 }
490
491 // EDIT page:
492 $editId = preg_replace('/[^[:alnum:]_]/', '', t3lib_div::_GET('edit'));
493 $editRecord = '';
494
495 if($editId) {
496
497 // Looking up the page to edit, checking permissions:
498 $where = ' AND ('.$GLOBALS['BE_USER']->getPagePermsClause(2)
499 .' OR '.$GLOBALS['BE_USER']->getPagePermsClause(16).')';
500
501 if(t3lib_div::testInt($editId)) {
502 $editRecord = t3lib_BEfunc::getRecordWSOL('pages', $editId, '*', $where);
503 } else {
504 $records = t3lib_BEfunc::getRecordsByField('pages', 'alias', $editId, $where);
505
506 if(is_array($records)) {
507 reset($records);
508 $editRecord = current($records);
509 t3lib_BEfunc::workspaceOL('pages', $editRecord);
510 }
511 }
512
513 // If the page was accessible, then let the user edit it.
514 if(is_array($editRecord) && $GLOBALS['BE_USER']->isInWebMount($editRecord['uid'])) {
515 // Setting JS code to open editing:
516 $this->js .= '
517 // Load page to edit:
518 window.setTimeout("top.loadEditId('.intval($editRecord['uid']).');", 500);
519 ';
520 // Checking page edit parameter:
521 if(!$GLOBALS['BE_USER']->getTSConfigVal('options.shortcut_onEditId_dontSetPageTree')) {
522
523 // Expanding page tree:
524 t3lib_BEfunc::openPageTree(intval($editRecord['pid']), !$GLOBALS['BE_USER']->getTSConfigVal('options.shortcut_onEditId_keepExistingExpanded'));
525 }
526 } else {
527 $this->js .= '
528 // Warning about page editing:
529 alert('.$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('noEditPage'), $editId)).');
530 ';
531 }
532 }
533 }
534
535 /**
536 * Sets the startup module from either GETvars module and mpdParams or user configuration.
537 *
538 * @return void
539 */
540 protected function setStartupModule() {
541 $startModule = preg_replace('/[^[:alnum:]_]/', '', t3lib_div::_GET('module'));
542
543 if(!$startModule) {
544 if ($GLOBALS['BE_USER']->uc['startModule']) {
545 $startModule = $GLOBALS['BE_USER']->uc['startModule'];
546 } else if($GLOBALS['BE_USER']->uc['startInTaskCenter']) {
547 $startModule = 'user_task';
548 }
549 }
550
551 $moduleParameters = t3lib_div::_GET('modParams');
552 if($startModule) {
553 $this->js .= '
554 // start in module:
555 function startInModule(modName, cMR_flag, addGetVars) {
556 Event.observe(document, \'dom:loaded\', function() {
557 top.goToModule(modName, cMR_flag, addGetVars);
558 });
559 }
560
561 startInModule(\''.$startModule.'\', false, \''.$moduleParameters.'\');
562 ';
563 }
564 }
565
566 /**
567 * generates the code for the TYPO3 logo, either the default TYPO3 logo or a custom one
568 *
569 * @return string HTML code snippet to display the TYPO3 logo
570 */
571 protected function getLogo() {
572 $logo = '<a href="http://www.typo3.com/" target="_blank" onclick="'.$GLOBALS['TBE_TEMPLATE']->thisBlur().'">'.
573 '<img'.t3lib_iconWorks::skinImg('','gfx/alt_backend_logo.gif','width="117" height="32"').' title="TYPO3 Content Management Framework" alt="" />'.
574 '</a>';
575
576 // overwrite with custom logo
577 if($GLOBALS['TBE_STYLES']['logo']) {
578 if(substr($GLOBALS['TBE_STYLES']['logo'], 0, 3) == '../') {
579 $imgInfo = @getimagesize(PATH_site.substr($GLOBALS['TBE_STYLES']['logo'], 3));
580 }
581 $logo = '<a href="http://www.typo3.com/" target="_blank" onclick="'.$GLOBALS['TBE_TEMPLATE']->thisBlur().'">'.
582 '<img src="'.$GLOBALS['TBE_STYLES']['logo'].'" '.$imgInfo[3].' title="TYPO3 Content Management Framework" alt="" />'.
583 '</a>';
584 }
585
586 return $logo;
587 }
588
589 /**
590 * adds a javascript snippet to the backend
591 *
592 * @param string javascript snippet
593 * @return void
594 */
595 public function addJavascript($javascript) {
596 // TODO do we need more checks?
597 if(!is_string($javascript)) {
598 throw new InvalidArgumentException('parameter $javascript must be of type string', 1195129553);
599 }
600
601 $this->js .= $javascript;
602 }
603
604 /**
605 * adds a javscript file to the backend after it has been checked that it exists
606 *
607 * @param string javascript file reference
608 * @return boolean true if the javascript file was successfully added, false otherwise
609 */
610 public function addJavascriptFile($javascriptFile) {
611 $jsFileAdded = false;
612
613 //TODO add more checks if neccessary
614 if(file_exists(t3lib_div::resolveBackPath(PATH_typo3.$javascriptFile))) {
615 $this->jsFiles[] = $javascriptFile;
616 $jsFileAdded = true;
617 }
618
619 return $jsFileAdded;
620 }
621
622 /**
623 * adds a css snippet to the backend
624 *
625 * @param string css snippet
626 * @return void
627 */
628 public function addCss($css) {
629 if(!is_string($css)) {
630 throw new InvalidArgumentException('parameter $css must be of type string', 1195129642);
631 }
632
633 $this->css .= $css;
634 }
635
636 /**
637 * adds a css file to the backend after it has been checked that it exists
638 *
639 * @param string the css file's name with out the .css ending
640 * @param string css file reference
641 * @return boolean true if the css file was added, false otherwise
642 */
643 public function addCssFile($cssFileName, $cssFile) {
644 $cssFileAdded = false;
645
646 //TODO add more checks if neccessary
647 if(file_exists(t3lib_div::resolveBackPath(PATH_typo3.$cssFile))) {
648 // prevent overwriting existing css files
649 if(empty($this->cssFiles[$cssFileName])) {
650 $this->cssFiles[$cssFileName] = $cssFile;
651 $cssFileAdded = true;
652 }
653 }
654
655 return $cssFileAdded;
656 }
657
658 /**
659 * adds an item to the toolbar, the class file for the toolbar item must be loaded at this point
660 *
661 * @param string toolbar item name, f.e. tx_toolbarExtension_coolItem
662 * @param string toolbar item class name, f.e. tx_toolbarExtension_coolItem
663 * @return void
664 */
665 public function addToolbarItem($toolbarItemName, $toolbarItemClassName) {
666 $toolbarItem = t3lib_div::makeInstance($toolbarItemClassName, $this);
667
668 if(!($toolbarItem instanceof backend_toolbarItem)) {
669 throw new UnexpectedValueException('$toolbarItem "'.$toolbarItemName.'" must implement interface backend_toolbarItem', 1195125501);
670 }
671
672 if($toolbarItem->checkAccess()) {
673 $this->toolbarItems[$toolbarItemName] = $toolbarItem;
674 } else {
675 unset($toolbarItem);
676 }
677 }
678 }
679
680
681 // include XCLASS
682 if(defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/backend.php']) {
683 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/backend.php']);
684 }
685
686
687 // document generation
688 $TYPO3backend = t3lib_div::makeInstance('TYPO3backend');
689
690 // include extensions which may add css, javascript or toolbar items
691 if(is_array($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'])) {
692 foreach($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'] as $additionalBackendItem) {
693 include_once($additionalBackendItem);
694 }
695 }
696
697 $TYPO3backend->render();
698
699 ?>