Follow-up to #11044: mass uploader didn't worked because missing settings
[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 var currentModuleLoaded = "";
440 var goToModule = ' . $goToModuleSwitch . ';
441
442 /**
443 * Frameset Module object
444 *
445 * Used in main modules with a frameset for submodules to keep the ID between modules
446 * Typically that is set by something like this in a Web>* sub module:
447 * if (top.fsMod) top.fsMod.recentIds["web"] = "\'.intval($this->id).\'";
448 * if (top.fsMod) top.fsMod.recentIds["file"] = "...(file reference/string)...";
449 */
450 function fsModules() { //
451 this.recentIds=new Array(); // used by frameset modules to track the most recent used id for list frame.
452 this.navFrameHighlightedID=new Array(); // used by navigation frames to track which row id was highlighted last time
453 this.currentMainLoaded="";
454 this.currentBank="0";
455 }
456 var fsMod = new fsModules();' . $moduleFramesHelper . ';';
457
458
459
460 // Check editing of page:
461 $this->handlePageEditing();
462 $this->setStartupModule();
463 }
464
465 /**
466 * Checking if the "&edit" variable was sent so we can open it for editing the page.
467 * Code based on code from "alt_shortcut.php"
468 *
469 * @return void
470 */
471 protected function handlePageEditing() {
472
473 if(!t3lib_extMgm::isLoaded('cms')) {
474 return;
475 }
476
477 // EDIT page:
478 $editId = preg_replace('/[^[:alnum:]_]/', '', t3lib_div::_GET('edit'));
479 $editRecord = '';
480
481 if($editId) {
482
483 // Looking up the page to edit, checking permissions:
484 $where = ' AND ('.$GLOBALS['BE_USER']->getPagePermsClause(2)
485 .' OR '.$GLOBALS['BE_USER']->getPagePermsClause(16).')';
486
487 if(t3lib_div::testInt($editId)) {
488 $editRecord = t3lib_BEfunc::getRecordWSOL('pages', $editId, '*', $where);
489 } else {
490 $records = t3lib_BEfunc::getRecordsByField('pages', 'alias', $editId, $where);
491
492 if(is_array($records)) {
493 reset($records);
494 $editRecord = current($records);
495 t3lib_BEfunc::workspaceOL('pages', $editRecord);
496 }
497 }
498
499 // If the page was accessible, then let the user edit it.
500 if(is_array($editRecord) && $GLOBALS['BE_USER']->isInWebMount($editRecord['uid'])) {
501 // Setting JS code to open editing:
502 $this->js .= '
503 // Load page to edit:
504 window.setTimeout("top.loadEditId('.intval($editRecord['uid']).');", 500);
505 ';
506 // Checking page edit parameter:
507 if(!$GLOBALS['BE_USER']->getTSConfigVal('options.shortcut_onEditId_dontSetPageTree')) {
508
509 // Expanding page tree:
510 t3lib_BEfunc::openPageTree(intval($editRecord['pid']), !$GLOBALS['BE_USER']->getTSConfigVal('options.shortcut_onEditId_keepExistingExpanded'));
511 }
512 } else {
513 $this->js .= '
514 // Warning about page editing:
515 alert('.$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('noEditPage'), $editId)).');
516 ';
517 }
518 }
519 }
520
521 /**
522 * Sets the startup module from either GETvars module and mpdParams or user configuration.
523 *
524 * @return void
525 */
526 protected function setStartupModule() {
527 $startModule = preg_replace('/[^[:alnum:]_]/', '', t3lib_div::_GET('module'));
528
529 if(!$startModule) {
530 if ($GLOBALS['BE_USER']->uc['startModule']) {
531 $startModule = $GLOBALS['BE_USER']->uc['startModule'];
532 } else if($GLOBALS['BE_USER']->uc['startInTaskCenter']) {
533 $startModule = 'user_task';
534 }
535 }
536
537 $moduleParameters = t3lib_div::_GET('modParams');
538 if($startModule) {
539 $this->js .= '
540 // start in module:
541 function startInModule(modName, cMR_flag, addGetVars) {
542 Event.observe(document, \'dom:loaded\', function() {
543 top.goToModule(modName, cMR_flag, addGetVars);
544 });
545 }
546
547 startInModule(\''.$startModule.'\', false, \''.$moduleParameters.'\');
548 ';
549 }
550 }
551
552 /**
553 * generates the code for the TYPO3 logo, either the default TYPO3 logo or a custom one
554 *
555 * @return string HTML code snippet to display the TYPO3 logo
556 */
557 protected function getLogo() {
558 $logo = '<a href="http://www.typo3.com/" target="_blank" onclick="'.$GLOBALS['TBE_TEMPLATE']->thisBlur().'">'.
559 '<img'.t3lib_iconWorks::skinImg('','gfx/alt_backend_logo.gif','width="117" height="32"').' title="TYPO3 Content Management Framework" alt="" />'.
560 '</a>';
561
562 // overwrite with custom logo
563 if($GLOBALS['TBE_STYLES']['logo']) {
564 if(substr($GLOBALS['TBE_STYLES']['logo'], 0, 3) == '../') {
565 $imgInfo = @getimagesize(PATH_site.substr($GLOBALS['TBE_STYLES']['logo'], 3));
566 }
567 $logo = '<a href="http://www.typo3.com/" target="_blank" onclick="'.$GLOBALS['TBE_TEMPLATE']->thisBlur().'">'.
568 '<img src="'.$GLOBALS['TBE_STYLES']['logo'].'" '.$imgInfo[3].' title="TYPO3 Content Management Framework" alt="" />'.
569 '</a>';
570 }
571
572 return $logo;
573 }
574
575 /**
576 * adds a javascript snippet to the backend
577 *
578 * @param string javascript snippet
579 * @return void
580 */
581 public function addJavascript($javascript) {
582 // TODO do we need more checks?
583 if(!is_string($javascript)) {
584 throw new InvalidArgumentException('parameter $javascript must be of type string', 1195129553);
585 }
586
587 $this->js .= $javascript;
588 }
589
590 /**
591 * adds a javscript file to the backend after it has been checked that it exists
592 *
593 * @param string javascript file reference
594 * @return boolean true if the javascript file was successfully added, false otherwise
595 */
596 public function addJavascriptFile($javascriptFile) {
597 $jsFileAdded = false;
598
599 //TODO add more checks if neccessary
600 if(file_exists(t3lib_div::resolveBackPath(PATH_typo3.$javascriptFile))) {
601 $this->jsFiles[] = $javascriptFile;
602 $jsFileAdded = true;
603 }
604
605 return $jsFileAdded;
606 }
607
608 /**
609 * adds a css snippet to the backend
610 *
611 * @param string css snippet
612 * @return void
613 */
614 public function addCss($css) {
615 if(!is_string($css)) {
616 throw new InvalidArgumentException('parameter $css must be of type string', 1195129642);
617 }
618
619 $this->css .= $css;
620 }
621
622 /**
623 * adds a css file to the backend after it has been checked that it exists
624 *
625 * @param string the css file's name with out the .css ending
626 * @param string css file reference
627 * @return boolean true if the css file was added, false otherwise
628 */
629 public function addCssFile($cssFileName, $cssFile) {
630 $cssFileAdded = false;
631
632 //TODO add more checks if neccessary
633 if(file_exists(t3lib_div::resolveBackPath(PATH_typo3.$cssFile))) {
634 // prevent overwriting existing css files
635 if(empty($this->cssFiles[$cssFileName])) {
636 $this->cssFiles[$cssFileName] = $cssFile;
637 $cssFileAdded = true;
638 }
639 }
640
641 return $cssFileAdded;
642 }
643
644 /**
645 * adds an item to the toolbar, the class file for the toolbar item must be loaded at this point
646 *
647 * @param string toolbar item name, f.e. tx_toolbarExtension_coolItem
648 * @param string toolbar item class name, f.e. tx_toolbarExtension_coolItem
649 * @return void
650 */
651 public function addToolbarItem($toolbarItemName, $toolbarItemClassName) {
652 $toolbarItem = t3lib_div::makeInstance($toolbarItemClassName, $this);
653
654 if(!($toolbarItem instanceof backend_toolbarItem)) {
655 throw new UnexpectedValueException('$toolbarItem "'.$toolbarItemName.'" must implement interface backend_toolbarItem', 1195125501);
656 }
657
658 if($toolbarItem->checkAccess()) {
659 $this->toolbarItems[$toolbarItemName] = $toolbarItem;
660 } else {
661 unset($toolbarItem);
662 }
663 }
664 }
665
666
667 // include XCLASS
668 if(defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/backend.php']) {
669 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/backend.php']);
670 }
671
672
673 // document generation
674 $TYPO3backend = t3lib_div::makeInstance('TYPO3backend');
675
676 // include extensions which may add css, javascript or toolbar items
677 if(is_array($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'])) {
678 foreach($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'] as $additionalBackendItem) {
679 include_once($additionalBackendItem);
680 }
681 }
682
683 $TYPO3backend->render();
684
685 ?>