Fixed bug: Removed unused inclusion of typo3/js/ajax.js in typo3/backend.php
[Packages/TYPO3.CMS.git] / typo3 / backend.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2007 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 private $content;
57 private $cssFiles;
58 private $js;
59 private $jsFiles;
60
61 /**
62 * Object for loading backend modules
63 *
64 * @var t3lib_loadModules
65 */
66 private $moduleLoader;
67
68 /**
69 * module menu generating object
70 *
71 * @var ModuleMenu
72 */
73 private $moduleMenu;
74
75 private $leftMenuWidth;
76 private $topHeight;
77 private $selectMenu;
78 private $toolbarItems;
79
80 /**
81 * constructor
82 *
83 * @return void
84 */
85 public function __construct() {
86 // Initializes the backend modules structure for use later.
87 $this->moduleLoader = t3lib_div::makeInstance('t3lib_loadModules');
88 $this->moduleLoader->load($GLOBALS['TBE_MODULES']);
89
90 $this->moduleMenu = t3lib_div::makeInstance('ModuleMenu');
91
92 // Check for distances defined in the styles array:
93 if ($TBE_STYLES['dims']['leftMenuFrameW']) {
94 $this->leftMenuWidth = $TBE_STYLES['dims']['leftMenuFrameW'];
95 }
96 if ($TBE_STYLES['dims']['topFrameH']) {
97 $this->topHeight = $TBE_STYLES['dims']['topFrameH'];
98 }
99 if ($TBE_STYLES['dims']['selMenuFrame']) {
100 $this->selectMenu = $TBE_STYLES['dims']['selMenuFrame'];
101 }
102
103 // add default BE javascript
104 $this->js = '';
105 $this->jsFiles = array(
106 'contrib/prototype/prototype.js',
107 'contrib/scriptaculous/scriptaculous.js?load=builder,effects,controls,dragdrop',
108 'md5.js',
109 'js/backend.js',
110 'js/common.js',
111 'js/sizemanager.js',
112 'js/toolbarmanager.js',
113 '../t3lib/jsfunc.evalfield.js'
114 );
115
116 // add default BE css
117 $this->cssFiles = array(
118 'css/backend-scaffolding.css',
119 'css/backend-style.css',
120 'css/verticalmenu.css'
121 );
122
123 $this->toolbarItems = array();
124 $this->initializeCoreToolbarItems();
125 }
126
127 /**
128 * initializes the core toolbar items
129 *
130 * @return void
131 */
132 private function initializeCoreToolbarItems() {
133
134 $coreToolbarItems = array(
135 'workspaceSelector' => 'WorkspaceSelector',
136 'clearCacheActions' => 'ClearCacheMenu',
137 'shortcuts' => 'ShortcutMenu',
138 'backendSearch' => 'BackendSearchMenu'
139 );
140
141 foreach($coreToolbarItems as $toolbarItemName => $toolbarItemClass) {
142 $toolbarItem = t3lib_div::makeInstance($toolbarItemClass);
143
144 if(!($toolbarItem instanceof backend_toolbarItem)) {
145 throw new UnexpectedValueException('$toolbarItem "'.$toolbarItemName.'" must implement interface backend_toolbarItem', 1195126772);
146 }
147
148 $toolbarItem->setBackend($this);
149 $this->toolbarItems[$toolbarItemName] = $toolbarItem;
150 }
151 }
152
153 /**
154 * main function generating the BE scaffolding
155 *
156 * @return void
157 */
158 public function render() {
159
160 // prepare the scaffolding, at this point extension still may addjavascript and css
161 $logo = t3lib_div::makeInstance('TYPO3Logo');
162 $logo->setLogo('gfx/typo3logo_mini.png');
163
164 $menu = $this->moduleMenu->render();
165
166
167 // create backend scaffolding
168 $backendScaffolding = '
169 <div id="typo3-backend">
170 <div id="typo3-top-container">
171 <div id="typo3-logo">'.$logo->render().'</div>
172 <div id="typo3-top" class="typo3-top-toolbar">'
173 .$this->renderToolbar()
174 .'</div>
175 </div>
176 <div id="typo3-main-container">
177 <div id="typo3-side-menu">
178 '.$menu.'
179 </div>
180 <div id="typo3-content">
181 <iframe src="alt_intro.php" name="content" id="content" marginwidth="0" marginheight="0" frameborder="0" scrolling="auto" noresize="noresize"></iframe>
182 </div>
183 </div>
184 </div>
185 </body>
186 </html>';
187
188 /******************************************************
189 * now put the complete backend document together
190 ******************************************************/
191
192 // set doctype
193 $GLOBALS['TBE_TEMPLATE']->docType = 'xhtml_trans';
194
195 // add javascript
196 foreach($this->jsFiles as $jsFile) {
197 $GLOBALS['TBE_TEMPLATE']->JScode .= '
198 <script type="text/javascript" src="'.$jsFile.'"></script>';
199 }
200 $GLOBALS['TBE_TEMPLATE']->JScode .= chr(10);
201 $this->generateJavascript();
202 $GLOBALS['TBE_TEMPLATE']->JScode .= $GLOBALS['TBE_TEMPLATE']->wrapScriptTags($this->js);
203
204 // abusing the JS container to add CSS
205 // TODO fix template.php
206 foreach($this->cssFiles as $cssFile) {
207 $GLOBALS['TBE_TEMPLATE']->JScode .= '
208 <link rel="stylesheet" type="text/css" href="'.$cssFile.'" />
209 ';
210 }
211 // TODO add CSS from $this->css
212
213 // set document title
214 $title = $TYPO3_CONF_VARS['SYS']['sitename'] ?
215 $TYPO3_CONF_VARS['SYS']['sitename'].' [TYPO3 '.TYPO3_version.']'
216 : 'TYPO3 '.TYPO3_version;
217
218 // start page header:
219 $this->content .= $GLOBALS['TBE_TEMPLATE']->startPage($title);
220 $this->content .= $GLOBALS['TBE_TEMPLATE']->endPage();
221
222 $this->content .= $backendScaffolding;
223
224 echo $this->content;
225 }
226
227 /**
228 * renders the items in the top toolbar
229 *
230 * @return string top toolbar elements as HTML
231 */
232 private function renderToolbar() {
233 $toolbar = '<ul id="typo3-toolbar">';
234 $toolbar.= '<li>'.$this->getLoggedInUserLabel().'</li>
235 <li><div id="logout-button" class="toolbar-item no-separator">'.$this->moduleMenu->renderLogoutButton().'</div></li>';
236
237 foreach($this->toolbarItems as $toolbarItem) {
238 $additionalAttributes = $toolbarItem->getAdditionalAttributes();
239
240 $toolbar .= '<li'.$additionalAttributes.'>'.$toolbarItem->render().'</li>';
241 }
242
243 return $toolbar.'</ul>';
244 }
245
246 /**
247 * gets the label of the currently loged in BE user
248 *
249 * @return string html code snippet displaying the currently logged in user
250 */
251 private function getLoggedInUserLabel() {
252 $username = '<div id="username" class="toolbar-item no-separator">['.htmlspecialchars($GLOBALS['BE_USER']->user['username']).']</div>';;
253
254 // superuser mode
255 if($BE_USER->user['ses_backuserid']) {
256 $username = '<div id="username" class="toolbar-item no-separator typo3-red-background">[SU: '.htmlspecialchars($GLOBALS['BE_USER']->user['username']).']</div>';
257 }
258
259 return $username;
260 }
261
262 /**
263 * Generates the JavaScript code for the backend.
264 *
265 * @return void
266 */
267 private function generateJavascript() {
268
269 $pathTYPO3 = t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')).'/';
270 $goToModuleSwitch = $this->moduleMenu->getGotoModuleJavascript();
271 $moduleFramesHelper = implode(chr(10), $this->moduleMenu->getFsMod());
272
273 // If another page module was specified, replace the default Page module with the new one
274 $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
275 $pageModule = t3lib_BEfunc::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
276
277 $menuFrameName = 'menu';
278 if($GLOBALS['BE_USER']->uc['noMenuMode'] === 'icons') {
279 $menuFrameName = 'topmenuFrame';
280 }
281
282 $this->js .= '
283 /**
284 * Function similar to PHPs rawurlencode();
285 */
286 function rawurlencode(str) { //
287 var output = escape(str);
288 output = str_replace("*","%2A", output);
289 output = str_replace("+","%2B", output);
290 output = str_replace("/","%2F", output);
291 output = str_replace("@","%40", output);
292 return output;
293 }
294
295 /**
296 * String-replace function
297 */
298 function str_replace(match,replace,string) { //
299 var input = ""+string;
300 var matchStr = ""+match;
301 if (!matchStr) {return string;}
302 var output = "";
303 var pointer=0;
304 var pos = input.indexOf(matchStr);
305 while (pos!=-1) {
306 output+=""+input.substr(pointer, pos-pointer)+replace;
307 pointer=pos+matchStr.length;
308 pos = input.indexOf(match,pos+1);
309 }
310 output+=""+input.substr(pointer);
311 return output;
312 }
313
314 /**
315 * TypoSetup object.
316 */
317 function typoSetup() { //
318 this.PATH_typo3 = "'.$pathTYPO3.'";
319 this.PATH_typo3_enc = "'.rawurlencode($pathTYPO3).'";
320 this.username = "'.$GLOBALS['BE_USER']->user['username'].'";
321 this.uniqueID = "'.t3lib_div::shortMD5(uniqid('')).'";
322 this.navFrameWidth = 0;
323 }
324 var TS = new typoSetup();
325
326 /**
327 * Functions for session-expiry detection:
328 */
329 function busy() { //
330 this.loginRefreshed = busy_loginRefreshed;
331 this.checkLoginTimeout = busy_checkLoginTimeout;
332 this.openRefreshWindow = busy_OpenRefreshWindow;
333 this.busyloadTime=0;
334 this.openRefreshW=0;
335 this.reloginCancelled=0;
336 }
337 function busy_loginRefreshed() { //
338 var date = new Date();
339 this.busyloadTime = Math.floor(date.getTime()/1000);
340 this.openRefreshW=0;
341 }
342 function busy_checkLoginTimeout() { //
343 var date = new Date();
344 var theTime = Math.floor(date.getTime()/1000);
345 if (theTime > this.busyloadTime+'.intval($GLOBALS['BE_USER']->auth_timeout_field).'-30) {
346 return true;
347 }
348 }
349 function busy_OpenRefreshWindow() { //
350 vHWin=window.open("login_frameset.php","relogin_"+TS.uniqueID,"height=350,width=700,status=0,menubar=0,location=1");
351 vHWin.focus();
352 this.openRefreshW=1;
353 }
354 function busy_checkLoginTimeout_timer() { //
355 if (busy.checkLoginTimeout() && !busy.reloginCancelled && !busy.openRefreshW) {
356 if (confirm('.$GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:mess.refresh_login')).')) {
357 busy.openRefreshWindow();
358 } else {
359 busy.reloginCancelled = 1;
360 }
361 }
362 window.setTimeout("busy_checkLoginTimeout_timer();",2*1000); // Each 2nd second is enough for checking. The popup will be triggered 10 seconds before the login expires (see above, busy_checkLoginTimeout())
363
364 // Detecting the frameset module navigation frame widths (do this AFTER setting new timeout so that any errors in the code below does not prevent another time to be set!)
365 if (top && top.content && top.content.nav_frame && top.content.nav_frame.document && top.content.nav_frame.document.body) {
366 TS.navFrameWidth = (top.content.nav_frame.document.documentElement && top.content.nav_frame.document.documentElement.clientWidth) ? top.content.nav_frame.document.documentElement.clientWidth : top.content.nav_frame.document.body.clientWidth;
367 }
368 }
369
370 /**
371 * Launcing information window for records/files (fileref as "table" argument)
372 */
373 function launchView(table,uid,bP) { //
374 var backPath= bP ? bP : "";
375 var thePreviewWindow="";
376 thePreviewWindow = window.open(TS.PATH_typo3+"show_item.php?table="+encodeURIComponent(table)+"&uid="+encodeURIComponent(uid),"ShowItem"+TS.uniqueID,"height=400,width=550,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
377 if (thePreviewWindow && thePreviewWindow.focus) {
378 thePreviewWindow.focus();
379 }
380 }
381
382 /**
383 * Opens plain window with url
384 */
385 function openUrlInWindow(url,windowName) { //
386 regularWindow = window.open(url,windowName,"status=1,menubar=1,resizable=1,location=1,directories=0,scrollbars=1,toolbar=1");
387 regularWindow.focus();
388 return false;
389 }
390
391 /**
392 * Loads a URL in the topmenuFrame
393 */
394 function loadTopMenu(url) { //
395 top.topmenuFrame.location = url;
396 }
397
398 /**
399 * Loads a page id for editing in the page edit module:
400 */
401 function loadEditId(id,addGetVars) { //
402 top.fsMod.recentIds["web"]=id;
403 top.fsMod.navFrameHighlightedID["web"]="pages"+id+"_0"; // For highlighting
404
405 if (top.content && top.content.nav_frame && top.content.nav_frame.refresh_nav) {
406 top.content.nav_frame.refresh_nav();
407 }
408
409 top.goToModule("'.$pageModule.'", 0, addGetVars?addGetVars:"");
410 }
411
412 /**
413 * Returns incoming URL (to a module) unless nextLoadModuleUrl is set. If that is the case nextLoadModuleUrl is returned (and cleared)
414 * Used by the shortcut frame to set a "intermediate URL"
415 */
416 var nextLoadModuleUrl="";
417 function getModuleUrl(inUrl) { //
418 var nMU;
419 if (top.nextLoadModuleUrl) {
420 nMU=top.nextLoadModuleUrl;
421 top.nextLoadModuleUrl="";
422 return nMU;
423 } else {
424 return inUrl;
425 }
426 }
427
428 /**
429 * Print properties of an object
430 */
431 function debugObj(obj,name) { //
432 var acc;
433 for (i in obj) {
434 if (obj[i]) {
435 acc+=i+": "+obj[i]+"\n";
436 }
437 }
438 alert("Object: "+name+"\n\n"+acc);
439 }
440
441 /**
442 * Initialize login expiration warning object
443 */
444 var busy = new busy();
445 busy.loginRefreshed();
446 busy_checkLoginTimeout_timer();
447
448
449 /**
450 * Highlight module:
451 */
452 var currentlyHighLightedId = "";
453 var currentlyHighLighted_restoreValue = "";
454 var currentlyHighLightedMain = "";
455 function highlightModuleMenuItem(trId, mainModule) { //
456 currentlyHighLightedMain = mainModule;
457 // Get document object:
458 if (top.menu && top.menu.document) {
459 var docObj = top.menu.document;
460 var HLclass = mainModule ? "c-mainitem-HL" : "c-subitem-row-HL";
461 } else if (top.topmenuFrame && top.topmenuFrame.document) {
462 var docObj = top.topmenuFrame.document;
463 var HLclass = mainModule ? "c-mainitem-HL" : "c-subitem-HL";
464 }
465
466 if (docObj) {
467 // Reset old:
468 if (currentlyHighLightedId && docObj.getElementById(currentlyHighLightedId)) {
469 docObj.getElementById(currentlyHighLightedId).attributes.getNamedItem("class").nodeValue = currentlyHighLighted_restoreValue;
470 }
471 // Set new:
472 currentlyHighLightedId = trId;
473 if (currentlyHighLightedId && docObj.getElementById(currentlyHighLightedId)) {
474 var classAttribObject = docObj.getElementById(currentlyHighLightedId).attributes.getNamedItem("class");
475 currentlyHighLighted_restoreValue = classAttribObject.nodeValue;
476 classAttribObject.nodeValue = HLclass;
477 }
478 }
479 }
480
481 /**
482 * Function restoring previous selection in left menu after clearing cache
483 */
484 function restoreHighlightedModuleMenuItem() { //
485 if (currentlyHighLightedId) {
486 highlightModuleMenuItem(currentlyHighLightedId,currentlyHighLightedMain);
487 }
488 }
489
490 '.$goToModuleSwitch.'
491
492 /**
493 * reloads the menu frame
494 */
495 function refreshMenu() {
496 top.'.$menuFrameName.'.location.href = top.'.$menuFrameName.'.document.URL
497 }
498
499 /**
500 * Frameset Module object
501 *
502 * Used in main modules with a frameset for submodules to keep the ID between modules
503 * Typically that is set by something like this in a Web>* sub module:
504 * if (top.fsMod) top.fsMod.recentIds["web"] = "\'.intval($this->id).\'";
505 * if (top.fsMod) top.fsMod.recentIds["file"] = "...(file reference/string)...";
506 */
507 function fsModules() { //
508 this.recentIds=new Array(); // used by frameset modules to track the most recent used id for list frame.
509 this.navFrameHighlightedID=new Array(); // used by navigation frames to track which row id was highlighted last time
510 this.currentMainLoaded="";
511 this.currentBank="0";
512 }
513 var fsMod = new fsModules();
514 '.$moduleFramesHelper.'
515
516 // Used by Frameset Modules
517 var condensedMode = '.($GLOBALS['BE_USER']->uc['condensedMode']?1:0).';
518 var currentSubScript = "";
519 var currentSubNavScript = "";
520
521 // Used for tab-panels:
522 var DTM_currentTabs = new Array();
523 ';
524
525 // Check editing of page:
526 $this->editPageHandling();
527 $this->setStartupModule();
528 }
529
530 /**
531 * Checking if the "&edit" variable was sent so we can open for editing the page.
532 * Code based on code from "alt_shortcut.php"
533 *
534 * @return void
535 */
536 private function editPageHandling() {
537
538 if(!t3lib_extMgm::isLoaded('cms')) {
539 return;
540 }
541
542 // EDIT page:
543 $editId = preg_replace('/[^[:alnum:]_]/', '', t3lib_div::_GET('edit'));
544 $editRecord = '';
545
546 if($editId) {
547
548 // Looking up the page to edit, checking permissions:
549 $where = ' AND ('.$GLOBALS['BE_USER']->getPagePermsClause(2)
550 .' OR '.$GLOBALS['BE_USER']->getPagePermsClause(16).')';
551
552 if(t3lib_div::testInt($editId)) {
553 $editRecord = t3lib_BEfunc::getRecordWSOL('pages', $editId, '*', $where);
554 } else {
555 $records = t3lib_BEfunc::getRecordsByField('pages', 'alias', $editId, $where);
556
557 if(is_array($records)) {
558 reset($records);
559 $editRecord = current($records);
560 t3lib_BEfunc::workspaceOL('pages', $editRecord);
561 }
562 }
563
564 // If the page was accessible, then let the user edit it.
565 if(is_array($editRecord) && $GLOBALS['BE_USER']->isInWebMount($editRecord['uid'])) {
566 // Setting JS code to open editing:
567 $this->js .= '
568 // Load page to edit:
569 window.setTimeout("top.loadEditId('.intval($editRecord['uid']).');", 500);
570 ';
571 // Checking page edit parameter:
572 if(!$GLOBALS['BE_USER']->getTSConfigVal('options.shortcut_onEditId_dontSetPageTree')) {
573
574 // Expanding page tree:
575 t3lib_BEfunc::openPageTree(intval($editRecord['pid']), !$GLOBALS['BE_USER']->getTSConfigVal('options.shortcut_onEditId_keepExistingExpanded'));
576 }
577 } else {
578 $this->js .= '
579 // Warning about page editing:
580 alert('.$GLOBALS['LANG']->JScharCode(sprintf($GLOBALS['LANG']->getLL('noEditPage'), $editId)).');
581 ';
582 }
583 }
584 }
585
586 /**
587 * Sets the startup module from either GETvars module and mpdParams or user configuration.
588 *
589 * @return void
590 */
591 private function setStartupModule() {
592 $startModule = preg_replace('/[^[:alnum:]_]/', '', t3lib_div::_GET('module'));
593
594 if(!$startModule) {
595 if ($GLOBALS['BE_USER']->uc['startModule']) {
596 $startModule = $GLOBALS['BE_USER']->uc['startModule'];
597 } else if($GLOBALS['BE_USER']->uc['startInTaskCenter']) {
598 $startModule = 'user_task';
599 }
600 }
601
602 $moduleParameters = t3lib_div::_GET('modParams');
603 if($startModule) {
604 $this->js .= '
605 // start in module:
606 function startInModule(modName, cMR_flag, addGetVars) { //
607 if ($(content) && top.goToModule) {
608 top.goToModule(modName, cMR_flag, addGetVars);
609 } else {
610 window.setTimeout(function() { startInModuleModule(modName, cMR_flag, addGetVars); }, 500);
611 }
612 }
613
614 // startInModule(\''.$startModule.'\', false, \''.$moduleParameters.'\');
615 '; //TODO get start module working
616 }
617 }
618
619 /**
620 * generates the code for the TYPO3 logo, either the default TYPO3 logo or a custom one
621 *
622 * @return string HTML code snippet to display the TYPO3 logo
623 */
624 private function getLogo() {
625 $logo = '<a href="http://www.typo3.com/" target="_blank" onclick="'.$GLOBALS['TBE_TEMPLATE']->thisBlur().'">'.
626 '<img'.t3lib_iconWorks::skinImg('','gfx/alt_backend_logo.gif','width="117" height="32"').' title="TYPO3 Content Management Framework" alt="" />'.
627 '</a>';
628
629 // overwrite with custom logo
630 if($GLOBALS['TBE_STYLES']['logo']) {
631 if(substr($GLOBALS['TBE_STYLES']['logo'], 0, 3) == '../') {
632 $imgInfo = @getimagesize(PATH_site.substr($GLOBALS['TBE_STYLES']['logo'], 3));
633 }
634 $logo = '<a href="http://www.typo3.com/" target="_blank" onclick="'.$GLOBALS['TBE_TEMPLATE']->thisBlur().'">'.
635 '<img src="'.$GLOBALS['TBE_STYLES']['logo'].'" '.$imgInfo[3].' title="TYPO3 Content Management Framework" alt="" />'.
636 '</a>';
637 }
638
639 return $logo;
640 }
641
642 /**
643 * adds a javascript snippet to the backend
644 *
645 * @param string javascript snippet
646 * @return void
647 */
648 public function addJavascript($javascript) {
649 // TODO do we need more checks?
650 if(!is_string($javascript)) {
651 throw new InvalidArgumentException('parameter $javascript must be of type string', 1195129553);
652 }
653
654 $this->js .= $javascript;
655 }
656
657 /**
658 * adds a javscript file to the backend after it has been checked that it exists
659 *
660 * @param string javascript file reference
661 * @return void
662 */
663 public function addJavascriptFile($javascriptFile) {
664 //TODO add more checks if neccessary
665
666 if(file_exists(t3lib_div::resolveBackPath(PATH_site.$javascriptFile))) {
667
668 if(t3lib_div::isFirstPartOfStr($javascriptFile, 'typo3/')) {
669 $javascriptFile = substr($javascriptFile, 6); // make relative to typo3/
670 }
671
672 $this->jsFiles[] = $javascriptFile;
673 }
674 }
675
676 /**
677 * adds a css snippet to the backend
678 *
679 * @param string css snippet
680 * @return void
681 */
682 public function addCss($css) {
683 if(!is_string($css)) {
684 throw new InvalidArgumentException('parameter $css must be of type string', 1195129642);
685 }
686
687 $this->css .= $css;
688 }
689
690 /**
691 * adds a css file to the backend after it has been checked that it exists
692 *
693 * @param string css file reference
694 * @return void
695 */
696 public function addCssFile($cssFile) {
697 //TODO add more checks if neccessary
698
699 if(file_exists(t3lib_div::resolveBackPath(PATH_site.$cssFile))) {
700
701 if(t3lib_div::isFirstPartOfStr($cssFile, 'typo3/')) {
702 $cssFile = substr($cssFile, 6); // make relative to typo3/
703 }
704
705 $this->cssFiles[] = $cssFile;
706 }
707 }
708
709 /**
710 * adds an item to the toolbar
711 *
712 * @param string toolbar item class reference, f.e. EXT:toolbarextension/class.tx_toolbarextension_coolitem.php:tx_toolbarExtension_coolItem
713 */
714 public function addToolbarItem($toolbarItemName, $toolbarItemClassReference) {
715 $toolbarItem = t3lib_div::getUserObj($toolbarItemClassReference);
716
717 if(!($toolbarItem instanceof t3lib_backendToolbarItem)) {
718 throw new UnexpectedValueException('$toolbarItem "'.$toolbarItemName.'" must implement interface t3lib_backendToolbarItem', 1195125501);
719 }
720
721 $toolbarItem->setBackend($this);
722 $this->toolbarItems[$toolbarItemName] = $toolbarItem;
723 }
724 }
725
726
727 // include XCLASS
728 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/backend.php']) {
729 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/backend.php']);
730 }
731
732
733 // document generation
734 $TYPO3backend = t3lib_div::makeInstance('TYPO3backend');
735
736 // include extensions which may add css, javascript or toolbar items
737 if(is_array($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'])) {
738 foreach($GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems'] as $additionalBackendItem) {
739 include_once($additionalBackendItem);
740 }
741 }
742
743 $TYPO3backend->render();
744
745 ?>