small changes
[Packages/TYPO3.CMS.git] / typo3 / template.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2003 Kasper Skårhøj (kasper@typo3.com)
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 * Contains class with layout/output function for TYPO3 Backend Scripts
29 *
30 * Revised for TYPO3 3.6 2/2003 by Kasper Skårhøj
31 * XHTML-trans compliant
32 *
33 * @author Kasper Skårhøj <kasper@typo3.com>
34 * @package TYPO3
35 * @subpackage core
36 */
37 /**
38 * [CLASS/FUNCTION INDEX of SCRIPT]
39 *
40 * 143: function fw($str)
41 *
42 *
43 * 165: class template
44 * 209: function template()
45 *
46 * SECTION: EVALUATION FUNCTIONS
47 * 263: function wrapClickMenuOnIcon($str,$table,$uid='',$listFr=1)
48 * 279: function viewPageIcon($id,$backPath,$addParams='hspace="3"')
49 * 304: function issueCommand($params,$rUrl='')
50 * 319: function isCMlayers()
51 * 329: function thisBlur()
52 * 339: function helpStyle()
53 * 356: function getHeader($table,$row,$path,$noViewPageIcon=0,$tWrap=array('',''))
54 * 381: function getFileheader($title,$path,$iconfile)
55 * 397: function makeShortcutIcon($gvList,$setList,$modName,$motherModName="")
56 * 430: function makeShortcutUrl($gvList,$setList)
57 * 451: function formWidth($size=48,$textarea=0,$styleOverride='')
58 * 476: function formWidthText($size=48,$styleOverride='',$wrap='')
59 * 493: function redirectUrls($thisLocation='')
60 * 517: function formatTime($tstamp,$type)
61 * 530: function parseTime()
62 *
63 * SECTION: PAGE BUILDING FUNCTIONS.
64 * 563: function startPage($title)
65 * 623: function endPage()
66 * 648: function header($text)
67 * 668: function section($label,$text,$nostrtoupper=0,$sH=0,$type=0)
68 * 689: function divider($dist)
69 * 705: function spacer($dist)
70 * 723: function sectionHeader($label,$sH=0)
71 * 740: function sectionBegin()
72 * 761: function sectionEnd()
73 * 781: function middle()
74 * 790: function endPageJS()
75 * 811: function docBodyTagBegin()
76 * 822: function docStyle()
77 * 846: function getBackgroundImage($CSS=0)
78 * 859: function initCharset()
79 * 869: function generator()
80 *
81 * SECTION: OTHER ELEMENTS
82 * 901: function icons($type)
83 * 930: function t3Button($onClick,$label)
84 * 941: function dfw($string)
85 * 951: function rfw($string)
86 * 961: function wrapInCData($string)
87 * 975: function wrapScriptTags($string)
88 * 1003: function table($arr)
89 * 1043: function menuTable($arr1,$arr2=array(), $arr3=array())
90 * 1076: function funcMenu($content,$menu)
91 * 1090: function clearCacheMenu($id,$addSaveOptions=0)
92 * 1124: function getContextMenuCode()
93 * 1141: function GL_checkBrowser()
94 * 1156: function GL_getObj(obj)
95 * 1168: function GL_getObjCss(obj)
96 * 1172: function GL_getMouse(event)
97 * 1186: function outsideLayer(level)
98 * 1193: function setLayerObj(html,level)
99 * 1211: function hideEmpty()
100 * 1217: function hideSpecific(level)
101 * 1223: function debugObj(obj,name)
102 * 1229: function initLayer()
103 *
104 *
105 * 1262: class bigDoc extends template
106 *
107 *
108 * 1271: class noDoc extends template
109 *
110 *
111 * 1280: class smallDoc extends template
112 *
113 *
114 * 1289: class mediumDoc extends template
115 *
116 * TOTAL FUNCTIONS: 54
117 * (This index is automatically created/updated by the extension "extdeveval")
118 *
119 */
120
121
122
123 if (!defined('TYPO3_MODE')) die("Can't include this file directly.");
124
125
126
127
128
129
130
131
132
133
134
135
136 /**
137 * Depreciated fontwrap function. Is just transparent now.
138 *
139 * @param string Input string
140 * @return string Output string (in the old days this was wrapped in <font> tags)
141 * @depreciated
142 */
143 function fw($str) {
144 return $str;
145 }
146
147
148 /**
149 * TYPO3 Backend Template Class
150 *
151 * This class contains functions for starting and ending the HTML of backend modules
152 * It also contains methods for outputting sections of content.
153 * Further there are functions for making icons, links, setting form-field widths etc.
154 * Color scheme and stylesheet definitions are also available here.
155 * Finally this file includes the language class for TYPO3's backend.
156 *
157 * After this file $LANG and $TBE_TEMPLATE are global variables / instances of their respective classes.
158 * This file is typically included right after the init.php file,
159 * if language and layout is needed.
160 *
161 * Please refer to Inside TYPO3 for a discussion of how to use this API.
162 *
163 * @author Kasper Skårhøj <kasper@typo3.com>
164 */
165 class template {
166
167 // Vars you typically might want to/should set from outside after making instance of this class:
168 var $backPath = ''; // 'backPath' pointing back to the PATH_typo3
169 var $form=''; // This can be set to the HTML-code for a formtag. Useful when you need a form to span the whole page; Inserted exactly after the body-tag.
170 var $JScode=''; // Additional header code (eg. a JavaScript section) could be accommulated in this var. It will be directly outputted in the header.
171 var $postCode=''; // Additional 'page-end' code could be accommulated in this var. It will be outputted at the end of page before </body> and some other internal page-end code.
172 var $docType=''; // Doc-type used in the header. Default is HTML 3.2. You can also set it to 'xhtml_strict', 'xhtml_trans', or 'xhtml_frames'.
173
174 // Other vars you can change, but less frequently used:
175 var $bodyTagAdditions=''; // You can add additional attributes to the body-tag through this variable.
176 var $inDocStyles=''; // Additional CSS styles which will be added to the <style> section in the header
177 var $form_rowsToStylewidth = 9.58; // Multiplication factor for formWidth() input size (default is 48* this value).
178 var $form_largeComp = 1.33; // Compensation for large documents (used in class.t3lib_tceforms.php)
179 var $endJS=1; // If set, then a JavaScript section will be outputted in the bottom of page which will try and update the top.busy session expiry object.
180
181 // TYPO3 Colorscheme.
182 // If you want to change this, please do so through a skin using the global var $TBE_STYLES
183 var $bgColor = '#F7F3EF'; // Light background color
184 var $bgColor2 = '#9BA1A8'; // Steel-blue
185 var $bgColor3 = '#F6F2E6'; // dok.color
186 var $bgColor4 = '#D9D5C9'; // light tablerow background, brownish
187 var $bgColor5 = '#ABBBB4'; // light tablerow background, greenish
188 var $bgColor6 = '#E7DBA8'; // light tablerow background, yellowish, for section headers. Light.
189 var $hoverColor = '#254D7B';
190 var $styleSheetFile = 'stylesheet.css'; // Filename of stylesheet (relative to PATH_typo3)
191 var $styleSheetFile2 = ''; // Filename of stylesheet #2 - linked to right after the $this->styleSheetFile script (relative to PATH_typo3)
192 var $backGroundImage = ''; // Background image of page (relative to PATH_typo3)
193
194 // DEV:
195 var $parseTimeFlag = 0; // Will output the parsetime of the scripts in milliseconds (for admin-users). Set this to false when releasing TYPO3. Only for dev.
196
197 // INTERNAL
198 var $charset = 'iso-8859-1'; // Default charset. see function initCharset()
199
200 var $sectionFlag=0; // Internal: Indicates if a <div>-output section is open
201 var $divClass="typo3-def"; // (Default) Class for wrapping <DIV>-tag of page. Is set in class extensions.
202
203 /**
204 * Constructor
205 * Imports relevant parts from global $TBE_STYLES (colorscheme)
206 *
207 * @return void
208 */
209 function template() {
210 global $TBE_STYLES;
211
212 // Color scheme:
213 if ($TBE_STYLES['mainColors']['bgColor']) $this->bgColor=$TBE_STYLES['mainColors']['bgColor'];
214 if ($TBE_STYLES['mainColors']['bgColor1']) $this->bgColor1=$TBE_STYLES['mainColors']['bgColor1'];
215 if ($TBE_STYLES['mainColors']['bgColor2']) $this->bgColor2=$TBE_STYLES['mainColors']['bgColor2'];
216 if ($TBE_STYLES['mainColors']['bgColor3']) $this->bgColor3=$TBE_STYLES['mainColors']['bgColor3'];
217 if ($TBE_STYLES['mainColors']['bgColor4']) $this->bgColor4=$TBE_STYLES['mainColors']['bgColor4'];
218 if ($TBE_STYLES['mainColors']['bgColor5']) $this->bgColor5=$TBE_STYLES['mainColors']['bgColor5'];
219 if ($TBE_STYLES['mainColors']['bgColor6']) $this->bgColor6=$TBE_STYLES['mainColors']['bgColor6'];
220 if ($TBE_STYLES['mainColors']['hoverColor']) $this->hoverColor=$TBE_STYLES['mainColors']['hoverColor'];
221
222 // Stylesheet:
223 if ($TBE_STYLES['stylesheet']) $this->styleSheetFile = $TBE_STYLES['stylesheet'];
224 if ($TBE_STYLES['stylesheet2']) $this->styleSheetFile2 = $TBE_STYLES['stylesheet2'];
225
226 // Background image
227 if ($TBE_STYLES['background']) $this->backGroundImage = $TBE_STYLES['background'];
228 }
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245 /*****************************************
246 *
247 * EVALUATION FUNCTIONS
248 * Various centralized processing
249 *
250 *****************************************/
251
252 /**
253 * Makes click menu link (context sensitive menu)
254 * Returns $str (possibly an <|img> tag/icon) wrapped in a link which will activate the context sensitive menu for the record ($table/$uid) or file ($table = file)
255 * The link will load the top frame with the parameter "&item" which is the table,uid and listFr arguments imploded by "|": rawurlencode($table.'|'.$uid.'|'.$listFr)
256 *
257 * @param string String to be wrapped in link, typ. image tag.
258 * @param string Table name/File path. If the icon is for a database record, enter the tablename from $TCA. If a file then enter the absolute filepath
259 * @param integer If icon is for database record this is the UID for the record from $table
260 * @param boolean Tells the top frame script that the link is coming from a "list" frame which means a frame from within the backend content frame.
261 * @return string The link-wrapped input string.
262 */
263 function wrapClickMenuOnIcon($str,$table,$uid='',$listFr=1) {
264 $onClick = 'top.loadTopMenu(\''.$this->backPath.'alt_clickmenu.php?item='.rawurlencode($table.'|'.$uid.'|'.$listFr).($this->backPath?'&backPath='.rawurlencode($this->backPath.'|'.md5($this->backPath.'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])):'').'\');'.$this->thisBlur().'return false;';
265 return '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.$str.'</a>';
266 }
267
268 /**
269 * Makes link to page $id in frontend (view page)
270 * Returns an magnifier-glass icon which links to the frontend index.php document for viewing the page with id $id
271 * $id must be a page-uid
272 * If the BE_USER has access to Web>List then a link to that module is shown as well (with return-url)
273 *
274 * @param integer The page id
275 * @param string The current "BACK_PATH" (the back relative to the typo3/ directory)
276 * @param string Additional parameters for the image tag(s)
277 * @return string HTML string with linked icon(s)
278 */
279 function viewPageIcon($id,$backPath,$addParams='hspace="3"') {
280 global $BE_USER;
281 $str = '';
282 // If access to Web>List for user, then link to that module.
283 if ($BE_USER->check('modules','web_list')) {
284 $href=$backPath.'db_list.php?id='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
285 $str.= '<a href="'.htmlspecialchars($href).'">'.
286 '<img src="'.$backPath.'gfx/list.gif" width="11" height="11" vspace="2" border="0" title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList',1).'"'.($addParams?' '.trim($addParams):'').' alt="" />'.
287 '</a>';
288 }
289 // Make link to view page
290 $str.= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($id,$backPath,t3lib_BEfunc::BEgetRootLine($id))).'">'.
291 '<img src="'.$backPath.'gfx/zoom.gif" width="12" height="12" border="0" title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage',1).'"'.($addParams?' '.trim($addParams):"").' hspace="2" alt="" />'.
292 '</a>';
293 return $str;
294 }
295
296 /**
297 * Returns a URL with a command to TYPO3 Core Engine (tce_db.php)
298 * See description of the API elsewhere.
299 *
300 * @param string $params is a set of GET params to send to tce_db.php. Example: "&cmd[tt_content][123][move]=456" or "&data[tt_content][123][hidden]=1&data[tt_content][123][title]=Hello%20World"
301 * @param string Redirect URL if any other that t3lib_div::getIndpEnv('REQUEST_URI') is wished
302 * @return string URL to tce_db.php + parameters (backpath is taken from $this->backPath)
303 */
304 function issueCommand($params,$rUrl='') {
305 $rUrl = $rUrl ? $rUrl : t3lib_div::getIndpEnv('REQUEST_URI');
306 return $this->backPath.'tce_db.php?'.
307 $params.
308 '&redirect='.($rUrl==-1?"'+T3_THIS_LOCATION+'":rawurlencode($rUrl)).
309 '&vC='.rawurlencode($GLOBALS['BE_USER']->veriCode()).
310 '&prErr=1&uPT=1';
311 }
312
313 /**
314 * Returns true if click-menu layers can be displayed for the current user/browser
315 * Use this to test if click-menus (context sensitive menus) can and should be displayed in the backend.
316 *
317 * @return boolean
318 */
319 function isCMlayers() {
320 return !$GLOBALS['BE_USER']->uc['disableCMlayers'] && $GLOBALS['CLIENT']['FORMSTYLE'] && $GLOBALS['CLIENT']['SYSTEM']!='mac';
321 }
322
323 /**
324 * Returns 'this.blur();' if the client supports CSS styles
325 * Use this in links to remove the underlining after being clicked
326 *
327 * @return string
328 */
329 function thisBlur() {
330 return ($GLOBALS['CLIENT']['FORMSTYLE']?'this.blur();':'');
331 }
332
333 /**
334 * Returns ' style='cursor:help;'' if the client supports CSS styles
335 * Use for <a>-links to help texts
336 *
337 * @return string
338 */
339 function helpStyle() {
340 return $GLOBALS['CLIENT']['FORMSTYLE'] ? ' style="cursor:help;"':'';
341 }
342
343 /**
344 * Makes the header (icon+title) for a page (or other record). Used in most modules under Web>*
345 * $table and $row must be a tablename/record from that table
346 * $path will be shown as alt-text for the icon.
347 * The title will be truncated to 45 chars.
348 *
349 * @param string Table name
350 * @param array Record row
351 * @param string Alt text
352 * @param boolean Set $noViewPageIcon true if you don't want a magnifier-icon for viewing the page in the frontend
353 * @param array $tWrap is an array with indexes 0 and 1 each representing HTML-tags (start/end) which will wrap the title
354 * @return string HTML content
355 */
356 function getHeader($table,$row,$path,$noViewPageIcon=0,$tWrap=array('','')) {
357 global $TCA;
358 if (is_array($row)) {
359 $iconfile=t3lib_iconWorks::getIcon($table,$row);
360 $title= strip_tags($row[$TCA[$table]['ctrl']['label']]);
361 $viewPage = $noViewPageIcon ? '' : $this->viewPageIcon($row['uid'],$this->backPath,'align="top" vspace="2"');
362 if ($table=='pages') $path.=' - '.t3lib_BEfunc::titleAttribForPages($row,'',0);
363 } else {
364 $iconfile='gfx/i/_icon_website.gif';
365 $title=$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
366 }
367 return $this->wrapClickMenuOnIcon('<img src="'.$this->backPath.$iconfile.'" width="18" height="16" border="0" title="'.htmlspecialchars($path).'" align="top" alt="" />',$table,$row['uid']).
368 $viewPage.
369 '&nbsp;<b>'.$tWrap[0].htmlspecialchars(t3lib_div::fixed_lgd($title,45)).$tWrap[1].'</b>';
370 }
371
372 /**
373 * Like ->getHeader() but for files in the File>* main module/submodules
374 * Returns the file-icon with the path of the file set in the alt/title attribute. Shows the file-name after the icon.
375 *
376 * @param string Title string, expected to be the filepath
377 * @param string Alt text
378 * @param string The icon file (relative to TYPO3 dir)
379 * @return string HTML content
380 */
381 function getFileheader($title,$path,$iconfile) {
382 $fileInfo = t3lib_div::split_fileref($title);
383 $title=htmlspecialchars($fileInfo['path']).'<b>'.htmlspecialchars($fileInfo['file']).'</b>';
384 $title=t3lib_div::fixed_lgd_pre($title,45);
385 return '<img src="'.$this->backPath.$iconfile.'" width="18" height="16" border="0" title="'.htmlspecialchars($path).'" align="top" alt="" />&nbsp;'.$title;
386 }
387
388 /**
389 * Returns a linked shortcut-icon which will call the shortcut frame and set a shortcut there back to the calling page/module
390 *
391 * @param string Is the list of GET variables to store (if any)
392 * @param string Is the list of SET[] variables to store (if any) - SET[] variables a stored in $GLOBALS["SOBE"]->MOD_SETTINGS for backend modules
393 * @param string Module name string
394 * @param string Is used to enter the "parent module name" if the module is a submodule under eg. Web>* or File>*. You can also set this value to "1" in which case the currentLoadedModule is sent to the shortcut script (so - not a fixed value!) - that is used in file_edit.php and wizard_rte.php scripts where those scripts are really running as a part of another module.
395 * @return string HTML content
396 */
397 function makeShortcutIcon($gvList,$setList,$modName,$motherModName="") {
398 $backPath=$this->backPath;
399 $storeUrl=$this->makeShortcutUrl($gvList,$setList);
400 $pathInfo = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
401
402 if (!strcmp($motherModName,'1')) {
403 $mMN="&motherModName='+top.currentModuleLoaded+'";
404 } elseif ($motherModName) {
405 $mMN='&motherModName='.rawurlencode($motherModName);
406 } else $mMN="";
407
408 $onClick = 'if (top.shortcutFrame && confirm('.
409 $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.makeShortcut')).
410 ')){top.shortcutFrame.document.location=\''.$backPath.'alt_shortcut.php?modName='.rawurlencode($modName).
411 '&URL='.rawurlencode($pathInfo['path']."?".$storeUrl).
412 $mMN.
413 '\';}return false;';
414
415 $sIcon = '<a href="#" onclick="'.htmlspecialchars($onClick).'">
416 <img src="'.$backPath.'gfx/shortcut.gif" width="14" height="14" border="0"'.t3lib_BEfunc::titleAttrib($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.makeShortcut'),1).' alt="" /></a>';
417 return $sIcon;
418 }
419
420 /**
421 * MAKE url for storing
422 * Internal func
423 *
424 * @param Is the list of GET variables to store (if any)
425 * @param Is the list of SET[] variables to store (if any) - SET[] variables a stored in $GLOBALS["SOBE"]->MOD_SETTINGS for backend modules
426 * @return string
427 * @access private
428 * @see makeShortcutIcon()
429 */
430 function makeShortcutUrl($gvList,$setList) {
431 global $HTTP_GET_VARS;
432 $storeArray = array_merge(
433 t3lib_div::compileSelectedGetVarsFromArray($gvList,$HTTP_GET_VARS),
434 array('SET'=>t3lib_div::compileSelectedGetVarsFromArray($setList,$GLOBALS['SOBE']->MOD_SETTINGS))
435 );
436 $storeUrl = t3lib_div::implodeArrayForUrl("",$storeArray);
437 return $storeUrl;
438 }
439
440 /**
441 * Returns <input> attributes to set the width of an text-type input field.
442 * For client browsers with no CSS support the cols/size attribute is returned.
443 * For CSS compliant browsers (recommended) a ' style="width: ...px;"' is returned.
444 *
445 * @param integer A relative number which multiplied with approx. 10 will lead to the width in pixels
446 * @param boolean A flag you can set for textareas - DEPRECIATED, use ->formWidthText() for textareas!!!
447 * @param string A string which will be returned as attribute-value for style="" instead of the calculated width (if CSS is enabled)
448 * @return string Tag attributes for an <input> tag (regarding width)
449 * @see formWidthText()
450 */
451 function formWidth($size=48,$textarea=0,$styleOverride='') {
452 $wAttrib = $textarea?'cols':'size';
453 if (!$GLOBALS['CLIENT']['FORMSTYLE']) { // If not setting the width by style-attribute
454 $size = $size;
455 $retVal = ' '.$wAttrib.'="'.$size.'"';
456 } else { // Setting width by style-attribute. 'cols' MUST be avoided with NN6+
457 $pixels = ceil($size*$this->form_rowsToStylewidth);
458 $retVal = $styleOverride ? ' style="'.$styleOverride.'"' : ' style="width:'.$pixels.'px;"';
459 }
460 return $retVal;
461 }
462
463 /**
464 * This function is dedicated to textareas, which has the wrapping on/off option to observe.
465 * EXAMPLE:
466 * <textarea rows="10" wrap="off" '.$GLOBALS["TBE_TEMPLATE"]->formWidthText(48,"","off").'>
467 * or
468 * <textarea rows="10" wrap="virtual" '.$GLOBALS["TBE_TEMPLATE"]->formWidthText(48,"","virtual").'>
469 *
470 * @param integer A relative number which multiplied with approx. 10 will lead to the width in pixels
471 * @param string A string which will be returned as attribute-value for style="" instead of the calculated width (if CSS is enabled)
472 * @param string Pass on the wrap-attribute value you use in your <textarea>! This will be used to make sure that some browsers will detect wrapping alright.
473 * @return string Tag attributes for an <input> tag (regarding width)
474 * @see formWidth()
475 */
476 function formWidthText($size=48,$styleOverride='',$wrap='') {
477 $wTags = $this->formWidth($size,1,$styleOverride);
478 // Netscape 6+/Mozilla seems to have this ODD problem where there WILL ALWAYS be wrapping with the cols-attribute set and NEVER without the col-attribute...
479 if (strtolower(trim($wrap))!='off' && $GLOBALS['CLIENT']['BROWSER']=='net' && $GLOBALS['CLIENT']['VERSION']>=5) {
480 $wTags.=' cols="'.$size.'"';
481 }
482 return $wTags;
483 }
484
485 /**
486 * Returns JavaScript variables setting the returnUrl and thisScript location for use by JavaScript on the page.
487 * Used in fx. db_list.php (Web>List)
488 *
489 * @param string URL to "this location" / current script
490 * @return string
491 * @see typo3/db_list.php
492 */
493 function redirectUrls($thisLocation='') {
494 $thisLocation = $thisLocation?$thisLocation:t3lib_div::linkThisScript(
495 array(
496 'CB'=>'',
497 'SET'=>'',
498 'cmd' => '',
499 'popViewId'=>''
500 ));
501
502 $out ="
503 var T3_RETURN_URL = '".str_replace('%20','',rawurlencode(t3lib_div::GPvar('returnUrl')))."';
504 var T3_THIS_LOCATION = '".str_replace('%20','',rawurlencode($thisLocation))."';
505 ";
506 return $out;
507 }
508
509 /**
510 * Returns a formatted string of $tstamp
511 * Uses $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] and $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] to format date and time
512 *
513 * @param integer UNIX timestamp, seconds since 1970
514 * @param integer How much data to show: $type = 1: hhmm, $type = 10: ddmmmyy
515 * @return string Formatted timestamp
516 */
517 function formatTime($tstamp,$type) {
518 switch($type) {
519 case 1: return date($GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'],$tstamp); break;
520 case 10: return date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'],$tstamp); break;
521 }
522 }
523
524 /**
525 * Returns script parsetime IF ->parseTimeFlag is set and user is "admin"
526 * Automatically outputted in page end
527 *
528 * @return string
529 */
530 function parseTime() {
531 if ($this->parseTimeFlag && $GLOBALS['BE_USER']->isAdmin()) {
532 return '<p>(ParseTime: '.(t3lib_div::milliseconds()-$GLOBALS['PARSETIME_START']).' ms</p>
533 <p>REQUEST_URI-length: '.strlen(t3lib_div::getIndpEnv('REQUEST_URI')).')</p>';
534 }
535 }
536
537
538
539
540
541
542
543
544
545
546
547
548 /*****************************************
549 *
550 * PAGE BUILDING FUNCTIONS.
551 * Use this to build the HTML of your backend modules
552 *
553 *****************************************/
554
555 /**
556 * Returns page start
557 * This includes the proper header with charset, title, meta tag and beginning body-tag.
558 *
559 * @param string HTML Page title for the header
560 * @return string Returns the whole header section of a HTML-document based on settings in internal variables (like styles, javascript code, charset, generator and docType)
561 * @see endPage()
562 */
563 function startPage($title) {
564 $charSet = $this->initCharset();
565 $generator = $this->generator();
566
567 switch($this->docType) {
568 case 'xhtml_strict':
569 $headerStart= '<?xml version="1.0" encoding="'.$this->charset.'"?>
570 <?xml-stylesheet href="#internalStyle" type="text/css"?>
571 <!DOCTYPE html
572 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
573 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
574 break;
575 case 'xhtml_trans':
576 $headerStart= '<?xml version="1.0" encoding="'.$this->charset.'"?>
577 <?xml-stylesheet href="#internalStyle" type="text/css"?>
578 <!DOCTYPE html
579 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
580 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
581 break;
582 case 'xhtml_frames':
583 $headerStart= '<?xml version="1.0" encoding="'.$this->charset.'"?>
584 <!DOCTYPE html
585 PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
586 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
587 break;
588 default:
589 $headerStart='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">';
590 break;
591 }
592
593 // Construct page header.
594 $str = $headerStart.'
595 <html>
596 <head>
597 '.$charSet.'
598 '.$generator.'
599 <title>'.htmlspecialchars($title).'</title>
600 '.$this->docStyle().'
601 '.$this->JScode.'
602 </head>
603 ';
604
605 if ($this->docType=='xhtml_frames') {
606 return $str;
607 } else
608 $str.=$this->docBodyTagBegin().
609 ($this->divClass?'
610
611 <!-- Wrapping DIV-section for whole page BEGIN -->
612 <div class="'.$this->divClass.'">':'').
613 trim($this->form);
614 return $str;
615 }
616
617 /**
618 * Returns page end.
619 *
620 * @return string The HTML end of a page
621 * @see startPage()
622 */
623 function endPage() {
624 $str = $this->sectionEnd().
625 $this->postCode.
626 $this->endPageJS().
627 t3lib_BEfunc::getSetUpdateSignal().
628 $this->parseTime().
629 ($this->form?'
630 </form>':'').
631 ($this->divClass?'
632
633 <!-- Wrapping DIV-section for whole page END -->
634 </div>':'').
635 '
636 </body>
637 </html> ';
638 return $str;
639 }
640
641 /**
642 * Returns the header-bar in the top of most backend modules
643 * Closes section if open.
644 *
645 * @param string The text string for the header
646 * @return string HTML content
647 */
648 function header($text) {
649 $str='
650
651 <!-- MAIN Header in page top -->
652 <h2>'.$text.'</h2>
653 ';
654 return $this->sectionEnd().$str;
655 }
656
657 /**
658 * Begins an output section and sets header and content
659 *
660 * @param string The header
661 * @param string The HTML-content
662 * @param boolean A flag that will prevent the header from being converted to uppercase
663 * @param boolean Defines the type of header (if set, "<h3>" rather than the default "h4")
664 * @param integer The number of an icon to show with the header (see the icon-function). -1,1,2,3
665 * @return string HTML content
666 * @see icons(), sectionHeader()
667 */
668 function section($label,$text,$nostrtoupper=0,$sH=0,$type=0) {
669 $str="";
670
671 // Setting header
672 if ($label) $str.=$this->sectionHeader($this->icons($type).($nostrtoupper ? $label : t3lib_div::danish_strtoupper($label)), $sH);
673 // Setting content
674 $str.='
675
676 <!-- Section content -->
677 '.$text;
678
679 return $this->sectionBegin().$str;
680 }
681
682 /**
683 * Inserts a divider image
684 * Ends a section (if open) before inserting the image
685 *
686 * @param integer The padding-top/-bottom of the <hr> ruler.
687 * @return string HTML content
688 */
689 function divider($dist) {
690 $dist = intval($dist);
691 $str='
692
693 <!-- DIVIDER -->
694 <hr style="padding-top: '.$dist.'px; padding-bottom: '.$dist.'px;" />
695 ';
696 return $this->sectionEnd().$str;
697 }
698
699 /**
700 * Returns a blank <div>-section with a height
701 *
702 * @param integer Padding-top for the div-section
703 * @return string HTML content
704 */
705 function spacer($dist) {
706 if ($dist>0) {
707 return '
708
709 <!-- Spacer element -->
710 <div style="padding-top: '.intval($dist).'px;"></div>
711 ';
712 }
713 }
714
715 /**
716 * Make a section header.
717 * Begins a section if not already open.
718 *
719 * @param string The label between the <h3> or <h4> tags
720 * @param boolean If set, <h3> is used, otherwise <h4>
721 * @return string HTML content
722 */
723 function sectionHeader($label,$sH=0) {
724 $tag = ($sH?'h3':'h4');
725 $str='
726
727 <!-- Section header -->
728 <'.$tag.'>'.$label.'</'.$tag.'>
729 ';
730 return $this->sectionBegin().$str;
731 }
732
733 /**
734 * Begins an output section.
735 * Returns the <div>-begin tag AND sets the ->sectionFlag true (if the ->sectionFlag is not already set!)
736 * You can call this function even if a section is already begun since the function will only return something if the sectionFlag is not already set!
737 *
738 * @return string HTML content
739 */
740 function sectionBegin() {
741 if (!$this->sectionFlag) {
742 $this->sectionFlag=1;
743 $str='
744
745 <!-- ***********************
746 Begin output section.
747 *********************** -->
748 <div>
749 ';
750 return $str;
751 } else return '';
752 }
753
754 /**
755 * Ends and output section
756 * Returns the </div>-end tag AND clears the ->sectionFlag (but does so only IF the sectionFlag is set - that is a section is 'open')
757 * See sectionBegin() also.
758 *
759 * @return string HTML content
760 */
761 function sectionEnd() {
762 if ($this->sectionFlag) {
763 $this->sectionFlag=0;
764 return '
765 </div>
766 <!-- *********************
767 End output section.
768 ********************* -->
769 ';
770 } else return '';
771 }
772
773 /**
774 * Originally it printed a kind of divider.
775 * Depreciated. Just remove function calls to it or call the divider() function instead.
776 *
777 * @return void
778 * @internal
779 * @depreciated
780 */
781 function middle() {
782 }
783
784 /**
785 * If a form-tag is defined in ->form then and end-tag for that <form> element is outputted
786 * Further a JavaScript section is outputted which will update the top.busy session-expiry object (unless $this->endJS is set to false)
787 *
788 * @return string
789 */
790 function endPageJS() {
791 return ($this->endJS?'
792 <script type="text/javascript">
793 /*<![CDATA[*/
794 if (top.busy && top.busy.loginRefreshed) {
795 top.busy.loginRefreshed();
796 }
797 /*]]>*/
798 </script>':'');
799 }
800
801 /**
802 * Creates the bodyTag.
803 *
804 * You can add to the bodyTag by $this->bodyTagAdditions
805 * Background color is set by $this->bgColor
806 * The array $this->bodyTagMargins is used to set left/top margins
807 * $this->getBackgroundImage() fetches background image if applicable.
808 *
809 * @return string HTML body tag
810 */
811 function docBodyTagBegin() {
812 // topmargin="'.$this->bodyTagMargins["y"].'" leftmargin="'.$this->bodyTagMargins["x"].'" marginwidth="'.$this->bodyTagMargins["x"].'" marginheight="'.$this->bodyTagMargins["y"].'"
813 $bodyContent = 'body '.trim($this->bodyTagAdditions).' '; // $this->getBackgroundImage()
814 return '<'.trim($bodyContent).'>';
815 }
816
817 /**
818 * Outputting document style
819 *
820 * @return string HTML style section/link tags
821 */
822 function docStyle() {
823 // The default color scheme should also in full be represented in the stylesheet.
824 $style='
825 '.($this->styleSheetFile?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile.'" />':'').'
826 '.($this->styleSheetFile2?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile2.'" />':'').'
827 <style type="text/css" id="internalStyle">
828 /*<![CDATA[*/
829 A:hover {color: '.$this->hoverColor.'}
830 H2 {background-color: '.$this->bgColor2.';}
831 H3 {background-color: '.$this->bgColor6.';}
832 BODY {background-color: '.$this->bgColor.';'.$this->getBackgroundImage(1).'}
833 '.$this->inDocStyles.'
834 /*]]>*/
835 </style>
836 ';
837 return $style;
838 }
839
840 /**
841 * Returns the 'background' attribute for the bodytag if the TBE_STYLES[background] value is set (must be relative to PATH_typo3)
842 *
843 * @param boolean If set, a background image is referred to with the CSS property "background-image" instead of the body-tag property "background"
844 * @return string
845 */
846 function getBackgroundImage($CSS=0) {
847 return ($this->backGroundImage
848 ? ($CSS ? ' background-image: url('.$this->backPath.$this->backGroundImage.');' : ' background="'.$this->backPath.$this->backGroundImage.'"')
849 :'');
850 }
851
852 /**
853 * Initialize the charset.
854 * Sets the internal $this->charset variable to the charset defined in $GLOBALS["LANG"] (or the default as set in this class)
855 * Returns the meta-tag for the document header
856 *
857 * @return string <meta> tag with charset from $this->charset or $GLOBALS['LANG']->charSet
858 */
859 function initCharset() {
860 // Set charset to the charset provided by the current backend users language selection:
861 $this->charset = $GLOBALS['LANG']->charSet ? $GLOBALS['LANG']->charSet : $this->charset;
862 // Return meta tag:
863 return '<meta http-equiv="Content-Type" content="text/html; charset='.$this->charset.'" />';
864 }
865
866 /**
867 * Returns generator meta tag
868 *
869 * @return string <meta> tag with name "GENERATOR"
870 */
871 function generator() {
872 $str = 'TYPO3 '.$GLOBALS['TYPO_VERSION'].', http://typo3.com, &#169; Kasper Sk&#229;rh&#248;j 1998-2003, extensions are copyright of their respective owners.';
873 return '<meta name="GENERATOR" content="'.$str .'" />';
874 }
875
876
877
878
879
880
881
882
883 /*****************************************
884 *
885 * OTHER ELEMENTS
886 * Tables, buttons, formatting dimmed/red strings
887 *
888 ******************************************/
889
890
891 /**
892 * Returns an image-tag with an 18x16 icon of the following types:
893 *
894 * $type:
895 * -1: OK icon (Check-mark)
896 * 1: Notice (Speach-bubble)
897 * 2: Warning (Yellow triangle)
898 * 3: Fatal error (Red stop sign)
899 *
900 * @param integer See description
901 * @return return HTML image tag (if applicable)
902 */
903 function icons($type) {
904 switch($type) {
905 case '3':
906 $icon = 'gfx/icon_fatalerror.gif';
907 break;
908 case '2':
909 $icon = 'gfx/icon_warning.gif';
910 break;
911 case '1':
912 $icon = 'gfx/icon_note.gif';
913 break;
914 case '-1':
915 $icon = 'gfx/icon_ok.gif';
916 break;
917 default:
918 break;
919 }
920 if ($icon) {
921 return '<img src="'.$this->backPath.$icon.'" width="18" height="16" align="absmiddle" alt="" />';
922 }
923 }
924
925 /**
926 * Returns an <input> button with the $onClick action and $label
927 *
928 * @param string The value of the onclick attribute of the input tag (submit type)
929 * @param string The label for the button (which will be htmlspecialchar'ed)
930 * @return string A <input> tag of the type "submit"
931 */
932 function t3Button($onClick,$label) {
933 $button = '<input type="submit" onclick="'.htmlspecialchars($onClick).'; return false;" value="'.htmlspecialchars($label).'" style="padding: 0 0 0 0; margin: 0 0 0 0; height:18px;" />';
934 return $button;
935 }
936
937 /**
938 * dimmed-fontwrap. Returns the string wrapped in a <span>-tag defining the color to be gray/dimmed
939 *
940 * @param string Input string
941 * @return string Output string
942 */
943 function dfw($string) {
944 return '<span class="typo3-dimmed">'.$string.'</span>';
945 }
946
947 /**
948 * red-fontwrap. Returns the string wrapped in a <span>-tag defining the color to be red
949 *
950 * @param string Input string
951 * @return string Output string
952 */
953 function rfw($string) {
954 return '<span class="typo3-red">'.$string.'</span>';
955 }
956
957 /**
958 * Returns string wrapped in CDATA "tags" for XML / XHTML (wrap content of <script> and <style> sections in those!)
959 *
960 * @param string Input string
961 * @return string Output string
962 */
963 function wrapInCData($string) {
964 $string = '/*<![CDATA[*/'.
965 $string.
966 '/*]]>*/';
967
968 return $string;
969 }
970
971 /**
972 * Wraps the input string in script tags.
973 *
974 * @param string Input string
975 * @return string Output string
976 */
977 function wrapScriptTags($string) {
978 $string = '
979 <script type="text/javascript">
980 /*<![CDATA[*/
981 '.$string.'
982 /*]]>*/
983 </script>
984 ';
985 return trim($string);
986 }
987
988 // These vars defines the layout for the table produced by the table() function.
989 // You can override these values from outside if you like.
990 var $tableLayout = Array (
991 'defRow' => Array (
992 'defCol' => Array('<TD valign="top">','</td>')
993 )
994 );
995 var $table_TR = '<tr>';
996 var $table_TABLE = '<table border="0" cellspacing="0" cellpadding="0">';
997
998 /**
999 * Returns a table based on the input $arr
1000 *
1001 * @param array Multidim array with first levels = rows, second levels = cells
1002 * @return string The HTML table.
1003 * @internal
1004 */
1005 function table($arr) {
1006 if (is_array($arr)) {
1007 reset($arr);
1008 $code='';
1009 $rc=0;
1010 while(list(,$val)=each($arr)) {
1011 if ($rc % 2) {
1012 $layout = is_array($this->tableLayout['defRowOdd']) ? $this->tableLayout['defRowOdd'] : $this->tableLayout['defRow'];
1013 } else {
1014 $layout = is_array($this->tableLayout['defRowEven']) ? $this->tableLayout['defRowEven'] : $this->tableLayout['defRow'];
1015 }
1016 $layout = is_array($this->tableLayout[$rc]) ? $this->tableLayout[$rc] : $layout;
1017 $code_td='';
1018 if (is_array($val)) {
1019 $cc=0;
1020 while(list(,$content)=each($val)) {
1021 $wrap= is_array($layout[$cc]) ? $layout[$cc] : $layout['defCol'];
1022 $code_td.=$wrap[0].$content.$wrap[1];
1023 $cc++;
1024 }
1025 }
1026 $trWrap = is_array($layout['tr']) ? $layout['tr'] : array($this->table_TR, '</tr>');
1027 $code.=$trWrap[0].$code_td.$trWrap[1];
1028 $rc++;
1029 }
1030 $tableWrap = is_array($this->tableLayout['table']) ? $this->tableLayout['table'] : array($this->table_TABLE, '</table>');
1031 $code=$tableWrap[0].$code.$tableWrap[1];
1032 }
1033 return $code;
1034 }
1035
1036 /**
1037 * Constructs a table with content from the $arr1, $arr2 and $arr3.
1038 * Used in eg. ext/belog/mod/index.php - refer to that for examples
1039 *
1040 * @param array
1041 * @param array
1042 * @param array
1043 * @return string HTML content, <table>...</table>
1044 */
1045 function menuTable($arr1,$arr2=array(), $arr3=array()) {
1046 $rows = max(array(count($arr1),count($arr2),count($arr3)));
1047
1048 $menu='
1049 <table border="0" cellpadding="0" cellspacing="0">';
1050 for($a=0;$a<$rows;$a++) {
1051 $menu.='<tr>';
1052 $cls=array();
1053 $valign='middle';
1054 $cls[]='<td valign="'.$valign.'">'.$arr1[$a][0].'&nbsp;</td><td>'.$arr1[$a][1].'</td>';
1055 if (count($arr2)) {
1056 $cls[]='<td valign="'.$valign.'">'.$arr2[$a][0].'&nbsp;</td><td>'.$arr2[$a][1].'</td>';
1057 if (count($arr3)) {
1058 $cls[]='<td valign="'.$valign.'">'.$arr3[$a][0].'&nbsp;</td><td>'.$arr3[$a][1].'</td>';
1059 }
1060 }
1061 $menu.=implode($cls,'<td>&nbsp;&nbsp;</td>');
1062 $menu.='</tr>';
1063 }
1064 $menu.='
1065 </table>
1066 ';
1067 return $menu;
1068 }
1069
1070 /**
1071 * Returns a one-row/two-celled table with $content and $menu side by side.
1072 * The table is a 100% width table and each cell is aligned left / right
1073 *
1074 * @param string Content cell content (left)
1075 * @param string Menu cell content (right)
1076 * @return string HTML output
1077 */
1078 function funcMenu($content,$menu) {
1079 return '<table border="0" cellpadding="0" cellspacing="0" width="100%">
1080 <tr><td valign="top" nowrap="nowrap">'.$content.'</td><td valign="top" align="right" nowrap="nowrap">'.$menu.'</td></tr>
1081 </table>';
1082 }
1083
1084 /**
1085 * Creates a selector box with clear-cache items.
1086 * Rather specialized functions - at least don't use it with $addSaveOptions unless you know what you do...
1087 *
1088 * @param integer The page uid of the "current page" - the one that will be cleared as "clear cache for this page".
1089 * @param boolean If $addSaveOptions is set, then also the array of save-options for TCE_FORMS will appear.
1090 * @return string <select> tag with content - a selector box for clearing the cache
1091 */
1092 function clearCacheMenu($id,$addSaveOptions=0) {
1093 global $BE_USER;
1094 $opt=$addOptions;
1095 if ($addSaveOptions) {
1096 $opt[]='<option value="">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.menu',1).'</option>';
1097 $opt[]='<option value="TBE_EDITOR_checkAndDoSubmit(1);">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc',1).'</option>';
1098 $opt[]='<option value="document.editform.closeDoc.value=-2; TBE_EDITOR_checkAndDoSubmit(1);">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseDoc',1).'</option>';
1099 if ($BE_USER->uc['allSaveFunctions']) $opt[]='<option value="document.editform.closeDoc.value=-3; TBE_EDITOR_checkAndDoSubmit(1);">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseAllDocs',1).'</option>';
1100 $opt[]='<option value="document.editform.closeDoc.value=2; document.editform.submit();">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc',1).'</option>';
1101 $opt[]='<option value="document.editform.closeDoc.value=3; document.editform.submit();">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeAllDocs',1).'</option>';
1102 $opt[]='<option value=""></option>';
1103 }
1104 $opt[]='<option value="">[ '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_clearCache',1).' ]</option>';
1105 if ($id) $opt[]='<option value="'.$id.'">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_thisPage',1).'</option>';
1106 if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.clearCache.pages')) $opt[]='<option value="pages">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_pages',1).'</option>';
1107 if ($BE_USER->isAdmin() || $BE_USER->getTSConfigVal('options.clearCache.all')) $opt[]='<option value="all">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_all',1).'</option>';
1108 $af_content = '<select name="cacheCmd" onchange="
1109 if (!this.options[this.selectedIndex].value) {
1110 this.selectedIndex=0;
1111 } else if (this.options[this.selectedIndex].value.indexOf(\';\')!=-1) {
1112 eval(this.options[this.selectedIndex].value);
1113 }else{
1114 document.location=\''.$this->backPath.'tce_db.php?vC='.$BE_USER->veriCode().'&redirect='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')).'&cacheCmd=\'+this.options[this.selectedIndex].value;
1115 }">'.implode("",$opt).'</select>';
1116 if (count($opt)>2) {
1117 return $af_content;
1118 }
1119 }
1120
1121 /**
1122 * Returns an array with parts (JavaScript, init-functions, <div>-layers) for use on pages which displays the clickmenu layers (context sensitive menus)
1123 *
1124 * @return array If values are present: [0] = A <script> section for the HTML page header, [1] = onmousemove/onload handler for HTML tag or alike, [2] = Two empty <div> layers for the context menu
1125 */
1126 function getContextMenuCode() {
1127 if ($this->isCMlayers()) {
1128 $content='
1129 <script type="text/javascript">
1130 /*<![CDATA[*/
1131 var GLV_gap=10;
1132 var GLV_curLayerX=new Array(0,0);
1133 var GLV_curLayerY=new Array(0,0);
1134 var GLV_curLayerWidth=new Array(0,0);
1135 var GLV_curLayerHeight=new Array(0,0);
1136 var GLV_isVisible=new Array(0,0);
1137 var GLV_x=0;
1138 var GLV_y=0;
1139 var layerObj=new Array();
1140 var layerObjCss=new Array();
1141
1142 //browsercheck...
1143 function GL_checkBrowser(){
1144 this.dom= (document.getElementById);
1145 this.op= (navigator.userAgent.indexOf("Opera")>-1);
1146 this.op7= this.op && (navigator.appVersion.indexOf("7")>-1); // check for Opera version 7
1147 this.konq= (navigator.userAgent.indexOf("Konq")>-1);
1148 this.ie4= (document.all && !this.dom && !this.op && !this.konq);
1149 this.ie5= (document.all && this.dom && !this.op && !this.konq);
1150 this.ns4= (document.layers && !this.dom && !this.konq);
1151 this.ns5= (!document.all && this.dom && !this.op && !this.konq);
1152 this.ns6= (this.ns5);
1153 this.bw= (this.ie4 || this.ie5 || this.ns4 || this.ns6 || this.op || this.konq);
1154 return this;
1155 }
1156 bw= new GL_checkBrowser();
1157
1158 // GL_getObj(obj)
1159 function GL_getObj(obj){
1160 nest="";
1161 this.el= (bw.ie4||bw.op7)?document.all[obj]:bw.ns4?eval(nest+"document."+obj):document.getElementById(obj);
1162 this.css= bw.ns4?this.el:this.el.style;
1163 this.ref= bw.ns4?this.el.document:document;
1164 this.x= (bw.ns4||bw.op)?this.css.left:this.el.offsetLeft;
1165 this.y= (bw.ns4||bw.op)?this.css.top:this.el.offsetTop;
1166 this.height= (bw.ie4||bw.ie5||bw.ns6||this.konq||bw.op7)?this.el.offsetHeight:bw.ns4?this.ref.height:bw.op?this.css.pixelHeight:0;
1167 this.width= (bw.ie4||bw.ie5||bw.ns6||this.konq||bw.op7)?this.el.offsetWidth:bw.ns4?this.ref.width:bw.op?this.css.pixelWidth:0;
1168 return this;
1169 }
1170 // GL_getObjCss(obj)
1171 function GL_getObjCss(obj){
1172 return bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?document.layers[obj]:0;
1173 }
1174 // GL_getMouse(event)
1175 function GL_getMouse(event) {
1176 if (layerObj) {
1177 GLV_x= (bw.ns4||bw.ns5)?event.pageX:(bw.ie4||bw.op)?event.clientX:(event.clientX-2)+document.body.scrollLeft;
1178 GLV_y= (bw.ns4||bw.ns5)?event.pageY:(bw.ie4||bw.op)?event.clientY:(event.clientY-2)+document.body.scrollTop;
1179
1180 // status = (GLV_x+GLV_gap-GLV_curLayerX[0]) + " | " + (GLV_y+GLV_gap-GLV_curLayerY[0]);
1181 if (GLV_isVisible[1]) {
1182 if (outsideLayer(1)) hideSpecific(1);
1183 } else if (GLV_isVisible[0]) {
1184 if (outsideLayer(0)) hideSpecific(0);
1185 }
1186 }
1187 }
1188 // outsideLayer(level)
1189 function outsideLayer(level) {
1190 return GLV_x+GLV_gap-GLV_curLayerX[level] <0 ||
1191 GLV_y+GLV_gap-GLV_curLayerY[level] <0 ||
1192 GLV_curLayerX[level]+GLV_curLayerWidth[level]+GLV_gap-GLV_x <0 ||
1193 GLV_curLayerY[level]+GLV_curLayerHeight[level]+GLV_gap-GLV_y <0;
1194 }
1195 // setLayerObj(html,level)
1196 function setLayerObj(html,level) {
1197 var tempLayerObj = GL_getObj("contentMenu"+level);
1198 var tempLayerObjCss = GL_getObjCss("contentMenu"+level);
1199
1200 if (tempLayerObj && (level==0 || GLV_isVisible[level-1])) {
1201 tempLayerObj.el.innerHTML = html;
1202 tempLayerObj.height= (bw.ie4||bw.ie5||bw.ns6||bw.konq||bw.op7)?this.el.offsetHeight:bw.ns4?this.ref.height:bw.op?this.css.pixelHeight:0;
1203 tempLayerObj.width= (bw.ie4||bw.ie5||bw.ns6||bw.konq||bw.op7)?this.el.offsetWidth:bw.ns4?this.ref.width:bw.op?this.css.pixelWidth:0;
1204
1205 tempLayerObjCss.left = GLV_curLayerX[level] = GLV_x;
1206 tempLayerObjCss.top = GLV_curLayerY[level] = GLV_y;
1207 tempLayerObjCss.visibility = "visible";
1208
1209 GLV_isVisible[level]=1;
1210 GLV_curLayerWidth[level] = tempLayerObj.width;
1211 GLV_curLayerHeight[level] = tempLayerObj.height;
1212 }
1213 }
1214 // hideEmpty()
1215 function hideEmpty() {
1216 hideSpecific(0);
1217 hideSpecific(1);
1218 return false;
1219 }
1220 // hideSpecific(level)
1221 function hideSpecific(level) {
1222 GL_getObjCss("contentMenu"+level).visibility = "hidden";
1223 GL_getObj("contentMenu"+level).el.innerHTML = "";
1224 GLV_isVisible[level]=0;
1225 }
1226 // debugObj(obj,name)
1227 function debugObj(obj,name) {
1228 var acc;
1229 for (i in obj) {if (obj[i]) {acc+=i+": "+obj[i]+"\n";}}
1230 alert("Object: "+name+"\n\n"+acc);
1231 }
1232 // initLayer()
1233 function initLayer(){
1234 if (document.all) {
1235 window.onmousemove=GL_getMouse;
1236 }
1237 layerObj = GL_getObj("contentMenu1");
1238 layerObjCss = GL_getObjCss("contentMenu1");
1239 }
1240 /*]]>*/
1241 </script>
1242 ';
1243 return array(
1244 $content,
1245 ' onmousemove="GL_getMouse(event);" onload="initLayer();"',
1246 '<div id="contentMenu0" style="z-index:1; position:absolute;visibility:hidden"></div><div id="contentMenu1" style="z-index:2; position:absolute;visibility:hidden"></div>'
1247 );
1248 } else return array('','','');
1249 }
1250 }
1251
1252
1253
1254 // ******************************
1255 // Extension classes of the template class.
1256 // These are meant to provide backend screens with different widths.
1257 // They still do because of the different class-prefixes used for the <div>-sections
1258 // but obviously the final width is determined by the stylesheet used.
1259 // ******************************
1260
1261 /**
1262 * Extension class for "template" - used for backend pages which are wide. Typically modules taking up all the space in the "content" frame of the backend
1263 * The class were more significant in the past than today.
1264 *
1265 */
1266 class bigDoc extends template {
1267 var $divClass = 'typo3-bigDoc';
1268 }
1269
1270 /**
1271 * Extension class for "template" - used for backend pages without the "document" background image
1272 * The class were more significant in the past than today.
1273 *
1274 */
1275 class noDoc extends template {
1276 var $divClass = 'typo3-noDoc';
1277 }
1278
1279 /**
1280 * Extension class for "template" - used for backend pages which were narrow (like the Web>List modules list frame. Or the "Show details" pop up box)
1281 * The class were more significant in the past than today.
1282 *
1283 */
1284 class smallDoc extends template {
1285 var $divClass = 'typo3-smallDoc';
1286 }
1287
1288 /**
1289 * Extension class for "template" - used for backend pages which were medium wide. Typically submodules to Web or File which were presented in the list-frame when the content frame were divided into a navigation and list frame.
1290 * The class were more significant in the past than today. But probably you should use this one for most modules you make.
1291 *
1292 */
1293 class mediumDoc extends template {
1294 var $divClass = 'typo3-mediumDoc';
1295 }
1296
1297
1298
1299 // Include extension to the template class?
1300 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/template.php']) {
1301 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/template.php']);
1302 }
1303
1304
1305
1306 // ******************************************************
1307 // The backend language engine is started (ext: "lang")
1308 // ******************************************************
1309 require_once(PATH_typo3.'sysext/lang/lang.php');
1310 $LANG = t3lib_div::makeInstance('language');
1311 $LANG->init($BE_USER->uc['lang']);
1312
1313
1314
1315 // ******************************
1316 // The template is loaded
1317 // ******************************
1318 $TBE_TEMPLATE = t3lib_div::makeInstance('template');
1319 ?>