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