Added Tab Menu and the possiblity to use head and JS code from extobj-modules
[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 $JScodeArray=array(); // Similar to $JScode but for use as array with assioziative keys to prevent double inclusion of JS code. a <script> tag is automatically wrapped around.
172 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.
173 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'.
174
175 // Other vars you can change, but less frequently used:
176 var $bodyTagAdditions=''; // You can add additional attributes to the body-tag through this variable.
177 var $inDocStyles=''; // Additional CSS styles which will be added to the <style> section in the header
178 var $inDocStylesArray=array(); // Like $inDocStyles but for use as array with assioziative keys to prevent double inclusion of css code
179 var $form_rowsToStylewidth = 9.58; // Multiplication factor for formWidth() input size (default is 48* this value).
180 var $form_largeComp = 1.33; // Compensation for large documents (used in class.t3lib_tceforms.php)
181 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.
182
183 // TYPO3 Colorscheme.
184 // If you want to change this, please do so through a skin using the global var $TBE_STYLES
185 var $bgColor = '#F7F3EF'; // Light background color
186 var $bgColor2 = '#9BA1A8'; // Steel-blue
187 var $bgColor3 = '#F6F2E6'; // dok.color
188 var $bgColor4 = '#D9D5C9'; // light tablerow background, brownish
189 var $bgColor5 = '#ABBBB4'; // light tablerow background, greenish
190 var $bgColor6 = '#E7DBA8'; // light tablerow background, yellowish, for section headers. Light.
191 var $hoverColor = '#254D7B';
192 var $styleSheetFile = 'stylesheet.css'; // Filename of stylesheet (relative to PATH_typo3)
193 var $styleSheetFile2 = ''; // Filename of stylesheet #2 - linked to right after the $this->styleSheetFile script (relative to PATH_typo3)
194 var $backGroundImage = ''; // Background image of page (relative to PATH_typo3)
195
196 // DEV:
197 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.
198
199 // INTERNAL
200 var $charset = 'iso-8859-1'; // Default charset. see function initCharset()
201
202 var $sectionFlag=0; // Internal: Indicates if a <div>-output section is open
203 var $divClass="typo3-def"; // (Default) Class for wrapping <DIV>-tag of page. Is set in class extensions.
204
205 /**
206 * Constructor
207 * Imports relevant parts from global $TBE_STYLES (colorscheme)
208 *
209 * @return void
210 */
211 function template() {
212 global $TBE_STYLES;
213
214 // Color scheme:
215 if ($TBE_STYLES['mainColors']['bgColor']) $this->bgColor=$TBE_STYLES['mainColors']['bgColor'];
216 if ($TBE_STYLES['mainColors']['bgColor1']) $this->bgColor1=$TBE_STYLES['mainColors']['bgColor1'];
217 if ($TBE_STYLES['mainColors']['bgColor2']) $this->bgColor2=$TBE_STYLES['mainColors']['bgColor2'];
218 if ($TBE_STYLES['mainColors']['bgColor3']) $this->bgColor3=$TBE_STYLES['mainColors']['bgColor3'];
219 if ($TBE_STYLES['mainColors']['bgColor4']) $this->bgColor4=$TBE_STYLES['mainColors']['bgColor4'];
220 if ($TBE_STYLES['mainColors']['bgColor5']) $this->bgColor5=$TBE_STYLES['mainColors']['bgColor5'];
221 if ($TBE_STYLES['mainColors']['bgColor6']) $this->bgColor6=$TBE_STYLES['mainColors']['bgColor6'];
222 if ($TBE_STYLES['mainColors']['hoverColor']) $this->hoverColor=$TBE_STYLES['mainColors']['hoverColor'];
223
224 // Stylesheet:
225 if ($TBE_STYLES['stylesheet']) $this->styleSheetFile = $TBE_STYLES['stylesheet'];
226 if ($TBE_STYLES['stylesheet2']) $this->styleSheetFile2 = $TBE_STYLES['stylesheet2'];
227
228 // Background image
229 if ($TBE_STYLES['background']) $this->backGroundImage = $TBE_STYLES['background'];
230 }
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247 /*****************************************
248 *
249 * EVALUATION FUNCTIONS
250 * Various centralized processing
251 *
252 *****************************************/
253
254 /**
255 * Makes click menu link (context sensitive menu)
256 * 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)
257 * 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)
258 *
259 * @param string String to be wrapped in link, typ. image tag.
260 * @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
261 * @param integer If icon is for database record this is the UID for the record from $table
262 * @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.
263 * @return string The link-wrapped input string.
264 */
265 function wrapClickMenuOnIcon($str,$table,$uid='',$listFr=1) {
266 $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;';
267 return '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.$str.'</a>';
268 }
269
270 /**
271 * Makes link to page $id in frontend (view page)
272 * Returns an magnifier-glass icon which links to the frontend index.php document for viewing the page with id $id
273 * $id must be a page-uid
274 * If the BE_USER has access to Web>List then a link to that module is shown as well (with return-url)
275 *
276 * @param integer The page id
277 * @param string The current "BACK_PATH" (the back relative to the typo3/ directory)
278 * @param string Additional parameters for the image tag(s)
279 * @return string HTML string with linked icon(s)
280 */
281 function viewPageIcon($id,$backPath,$addParams='hspace="3"') {
282 global $BE_USER;
283 $str = '';
284 // If access to Web>List for user, then link to that module.
285 if ($BE_USER->check('modules','web_list')) {
286 $href=$backPath.'db_list.php?id='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
287 $str.= '<a href="'.htmlspecialchars($href).'">'.
288 '<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="" />'.
289 '</a>';
290 }
291 // Make link to view page
292 $str.= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($id,$backPath,t3lib_BEfunc::BEgetRootLine($id))).'">'.
293 '<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="" />'.
294 '</a>';
295 return $str;
296 }
297
298 /**
299 * Returns a URL with a command to TYPO3 Core Engine (tce_db.php)
300 * See description of the API elsewhere.
301 *
302 * @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"
303 * @param string Redirect URL if any other that t3lib_div::getIndpEnv('REQUEST_URI') is wished
304 * @return string URL to tce_db.php + parameters (backpath is taken from $this->backPath)
305 */
306 function issueCommand($params,$rUrl='') {
307 $rUrl = $rUrl ? $rUrl : t3lib_div::getIndpEnv('REQUEST_URI');
308 return $this->backPath.'tce_db.php?'.
309 $params.
310 '&redirect='.($rUrl==-1?"'+T3_THIS_LOCATION+'":rawurlencode($rUrl)).
311 '&vC='.rawurlencode($GLOBALS['BE_USER']->veriCode()).
312 '&prErr=1&uPT=1';
313 }
314
315 /**
316 * Returns true if click-menu layers can be displayed for the current user/browser
317 * Use this to test if click-menus (context sensitive menus) can and should be displayed in the backend.
318 *
319 * @return boolean
320 */
321 function isCMlayers() {
322 return !$GLOBALS['BE_USER']->uc['disableCMlayers'] && $GLOBALS['CLIENT']['FORMSTYLE'] && $GLOBALS['CLIENT']['SYSTEM']!='mac';
323 }
324
325 /**
326 * Returns 'this.blur();' if the client supports CSS styles
327 * Use this in links to remove the underlining after being clicked
328 *
329 * @return string
330 */
331 function thisBlur() {
332 return ($GLOBALS['CLIENT']['FORMSTYLE']?'this.blur();':'');
333 }
334
335 /**
336 * Returns ' style='cursor:help;'' if the client supports CSS styles
337 * Use for <a>-links to help texts
338 *
339 * @return string
340 */
341 function helpStyle() {
342 return $GLOBALS['CLIENT']['FORMSTYLE'] ? ' style="cursor:help;"':'';
343 }
344
345 /**
346 * Makes the header (icon+title) for a page (or other record). Used in most modules under Web>*
347 * $table and $row must be a tablename/record from that table
348 * $path will be shown as alt-text for the icon.
349 * The title will be truncated to 45 chars.
350 *
351 * @param string Table name
352 * @param array Record row
353 * @param string Alt text
354 * @param boolean Set $noViewPageIcon true if you don't want a magnifier-icon for viewing the page in the frontend
355 * @param array $tWrap is an array with indexes 0 and 1 each representing HTML-tags (start/end) which will wrap the title
356 * @return string HTML content
357 */
358 function getHeader($table,$row,$path,$noViewPageIcon=0,$tWrap=array('','')) {
359 global $TCA;
360 if (is_array($row)) {
361 $iconfile=t3lib_iconWorks::getIcon($table,$row);
362 $title= strip_tags($row[$TCA[$table]['ctrl']['label']]);
363 $viewPage = $noViewPageIcon ? '' : $this->viewPageIcon($row['uid'],$this->backPath,'align="top" vspace="2"');
364 if ($table=='pages') $path.=' - '.t3lib_BEfunc::titleAttribForPages($row,'',0);
365 } else {
366 $iconfile='gfx/i/_icon_website.gif';
367 $title=$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
368 }
369 return $this->wrapClickMenuOnIcon('<img src="'.$this->backPath.$iconfile.'" width="18" height="16" border="0" title="'.htmlspecialchars($path).'" align="top" alt="" />',$table,$row['uid']).
370 $viewPage.
371 '&nbsp;<b>'.$tWrap[0].htmlspecialchars(t3lib_div::fixed_lgd($title,45)).$tWrap[1].'</b>';
372 }
373
374 /**
375 * Like ->getHeader() but for files in the File>* main module/submodules
376 * Returns the file-icon with the path of the file set in the alt/title attribute. Shows the file-name after the icon.
377 *
378 * @param string Title string, expected to be the filepath
379 * @param string Alt text
380 * @param string The icon file (relative to TYPO3 dir)
381 * @return string HTML content
382 */
383 function getFileheader($title,$path,$iconfile) {
384 $fileInfo = t3lib_div::split_fileref($title);
385 $title=htmlspecialchars($fileInfo['path']).'<b>'.htmlspecialchars($fileInfo['file']).'</b>';
386 $title=t3lib_div::fixed_lgd_pre($title,45);
387 return '<img src="'.$this->backPath.$iconfile.'" width="18" height="16" border="0" title="'.htmlspecialchars($path).'" align="top" alt="" />&nbsp;'.$title;
388 }
389
390 /**
391 * Returns a linked shortcut-icon which will call the shortcut frame and set a shortcut there back to the calling page/module
392 *
393 * @param string Is the list of GET variables to store (if any)
394 * @param string Is the list of SET[] variables to store (if any) - SET[] variables a stored in $GLOBALS["SOBE"]->MOD_SETTINGS for backend modules
395 * @param string Module name string
396 * @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.
397 * @return string HTML content
398 */
399 function makeShortcutIcon($gvList,$setList,$modName,$motherModName="") {
400 $backPath=$this->backPath;
401 $storeUrl=$this->makeShortcutUrl($gvList,$setList);
402 $pathInfo = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
403
404 if (!strcmp($motherModName,'1')) {
405 $mMN="&motherModName='+top.currentModuleLoaded+'";
406 } elseif ($motherModName) {
407 $mMN='&motherModName='.rawurlencode($motherModName);
408 } else $mMN="";
409
410 $onClick = 'if (top.shortcutFrame && confirm('.
411 $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.makeShortcut')).
412 ')){top.shortcutFrame.document.location=\''.$backPath.'alt_shortcut.php?modName='.rawurlencode($modName).
413 '&URL='.rawurlencode($pathInfo['path']."?".$storeUrl).
414 $mMN.
415 '\';}return false;';
416
417 $sIcon = '<a href="#" onclick="'.htmlspecialchars($onClick).'">
418 <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>';
419 return $sIcon;
420 }
421
422 /**
423 * MAKE url for storing
424 * Internal func
425 *
426 * @param Is the list of GET variables to store (if any)
427 * @param Is the list of SET[] variables to store (if any) - SET[] variables a stored in $GLOBALS["SOBE"]->MOD_SETTINGS for backend modules
428 * @return string
429 * @access private
430 * @see makeShortcutIcon()
431 */
432 function makeShortcutUrl($gvList,$setList) {
433 global $HTTP_GET_VARS;
434 $storeArray = array_merge(
435 t3lib_div::compileSelectedGetVarsFromArray($gvList,$HTTP_GET_VARS),
436 array('SET'=>t3lib_div::compileSelectedGetVarsFromArray($setList,$GLOBALS['SOBE']->MOD_SETTINGS))
437 );
438 $storeUrl = t3lib_div::implodeArrayForUrl("",$storeArray);
439 return $storeUrl;
440 }
441
442 /**
443 * Returns <input> attributes to set the width of an text-type input field.
444 * For client browsers with no CSS support the cols/size attribute is returned.
445 * For CSS compliant browsers (recommended) a ' style="width: ...px;"' is returned.
446 *
447 * @param integer A relative number which multiplied with approx. 10 will lead to the width in pixels
448 * @param boolean A flag you can set for textareas - DEPRECIATED, use ->formWidthText() for textareas!!!
449 * @param string A string which will be returned as attribute-value for style="" instead of the calculated width (if CSS is enabled)
450 * @return string Tag attributes for an <input> tag (regarding width)
451 * @see formWidthText()
452 */
453 function formWidth($size=48,$textarea=0,$styleOverride='') {
454 $wAttrib = $textarea?'cols':'size';
455 if (!$GLOBALS['CLIENT']['FORMSTYLE']) { // If not setting the width by style-attribute
456 $size = $size;
457 $retVal = ' '.$wAttrib.'="'.$size.'"';
458 } else { // Setting width by style-attribute. 'cols' MUST be avoided with NN6+
459 $pixels = ceil($size*$this->form_rowsToStylewidth);
460 $retVal = $styleOverride ? ' style="'.$styleOverride.'"' : ' style="width:'.$pixels.'px;"';
461 }
462 return $retVal;
463 }
464
465 /**
466 * This function is dedicated to textareas, which has the wrapping on/off option to observe.
467 * EXAMPLE:
468 * <textarea rows="10" wrap="off" '.$GLOBALS["TBE_TEMPLATE"]->formWidthText(48,"","off").'>
469 * or
470 * <textarea rows="10" wrap="virtual" '.$GLOBALS["TBE_TEMPLATE"]->formWidthText(48,"","virtual").'>
471 *
472 * @param integer A relative number which multiplied with approx. 10 will lead to the width in pixels
473 * @param string A string which will be returned as attribute-value for style="" instead of the calculated width (if CSS is enabled)
474 * @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.
475 * @return string Tag attributes for an <input> tag (regarding width)
476 * @see formWidth()
477 */
478 function formWidthText($size=48,$styleOverride='',$wrap='') {
479 $wTags = $this->formWidth($size,1,$styleOverride);
480 // 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...
481 if (strtolower(trim($wrap))!='off' && $GLOBALS['CLIENT']['BROWSER']=='net' && $GLOBALS['CLIENT']['VERSION']>=5) {
482 $wTags.=' cols="'.$size.'"';
483 }
484 return $wTags;
485 }
486
487 /**
488 * Returns JavaScript variables setting the returnUrl and thisScript location for use by JavaScript on the page.
489 * Used in fx. db_list.php (Web>List)
490 *
491 * @param string URL to "this location" / current script
492 * @return string
493 * @see typo3/db_list.php
494 */
495 function redirectUrls($thisLocation='') {
496 $thisLocation = $thisLocation?$thisLocation:t3lib_div::linkThisScript(
497 array(
498 'CB'=>'',
499 'SET'=>'',
500 'cmd' => '',
501 'popViewId'=>''
502 ));
503
504 $out ="
505 var T3_RETURN_URL = '".str_replace('%20','',rawurlencode(t3lib_div::GPvar('returnUrl')))."';
506 var T3_THIS_LOCATION = '".str_replace('%20','',rawurlencode($thisLocation))."';
507 ";
508 return $out;
509 }
510
511 /**
512 * Returns a formatted string of $tstamp
513 * Uses $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] and $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] to format date and time
514 *
515 * @param integer UNIX timestamp, seconds since 1970
516 * @param integer How much data to show: $type = 1: hhmm, $type = 10: ddmmmyy
517 * @return string Formatted timestamp
518 */
519 function formatTime($tstamp,$type) {
520 switch($type) {
521 case 1: return date($GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'],$tstamp); break;
522 case 10: return date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'],$tstamp); break;
523 }
524 }
525
526 /**
527 * Returns script parsetime IF ->parseTimeFlag is set and user is "admin"
528 * Automatically outputted in page end
529 *
530 * @return string
531 */
532 function parseTime() {
533 if ($this->parseTimeFlag && $GLOBALS['BE_USER']->isAdmin()) {
534 return '<p>(ParseTime: '.(t3lib_div::milliseconds()-$GLOBALS['PARSETIME_START']).' ms</p>
535 <p>REQUEST_URI-length: '.strlen(t3lib_div::getIndpEnv('REQUEST_URI')).')</p>';
536 }
537 }
538
539
540
541
542
543
544
545
546
547
548
549
550 /*****************************************
551 *
552 * PAGE BUILDING FUNCTIONS.
553 * Use this to build the HTML of your backend modules
554 *
555 *****************************************/
556
557 /**
558 * Returns page start
559 * This includes the proper header with charset, title, meta tag and beginning body-tag.
560 *
561 * @param string HTML Page title for the header
562 * @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)
563 * @see endPage()
564 */
565 function startPage($title) {
566 $charSet = $this->initCharset();
567 $generator = $this->generator();
568
569 switch($this->docType) {
570 case 'xhtml_strict':
571 $headerStart= '<?xml version="1.0" encoding="'.$this->charset.'"?>
572 <?xml-stylesheet href="#internalStyle" type="text/css"?>
573 <!DOCTYPE html
574 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
575 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
576 break;
577 case 'xhtml_trans':
578 $headerStart= '<?xml version="1.0" encoding="'.$this->charset.'"?>
579 <?xml-stylesheet href="#internalStyle" type="text/css"?>
580 <!DOCTYPE html
581 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
582 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
583 break;
584 case 'xhtml_frames':
585 $headerStart= '<?xml version="1.0" encoding="'.$this->charset.'"?>
586 <!DOCTYPE html
587 PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
588 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
589 break;
590 default:
591 $headerStart='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">';
592 break;
593 }
594
595 // Construct page header.
596 $str = $headerStart.'
597 <html>
598 <head>
599 '.$charSet.'
600 '.$generator.'
601 <title>'.htmlspecialchars($title).'</title>
602 '.$this->docStyle().'
603 '.$this->JScode.'
604 '.$this->wrapScriptTags(implode("\n", $this->JScodeArray)).'
605 <!--###POSTJSMARKER###-->
606 </head>
607 ';
608 $this->JScode='';
609 $this->JScodeArray=array();
610
611 if ($this->docType=='xhtml_frames') {
612 return $str;
613 } else
614 $str.=$this->docBodyTagBegin().
615 ($this->divClass?'
616
617 <!-- Wrapping DIV-section for whole page BEGIN -->
618 <div class="'.$this->divClass.'">':'').
619 trim($this->form);
620 return $str;
621 }
622
623 /**
624 * Returns page end.
625 *
626 * @return string The HTML end of a page
627 * @see startPage()
628 */
629 function endPage() {
630 $str = $this->sectionEnd().
631 $this->postCode.
632 $this->endPageJS().
633 t3lib_BEfunc::getSetUpdateSignal().
634 $this->parseTime().
635 ($this->form?'
636 </form>':'').
637 ($this->divClass?'
638
639 <!-- Wrapping DIV-section for whole page END -->
640 </div>':'').
641 '
642 </body>
643 </html> ';
644 return $str;
645 }
646
647 /**
648 * Returns the header-bar in the top of most backend modules
649 * Closes section if open.
650 *
651 * @param string The text string for the header
652 * @return string HTML content
653 */
654 function header($text) {
655 $str='
656
657 <!-- MAIN Header in page top -->
658 <h2>'.$text.'</h2>
659 ';
660 return $this->sectionEnd().$str;
661 }
662
663 /**
664 * Begins an output section and sets header and content
665 *
666 * @param string The header
667 * @param string The HTML-content
668 * @param boolean A flag that will prevent the header from being converted to uppercase
669 * @param boolean Defines the type of header (if set, "<h3>" rather than the default "h4")
670 * @param integer The number of an icon to show with the header (see the icon-function). -1,1,2,3
671 * @return string HTML content
672 * @see icons(), sectionHeader()
673 */
674 function section($label,$text,$nostrtoupper=0,$sH=0,$type=0) {
675 $str="";
676
677 // Setting header
678 if ($label) $str.=$this->sectionHeader($this->icons($type).($nostrtoupper ? $label : t3lib_div::danish_strtoupper($label)), $sH);
679 // Setting content
680 $str.='
681
682 <!-- Section content -->
683 '.$text;
684
685 return $this->sectionBegin().$str;
686 }
687
688 /**
689 * Inserts a divider image
690 * Ends a section (if open) before inserting the image
691 *
692 * @param integer The margin-top/-bottom of the <hr> ruler.
693 * @return string HTML content
694 */
695 function divider($dist) {
696 $dist = intval($dist);
697 $str='
698
699 <!-- DIVIDER -->
700 <hr style="margin-top: '.$dist.'px; margin-bottom: '.$dist.'px;" />
701 ';
702 return $this->sectionEnd().$str;
703 }
704
705 /**
706 * Returns a blank <div>-section with a height
707 *
708 * @param integer Padding-top for the div-section (should be margin-top but konquorer (3.1) don't like it :-(
709 * @return string HTML content
710 */
711 function spacer($dist) {
712 if ($dist>0) {
713 return '
714
715 <!-- Spacer element -->
716 <div style="padding-top: '.intval($dist).'px;"></div>
717 ';
718 }
719 }
720
721 /**
722 * Make a section header.
723 * Begins a section if not already open.
724 *
725 * @param string The label between the <h3> or <h4> tags
726 * @param boolean If set, <h3> is used, otherwise <h4>
727 * @return string HTML content
728 */
729 function sectionHeader($label,$sH=0) {
730 $tag = ($sH?'h3':'h4');
731 $str='
732
733 <!-- Section header -->
734 <'.$tag.'>'.$label.'</'.$tag.'>
735 ';
736 return $this->sectionBegin().$str;
737 }
738
739 /**
740 * Begins an output section.
741 * Returns the <div>-begin tag AND sets the ->sectionFlag true (if the ->sectionFlag is not already set!)
742 * 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!
743 *
744 * @return string HTML content
745 */
746 function sectionBegin() {
747 if (!$this->sectionFlag) {
748 $this->sectionFlag=1;
749 $str='
750
751 <!-- ***********************
752 Begin output section.
753 *********************** -->
754 <div>
755 ';
756 return $str;
757 } else return '';
758 }
759
760 /**
761 * Ends and output section
762 * Returns the </div>-end tag AND clears the ->sectionFlag (but does so only IF the sectionFlag is set - that is a section is 'open')
763 * See sectionBegin() also.
764 *
765 * @return string HTML content
766 */
767 function sectionEnd() {
768 if ($this->sectionFlag) {
769 $this->sectionFlag=0;
770 return '
771 </div>
772 <!-- *********************
773 End output section.
774 ********************* -->
775 ';
776 } else return '';
777 }
778
779 /**
780 * Originally it printed a kind of divider.
781 * Depreciated. Just remove function calls to it or call the divider() function instead.
782 *
783 * @return void
784 * @internal
785 * @depreciated
786 */
787 function middle() {
788 }
789
790 /**
791 * If a form-tag is defined in ->form then and end-tag for that <form> element is outputted
792 * Further a JavaScript section is outputted which will update the top.busy session-expiry object (unless $this->endJS is set to false)
793 *
794 * @return string
795 */
796 function endPageJS() {
797 return ($this->endJS?'
798 <script type="text/javascript">
799 /*<![CDATA[*/
800 if (top.busy && top.busy.loginRefreshed) {
801 top.busy.loginRefreshed();
802 }
803 /*]]>*/
804 </script>':'');
805 }
806
807 /**
808 * Creates the bodyTag.
809 *
810 * You can add to the bodyTag by $this->bodyTagAdditions
811 * Background color is set by $this->bgColor
812 * The array $this->bodyTagMargins is used to set left/top margins
813 * $this->getBackgroundImage() fetches background image if applicable.
814 *
815 * @return string HTML body tag
816 */
817 function docBodyTagBegin() {
818 // topmargin="'.$this->bodyTagMargins["y"].'" leftmargin="'.$this->bodyTagMargins["x"].'" marginwidth="'.$this->bodyTagMargins["x"].'" marginheight="'.$this->bodyTagMargins["y"].'"
819 $bodyContent = 'body '.trim($this->bodyTagAdditions).' '; // $this->getBackgroundImage()
820 return '<'.trim($bodyContent).'>';
821 }
822
823 /**
824 * Outputting document style
825 *
826 * @return string HTML style section/link tags
827 */
828 function docStyle() {
829 $this->inDocStylesArray[] = $this->inDocStyles;
830 $inDocStyles = "\n".implode("\n", $this->inDocStylesArray);
831
832 // The default color scheme should also in full be represented in the stylesheet.
833 $style='
834 '.($this->styleSheetFile?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile.'" />':'').'
835 '.($this->styleSheetFile2?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile2.'" />':'').'
836 <style type="text/css" id="internalStyle">
837 /*<![CDATA[*/
838 A:hover {color: '.$this->hoverColor.'}
839 H2 {background-color: '.$this->bgColor2.';}
840 H3 {background-color: '.$this->bgColor6.';}
841 BODY {background-color: '.$this->bgColor.';'.$this->getBackgroundImage(1).'}
842 '.$inDocStyles.'
843 /*###POSTCSSMARKER###*/
844 /*]]>*/
845 </style>
846 ';
847 $this->inDocStyles='';
848 $this->inDocStylesArray=array();
849
850 return $style;
851 }
852
853 /**
854 * insert post rendering document style into already rendered content
855 *
856 * @return string content with inserted styles
857 */
858 function insertStylesAndJS($content) {
859 // insert accumulated CSS
860 $this->inDocStylesArray[] = $this->inDocStyles;
861 $styles = "\n".implode("\n", $this->inDocStylesArray);
862 $content = str_replace('/*###POSTCSSMARKER###*/',$styles,$content);
863
864 // insert accumulated JS
865 $jscode = $this->JScode."\n".$this->wrapScriptTags(implode("\n", $this->JScodeArray));
866 $content = str_replace('<!--###POSTJSMARKER###-->',$jscode,$content);
867
868 return $content;
869 }
870
871 /**
872 * Returns the 'background' attribute for the bodytag if the TBE_STYLES[background] value is set (must be relative to PATH_typo3)
873 *
874 * @param boolean If set, a background image is referred to with the CSS property "background-image" instead of the body-tag property "background"
875 * @return string
876 */
877 function getBackgroundImage($CSS=0) {
878 return ($this->backGroundImage
879 ? ($CSS ? ' background-image: url('.$this->backPath.$this->backGroundImage.');' : ' background="'.$this->backPath.$this->backGroundImage.'"')
880 :'');
881 }
882
883 /**
884 * Initialize the charset.
885 * Sets the internal $this->charset variable to the charset defined in $GLOBALS["LANG"] (or the default as set in this class)
886 * Returns the meta-tag for the document header
887 *
888 * @return string <meta> tag with charset from $this->charset or $GLOBALS['LANG']->charSet
889 */
890 function initCharset() {
891 // Set charset to the charset provided by the current backend users language selection:
892 $this->charset = $GLOBALS['LANG']->charSet ? $GLOBALS['LANG']->charSet : $this->charset;
893 // Return meta tag:
894 return '<meta http-equiv="Content-Type" content="text/html; charset='.$this->charset.'" />';
895 }
896
897 /**
898 * Returns generator meta tag
899 *
900 * @return string <meta> tag with name "GENERATOR"
901 */
902 function generator() {
903 $str = 'TYPO3 '.$GLOBALS['TYPO_VERSION'].', http://typo3.com, &#169; Kasper Sk&#229;rh&#248;j 1998-2003, extensions are copyright of their respective owners.';
904 return '<meta name="GENERATOR" content="'.$str .'" />';
905 }
906
907
908
909
910
911
912
913
914 /*****************************************
915 *
916 * OTHER ELEMENTS
917 * Tables, buttons, formatting dimmed/red strings
918 *
919 ******************************************/
920
921
922 /**
923 * Returns an image-tag with an 18x16 icon of the following types:
924 *
925 * $type:
926 * -1: OK icon (Check-mark)
927 * 1: Notice (Speach-bubble)
928 * 2: Warning (Yellow triangle)
929 * 3: Fatal error (Red stop sign)
930 *
931 * @param integer See description
932 * @return return HTML image tag (if applicable)
933 */
934 function icons($type) {
935 switch($type) {
936 case '3':
937 $icon = 'gfx/icon_fatalerror.gif';
938 break;
939 case '2':
940 $icon = 'gfx/icon_warning.gif';
941 break;
942 case '1':
943 $icon = 'gfx/icon_note.gif';
944 break;
945 case '-1':
946 $icon = 'gfx/icon_ok.gif';
947 break;
948 default:
949 break;
950 }
951 if ($icon) {
952 return '<img src="'.$this->backPath.$icon.'" width="18" height="16" align="absmiddle" alt="" />';
953 }
954 }
955
956 /**
957 * Returns an <input> button with the $onClick action and $label
958 *
959 * @param string The value of the onclick attribute of the input tag (submit type)
960 * @param string The label for the button (which will be htmlspecialchar'ed)
961 * @return string A <input> tag of the type "submit"
962 */
963 function t3Button($onClick,$label) {
964 $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;" />';
965 return $button;
966 }
967
968 /**
969 * dimmed-fontwrap. Returns the string wrapped in a <span>-tag defining the color to be gray/dimmed
970 *
971 * @param string Input string
972 * @return string Output string
973 */
974 function dfw($string) {
975 return '<span class="typo3-dimmed">'.$string.'</span>';
976 }
977
978 /**
979 * red-fontwrap. Returns the string wrapped in a <span>-tag defining the color to be red
980 *
981 * @param string Input string
982 * @return string Output string
983 */
984 function rfw($string) {
985 return '<span class="typo3-red">'.$string.'</span>';
986 }
987
988 /**
989 * Returns string wrapped in CDATA "tags" for XML / XHTML (wrap content of <script> and <style> sections in those!)
990 *
991 * @param string Input string
992 * @return string Output string
993 */
994 function wrapInCData($string) {
995 $string = '/*<![CDATA[*/'.
996 $string.
997 '/*]]>*/';
998
999 return $string;
1000 }
1001
1002 /**
1003 * Wraps the input string in script tags.
1004 * Automatic re-identing of the JS code is done by using the first line as ident reference.
1005 * This is nice for identing JS code with PHP code on the same level.
1006 *
1007 * @param string Input string
1008 * @param boolean Wrap script element in linebreaks? Default is TRUE.
1009 * @return string Output string
1010 */
1011 function wrapScriptTags($string, $linebreak=TRUE) {
1012 if(trim($string)) {
1013 // <script wrapped in nl?
1014 $cr = $linebreak? "\n" : '';
1015
1016 // remove nl from the beginning
1017 $string = preg_replace ('/^\n+/', '', $string);
1018 // re-ident to one tab using the first line as reference
1019 if(preg_match('/^(\t+)/',$string,$match)) {
1020 $string = str_replace($match[1],"\t", $string);
1021 }
1022 $string = $cr.'<script type="text/javascript">
1023 /*<![CDATA[*/
1024 '.$string.'
1025 /*]]>*/
1026 </script>'.$cr;
1027 }
1028 return trim($string);
1029 }
1030
1031 // These vars defines the layout for the table produced by the table() function.
1032 // You can override these values from outside if you like.
1033 var $tableLayout = Array (
1034 'defRow' => Array (
1035 'defCol' => Array('<TD valign="top">','</td>')
1036 )
1037 );
1038 var $table_TR = '<tr>';
1039 var $table_TABLE = '<table border="0" cellspacing="0" cellpadding="0">';
1040
1041 /**
1042 * Returns a table based on the input $arr
1043 *
1044 * @param array Multidim array with first levels = rows, second levels = cells
1045 * @return string The HTML table.
1046 * @internal
1047 */
1048 function table($arr) {
1049 if (is_array($arr)) {
1050 reset($arr);
1051 $code='';
1052 $rc=0;
1053 while(list(,$val)=each($arr)) {
1054 if ($rc % 2) {
1055 $layout = is_array($this->tableLayout['defRowOdd']) ? $this->tableLayout['defRowOdd'] : $this->tableLayout['defRow'];
1056 } else {
1057 $layout = is_array($this->tableLayout['defRowEven']) ? $this->tableLayout['defRowEven'] : $this->tableLayout['defRow'];
1058 }
1059 $layout = is_array($this->tableLayout[$rc]) ? $this->tableLayout[$rc] : $layout;
1060 $code_td='';
1061 if (is_array($val)) {
1062 $cc=0;
1063 while(list(,$content)=each($val)) {
1064 $wrap= is_array($layout[$cc]) ? $layout[$cc] : $layout['defCol'];
1065 $code_td.=$wrap[0].$content.$wrap[1];
1066 $cc++;
1067 }
1068 }
1069 $trWrap = is_array($layout['tr']) ? $layout['tr'] : array($this->table_TR, '</tr>');
1070 $code.=$trWrap[0].$code_td.$trWrap[1];
1071 $rc++;
1072 }
1073 $tableWrap = is_array($this->tableLayout['table']) ? $this->tableLayout['table'] : array($this->table_TABLE, '</table>');
1074 $code=$tableWrap[0].$code.$tableWrap[1];
1075 }
1076 return $code;
1077 }
1078
1079 /**
1080 * Constructs a table with content from the $arr1, $arr2 and $arr3.
1081 * Used in eg. ext/belog/mod/index.php - refer to that for examples
1082 *
1083 * @param array
1084 * @param array
1085 * @param array
1086 * @return string HTML content, <table>...</table>
1087 */
1088 function menuTable($arr1,$arr2=array(), $arr3=array()) {
1089 $rows = max(array(count($arr1),count($arr2),count($arr3)));
1090
1091 $menu='
1092 <table border="0" cellpadding="0" cellspacing="0">';
1093 for($a=0;$a<$rows;$a++) {
1094 $menu.='<tr>';
1095 $cls=array();
1096 $valign='middle';
1097 $cls[]='<td valign="'.$valign.'">'.$arr1[$a][0].'&nbsp;</td><td>'.$arr1[$a][1].'</td>';
1098 if (count($arr2)) {
1099 $cls[]='<td valign="'.$valign.'">'.$arr2[$a][0].'&nbsp;</td><td>'.$arr2[$a][1].'</td>';
1100 if (count($arr3)) {
1101 $cls[]='<td valign="'.$valign.'">'.$arr3[$a][0].'&nbsp;</td><td>'.$arr3[$a][1].'</td>';
1102 }
1103 }
1104 $menu.=implode($cls,'<td>&nbsp;&nbsp;</td>');
1105 $menu.='</tr>';
1106 }
1107 $menu.='
1108 </table>
1109 ';
1110 return $menu;
1111 }
1112
1113 /**
1114 * Returns a one-row/two-celled table with $content and $menu side by side.
1115 * The table is a 100% width table and each cell is aligned left / right
1116 *
1117 * @param string Content cell content (left)
1118 * @param string Menu cell content (right)
1119 * @return string HTML output
1120 */
1121 function funcMenu($content,$menu) {
1122 return '<table border="0" cellpadding="0" cellspacing="0" width="100%">
1123 <tr><td valign="top" nowrap="nowrap">'.$content.'</td><td valign="top" align="right" nowrap="nowrap">'.$menu.'</td></tr>
1124 </table>';
1125 }
1126
1127 /**
1128 * Creates a selector box with clear-cache items.
1129 * Rather specialized functions - at least don't use it with $addSaveOptions unless you know what you do...
1130 *
1131 * @param integer The page uid of the "current page" - the one that will be cleared as "clear cache for this page".
1132 * @param boolean If $addSaveOptions is set, then also the array of save-options for TCE_FORMS will appear.
1133 * @return string <select> tag with content - a selector box for clearing the cache
1134 */
1135 function clearCacheMenu($id,$addSaveOptions=0) {
1136 global $BE_USER;
1137 $opt=$addOptions;
1138 if ($addSaveOptions) {
1139 $opt[]='<option value="">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.menu',1).'</option>';
1140 $opt[]='<option value="TBE_EDITOR_checkAndDoSubmit(1);">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc',1).'</option>';
1141 $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>';
1142 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>';
1143 $opt[]='<option value="document.editform.closeDoc.value=2; document.editform.submit();">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc',1).'</option>';
1144 $opt[]='<option value="document.editform.closeDoc.value=3; document.editform.submit();">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeAllDocs',1).'</option>';
1145 $opt[]='<option value=""></option>';
1146 }
1147 $opt[]='<option value="">[ '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_clearCache',1).' ]</option>';
1148 if ($id) $opt[]='<option value="'.$id.'">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_thisPage',1).'</option>';
1149 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>';
1150 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>';
1151 $af_content = '<select name="cacheCmd" onchange="
1152 if (!this.options[this.selectedIndex].value) {
1153 this.selectedIndex=0;
1154 } else if (this.options[this.selectedIndex].value.indexOf(\';\')!=-1) {
1155 eval(this.options[this.selectedIndex].value);
1156 }else{
1157 document.location=\''.$this->backPath.'tce_db.php?vC='.$BE_USER->veriCode().'&redirect='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')).'&cacheCmd=\'+this.options[this.selectedIndex].value;
1158 }">'.implode("",$opt).'</select>';
1159 if (count($opt)>2) {
1160 return $af_content;
1161 }
1162 }
1163
1164 /**
1165 * Returns an array with parts (JavaScript, init-functions, <div>-layers) for use on pages which displays the clickmenu layers (context sensitive menus)
1166 *
1167 * @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
1168 */
1169 function getContextMenuCode() {
1170 if ($this->isCMlayers()) {
1171 $content='
1172 <script type="text/javascript">
1173 /*<![CDATA[*/
1174 var GLV_gap=10;
1175 var GLV_curLayerX=new Array(0,0);
1176 var GLV_curLayerY=new Array(0,0);
1177 var GLV_curLayerWidth=new Array(0,0);
1178 var GLV_curLayerHeight=new Array(0,0);
1179 var GLV_isVisible=new Array(0,0);
1180 var GLV_x=0;
1181 var GLV_y=0;
1182 var layerObj=new Array();
1183 var layerObjCss=new Array();
1184
1185 //browsercheck...
1186 function GL_checkBrowser(){
1187 this.dom= (document.getElementById);
1188 this.op= (navigator.userAgent.indexOf("Opera")>-1);
1189 this.op7= this.op && (navigator.appVersion.indexOf("7")>-1); // check for Opera version 7
1190 this.konq= (navigator.userAgent.indexOf("Konq")>-1);
1191 this.ie4= (document.all && !this.dom && !this.op && !this.konq);
1192 this.ie5= (document.all && this.dom && !this.op && !this.konq);
1193 this.ns4= (document.layers && !this.dom && !this.konq);
1194 this.ns5= (!document.all && this.dom && !this.op && !this.konq);
1195 this.ns6= (this.ns5);
1196 this.bw= (this.ie4 || this.ie5 || this.ns4 || this.ns6 || this.op || this.konq);
1197 return this;
1198 }
1199 bw= new GL_checkBrowser();
1200
1201 // GL_getObj(obj)
1202 function GL_getObj(obj){
1203 nest="";
1204 this.el= (bw.ie4||bw.op7)?document.all[obj]:bw.ns4?eval(nest+"document."+obj):document.getElementById(obj);
1205 this.css= bw.ns4?this.el:this.el.style;
1206 this.ref= bw.ns4?this.el.document:document;
1207 this.x= (bw.ns4||bw.op)?this.css.left:this.el.offsetLeft;
1208 this.y= (bw.ns4||bw.op)?this.css.top:this.el.offsetTop;
1209 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;
1210 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;
1211 return this;
1212 }
1213 // GL_getObjCss(obj)
1214 function GL_getObjCss(obj){
1215 return bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?document.layers[obj]:0;
1216 }
1217 // GL_getMouse(event)
1218 function GL_getMouse(event) {
1219 if (layerObj) {
1220 GLV_x= (bw.ns4||bw.ns5)?event.pageX:(bw.ie4||bw.op)?event.clientX:(event.clientX-2)+document.body.scrollLeft;
1221 GLV_y= (bw.ns4||bw.ns5)?event.pageY:(bw.ie4||bw.op)?event.clientY:(event.clientY-2)+document.body.scrollTop;
1222
1223 // status = (GLV_x+GLV_gap-GLV_curLayerX[0]) + " | " + (GLV_y+GLV_gap-GLV_curLayerY[0]);
1224 if (GLV_isVisible[1]) {
1225 if (outsideLayer(1)) hideSpecific(1);
1226 } else if (GLV_isVisible[0]) {
1227 if (outsideLayer(0)) hideSpecific(0);
1228 }
1229 }
1230 }
1231 // outsideLayer(level)
1232 function outsideLayer(level) {
1233 return GLV_x+GLV_gap-GLV_curLayerX[level] <0 ||
1234 GLV_y+GLV_gap-GLV_curLayerY[level] <0 ||
1235 GLV_curLayerX[level]+GLV_curLayerWidth[level]+GLV_gap-GLV_x <0 ||
1236 GLV_curLayerY[level]+GLV_curLayerHeight[level]+GLV_gap-GLV_y <0;
1237 }
1238 // setLayerObj(html,level)
1239 function setLayerObj(html,level) {
1240 var tempLayerObj = GL_getObj("contentMenu"+level);
1241 var tempLayerObjCss = GL_getObjCss("contentMenu"+level);
1242
1243 if (tempLayerObj && (level==0 || GLV_isVisible[level-1])) {
1244 tempLayerObj.el.innerHTML = html;
1245 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;
1246 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;
1247
1248 GLV_curLayerX[level] = GLV_x;
1249 GLV_curLayerY[level] = GLV_y;
1250 tempLayerObjCss.left = GLV_x+"px";
1251 tempLayerObjCss.top = GLV_y+"px";
1252 tempLayerObjCss.visibility = "visible";
1253
1254 GLV_isVisible[level]=1;
1255 GLV_curLayerWidth[level] = tempLayerObj.width;
1256 GLV_curLayerHeight[level] = tempLayerObj.height;
1257 }
1258 }
1259 // hideEmpty()
1260 function hideEmpty() {
1261 hideSpecific(0);
1262 hideSpecific(1);
1263 return false;
1264 }
1265 // hideSpecific(level)
1266 function hideSpecific(level) {
1267 GL_getObjCss("contentMenu"+level).visibility = "hidden";
1268 GL_getObj("contentMenu"+level).el.innerHTML = "";
1269 GLV_isVisible[level]=0;
1270 }
1271 // debugObj(obj,name)
1272 function debugObj(obj,name) {
1273 var acc;
1274 for (i in obj) {if (obj[i]) {acc+=i+": "+obj[i]+"\n";}}
1275 alert("Object: "+name+"\n\n"+acc);
1276 }
1277 // initLayer()
1278 function initLayer(){
1279 if (document.all) {
1280 window.onmousemove=GL_getMouse;
1281 }
1282 layerObj = GL_getObj("contentMenu1");
1283 layerObjCss = GL_getObjCss("contentMenu1");
1284 }
1285 /*]]>*/
1286 </script>
1287 ';
1288 return array(
1289 $content,
1290 ' onmousemove="GL_getMouse(event);" onload="initLayer();"',
1291 '<div id="contentMenu0" style="z-index:1; position:absolute;visibility:hidden"></div><div id="contentMenu1" style="z-index:2; position:absolute;visibility:hidden"></div>'
1292 );
1293 } else return array('','','');
1294 }
1295
1296
1297
1298
1299 /**
1300 * creates a tab menu from an array definition
1301 *
1302 * Returns a tab menu for a module
1303 * Requires the JS function jumpToUrl() to be available
1304 *
1305 *
1306 * @param string $id is the "&id=" parameter value to be sent to the module
1307 * @param string $elementName it the form elements name, probably something like "SET[...]"
1308 * @param string $currentValue is the value to be selected currently.
1309 * @param array $menuItems is an array with the menu items for the selector box
1310 * @param string $script is the script to send the &id to, if empty it's automatically found
1311 * @param string $addParams is additional parameters to pass to the script.
1312 * @return string HTML code for tab menu
1313 * @author René Fritz <r.fritz@colorcube.de>
1314 */
1315 function getTabMenu($id,$elementName,$currentValue,$menuItems,$script='',$addparams='') {
1316 $content='';
1317
1318 if (is_array($menuItems)) {
1319 if (!$script) {basename(PATH_thisScript);}
1320 $options='';
1321
1322 $count = count($menuItems);
1323 $widthLeft = 1;
1324 $addToAct = 5;
1325
1326 $widthRight = max (1,floor(30-pow($count,1.72)));
1327 $widthTabs = 100 - $widthRight - $widthLeft;
1328 $widthNo = floor(($widthTabs - $addToAct)/$count);
1329 $addToAct = max ($addToAct,$widthTabs-($widthNo*$count));
1330 $widthAct = $widthNo + $addToAct;
1331 $widthRight = 100 - ($widthLeft + ($count*$widthNo) + $addToAct);
1332
1333 $first=true;
1334 foreach($menuItems as $value => $label) {
1335 $isActive = !strcmp($currentValue,$value);
1336 $class = $isActive ? "tabact" : "tab";
1337 $width = $isActive ? $widthAct : $widthNo;
1338
1339 $label = t3lib_div::deHSCentities(htmlspecialchars($label));
1340 $link = htmlspecialchars($script.'?id='.rawurlencode($id).$addparams.'&'.$elementName.'='.$value);
1341 if($first) {
1342 $options .= "\n\t".'<td width="'.$width.'%" class="'.$class.'" style="border-left: solid #000 1px;"><a href="'.$link.'" class="'.$class.'" style="padding-left:5px;padding-right:2px;">'.$label.'</a></td>';
1343 } else {
1344 $options .= "\n\t".'<td width="'.$width.'%" class="'.$class.'"><a href="'.$link.'" class="'.$class.'">'.$label.'</a></td>';
1345 }
1346 $first=false;
1347 }
1348
1349 if ($options) {
1350 $content .= "\n\t".'<!-- Tab menu -->';
1351 $content .= "\n\t".'<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr>';
1352 $content .= "\n\t".'<td width="'.$widthLeft.'%">&nbsp;</td>';
1353
1354 $content .= $options;
1355
1356 $content .= "\n\t".'<td width="'.$widthRight.'%">&nbsp;</td>';
1357 $content .= "\n\t".'</tr></table>';
1358 $content .= '<div class="hr" style="display:block;margin:0px;padding:0px;"></div';
1359 }
1360
1361 // include CSS
1362 $actBgColor = t3lib_div::modifyHTMLcolor($this->bgColor6,0,0,0);
1363 $lgBgColor = t3lib_div::modifyHTMLcolor($this->bgColor5,25,25,25);
1364 $hoverBgColor = t3lib_div::modifyHTMLcolor($this->bgColor6,15,15,15);
1365
1366 $this->inDocStylesArray['getTabMenu'] = '
1367 td.tabact {
1368 border: solid black 1px;
1369 background: '.$actBgColor.';
1370 color:#000;
1371 }
1372 td.tabact>a {
1373 color:#000;
1374 }
1375 td.tab {
1376 border: solid #555 1px;
1377 border-left: solid #aaa 3px;
1378 background: '.$lgBgColor.';
1379 color:grey;
1380 }
1381 td.tab, td.tabact {
1382 border-bottom: none;
1383 border-radius: 3px;
1384 -moz-border-radius: 3px;
1385 }
1386 a.tab, a.tabact {
1387 color:grey;
1388 text-decoration:none;
1389 display: block;
1390 width:auto;
1391 padding:2px;
1392 padding-left:3px;
1393 padding-right:5px;
1394 }
1395 a.tabact {
1396 padding-left:10px;
1397 padding-right:10px;
1398 }
1399 a.tab:hover,a.tabact:hover {
1400 color:black;
1401 background: '.$hoverBgColor.';
1402 text-decoration:none;
1403 cursor: pointer;
1404 }';
1405 }
1406 return $content;
1407
1408 }
1409
1410
1411 }
1412
1413
1414
1415 // ******************************
1416 // Extension classes of the template class.
1417 // These are meant to provide backend screens with different widths.
1418 // They still do because of the different class-prefixes used for the <div>-sections
1419 // but obviously the final width is determined by the stylesheet used.
1420 // ******************************
1421
1422 /**
1423 * 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
1424 * The class were more significant in the past than today.
1425 *
1426 */
1427 class bigDoc extends template {
1428 var $divClass = 'typo3-bigDoc';
1429 }
1430
1431 /**
1432 * Extension class for "template" - used for backend pages without the "document" background image
1433 * The class were more significant in the past than today.
1434 *
1435 */
1436 class noDoc extends template {
1437 var $divClass = 'typo3-noDoc';
1438 }
1439
1440 /**
1441 * 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)
1442 * The class were more significant in the past than today.
1443 *
1444 */
1445 class smallDoc extends template {
1446 var $divClass = 'typo3-smallDoc';
1447 }
1448
1449 /**
1450 * 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.
1451 * The class were more significant in the past than today. But probably you should use this one for most modules you make.
1452 *
1453 */
1454 class mediumDoc extends template {
1455 var $divClass = 'typo3-mediumDoc';
1456 }
1457
1458
1459
1460 // Include extension to the template class?
1461 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/template.php']) {
1462 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/template.php']);
1463 }
1464
1465
1466
1467 // ******************************************************
1468 // The backend language engine is started (ext: "lang")
1469 // ******************************************************
1470 require_once(PATH_typo3.'sysext/lang/lang.php');
1471 $LANG = t3lib_div::makeInstance('language');
1472 $LANG->init($BE_USER->uc['lang']);
1473
1474
1475
1476 // ******************************
1477 // The template is loaded
1478 // ******************************
1479 $TBE_TEMPLATE = t3lib_div::makeInstance('template');
1480 ?>