Added HTTP header output for charset encoding (utf-8 issue). Modified function: startPage
[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 // Get META tag containing the currently selected charset for backend output. The function sets $this->charSet.
567 $charSet = $this->initCharset();
568 $generator = $this->generator();
569
570 // Send HTTP header for selected charset. Added by Robert Lemke 23.10.2003
571 header ('Content-Type:text/html;charset='.$this->charset);
572
573 switch($this->docType) {
574 case 'xhtml_strict':
575 $headerStart= '<?xml version="1.0" encoding="'.$this->charset.'"?>
576 <?xml-stylesheet href="#internalStyle" type="text/css"?>
577 <!DOCTYPE html
578 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
579 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
580 break;
581 case 'xhtml_trans':
582 $headerStart= '<?xml version="1.0" encoding="'.$this->charset.'"?>
583 <?xml-stylesheet href="#internalStyle" type="text/css"?>
584 <!DOCTYPE html
585 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
586 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
587 break;
588 case 'xhtml_frames':
589 $headerStart= '<?xml version="1.0" encoding="'.$this->charset.'"?>
590 <!DOCTYPE html
591 PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
592 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
593 break;
594 default:
595 $headerStart='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">';
596 break;
597 }
598
599 // Construct page header.
600 $str = $headerStart.'
601 <html>
602 <head>
603 '.$charSet.'
604 '.$generator.'
605 <title>'.htmlspecialchars($title).'</title>
606 '.$this->docStyle().'
607 '.$this->JScode.'
608 '.$this->wrapScriptTags(implode("\n", $this->JScodeArray)).'
609 <!--###POSTJSMARKER###-->
610 </head>
611 ';
612 $this->JScode='';
613 $this->JScodeArray=array();
614
615 if ($this->docType=='xhtml_frames') {
616 return $str;
617 } else
618 $str.=$this->docBodyTagBegin().
619 ($this->divClass?'
620
621 <!-- Wrapping DIV-section for whole page BEGIN -->
622 <div class="'.$this->divClass.'">':'').
623 trim($this->form);
624 return $str;
625 }
626
627 /**
628 * Returns page end.
629 *
630 * @return string The HTML end of a page
631 * @see startPage()
632 */
633 function endPage() {
634 $str = $this->sectionEnd().
635 $this->postCode.
636 $this->endPageJS().
637 t3lib_BEfunc::getSetUpdateSignal().
638 $this->parseTime().
639 ($this->form?'
640 </form>':'').
641 ($this->divClass?'
642
643 <!-- Wrapping DIV-section for whole page END -->
644 </div>':'').
645 '
646 </body>
647 </html> ';
648 return $str;
649 }
650
651 /**
652 * Returns the header-bar in the top of most backend modules
653 * Closes section if open.
654 *
655 * @param string The text string for the header
656 * @return string HTML content
657 */
658 function header($text) {
659 $str='
660
661 <!-- MAIN Header in page top -->
662 <h2>'.$text.'</h2>
663 ';
664 return $this->sectionEnd().$str;
665 }
666
667 /**
668 * Begins an output section and sets header and content
669 *
670 * @param string The header
671 * @param string The HTML-content
672 * @param boolean A flag that will prevent the header from being converted to uppercase
673 * @param boolean Defines the type of header (if set, "<h3>" rather than the default "h4")
674 * @param integer The number of an icon to show with the header (see the icon-function). -1,1,2,3
675 * @return string HTML content
676 * @see icons(), sectionHeader()
677 */
678 function section($label,$text,$nostrtoupper=0,$sH=0,$type=0) {
679 $str="";
680
681 // Setting header
682 if ($label) $str.=$this->sectionHeader($this->icons($type).($nostrtoupper ? $label : t3lib_div::danish_strtoupper($label)), $sH);
683 // Setting content
684 $str.='
685
686 <!-- Section content -->
687 '.$text;
688
689 return $this->sectionBegin().$str;
690 }
691
692 /**
693 * Inserts a divider image
694 * Ends a section (if open) before inserting the image
695 *
696 * @param integer The margin-top/-bottom of the <hr> ruler.
697 * @return string HTML content
698 */
699 function divider($dist) {
700 $dist = intval($dist);
701 $str='
702
703 <!-- DIVIDER -->
704 <hr style="margin-top: '.$dist.'px; margin-bottom: '.$dist.'px;" />
705 ';
706 return $this->sectionEnd().$str;
707 }
708
709 /**
710 * Returns a blank <div>-section with a height
711 *
712 * @param integer Padding-top for the div-section (should be margin-top but konquorer (3.1) don't like it :-(
713 * @return string HTML content
714 */
715 function spacer($dist) {
716 if ($dist>0) {
717 return '
718
719 <!-- Spacer element -->
720 <div style="padding-top: '.intval($dist).'px;"></div>
721 ';
722 }
723 }
724
725 /**
726 * Make a section header.
727 * Begins a section if not already open.
728 *
729 * @param string The label between the <h3> or <h4> tags
730 * @param boolean If set, <h3> is used, otherwise <h4>
731 * @return string HTML content
732 */
733 function sectionHeader($label,$sH=0) {
734 $tag = ($sH?'h3':'h4');
735 $str='
736
737 <!-- Section header -->
738 <'.$tag.'>'.$label.'</'.$tag.'>
739 ';
740 return $this->sectionBegin().$str;
741 }
742
743 /**
744 * Begins an output section.
745 * Returns the <div>-begin tag AND sets the ->sectionFlag true (if the ->sectionFlag is not already set!)
746 * 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!
747 *
748 * @return string HTML content
749 */
750 function sectionBegin() {
751 if (!$this->sectionFlag) {
752 $this->sectionFlag=1;
753 $str='
754
755 <!-- ***********************
756 Begin output section.
757 *********************** -->
758 <div>
759 ';
760 return $str;
761 } else return '';
762 }
763
764 /**
765 * Ends and output section
766 * Returns the </div>-end tag AND clears the ->sectionFlag (but does so only IF the sectionFlag is set - that is a section is 'open')
767 * See sectionBegin() also.
768 *
769 * @return string HTML content
770 */
771 function sectionEnd() {
772 if ($this->sectionFlag) {
773 $this->sectionFlag=0;
774 return '
775 </div>
776 <!-- *********************
777 End output section.
778 ********************* -->
779 ';
780 } else return '';
781 }
782
783 /**
784 * Originally it printed a kind of divider.
785 * Depreciated. Just remove function calls to it or call the divider() function instead.
786 *
787 * @return void
788 * @internal
789 * @depreciated
790 */
791 function middle() {
792 }
793
794 /**
795 * If a form-tag is defined in ->form then and end-tag for that <form> element is outputted
796 * Further a JavaScript section is outputted which will update the top.busy session-expiry object (unless $this->endJS is set to false)
797 *
798 * @return string
799 */
800 function endPageJS() {
801 return ($this->endJS?'
802 <script type="text/javascript">
803 /*<![CDATA[*/
804 if (top.busy && top.busy.loginRefreshed) {
805 top.busy.loginRefreshed();
806 }
807 /*]]>*/
808 </script>':'');
809 }
810
811 /**
812 * Creates the bodyTag.
813 *
814 * You can add to the bodyTag by $this->bodyTagAdditions
815 * Background color is set by $this->bgColor
816 * The array $this->bodyTagMargins is used to set left/top margins
817 * $this->getBackgroundImage() fetches background image if applicable.
818 *
819 * @return string HTML body tag
820 */
821 function docBodyTagBegin() {
822 // topmargin="'.$this->bodyTagMargins["y"].'" leftmargin="'.$this->bodyTagMargins["x"].'" marginwidth="'.$this->bodyTagMargins["x"].'" marginheight="'.$this->bodyTagMargins["y"].'"
823 $bodyContent = 'body '.trim($this->bodyTagAdditions).' '; // $this->getBackgroundImage()
824 return '<'.trim($bodyContent).'>';
825 }
826
827 /**
828 * Outputting document style
829 *
830 * @return string HTML style section/link tags
831 */
832 function docStyle() {
833 $this->inDocStylesArray[] = $this->inDocStyles;
834 $inDocStyles = "\n".implode("\n", $this->inDocStylesArray);
835
836 // The default color scheme should also in full be represented in the stylesheet.
837 $style='
838 '.($this->styleSheetFile?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile.'" />':'').'
839 '.($this->styleSheetFile2?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile2.'" />':'').'
840 <style type="text/css" id="internalStyle">
841 /*<![CDATA[*/
842 A:hover {color: '.$this->hoverColor.'}
843 H2 {background-color: '.$this->bgColor2.';}
844 H3 {background-color: '.$this->bgColor6.';}
845 BODY {background-color: '.$this->bgColor.';'.$this->getBackgroundImage(1).'}
846 '.$inDocStyles.'
847 /*###POSTCSSMARKER###*/
848 /*]]>*/
849 </style>
850 ';
851 $this->inDocStyles='';
852 $this->inDocStylesArray=array();
853
854 return $style;
855 }
856
857 /**
858 * insert post rendering document style into already rendered content
859 *
860 * @return string content with inserted styles
861 */
862 function insertStylesAndJS($content) {
863 // insert accumulated CSS
864 $this->inDocStylesArray[] = $this->inDocStyles;
865 $styles = "\n".implode("\n", $this->inDocStylesArray);
866 $content = str_replace('/*###POSTCSSMARKER###*/',$styles,$content);
867
868 // insert accumulated JS
869 $jscode = $this->JScode."\n".$this->wrapScriptTags(implode("\n", $this->JScodeArray));
870 $content = str_replace('<!--###POSTJSMARKER###-->',$jscode,$content);
871
872 return $content;
873 }
874
875 /**
876 * Returns the 'background' attribute for the bodytag if the TBE_STYLES[background] value is set (must be relative to PATH_typo3)
877 *
878 * @param boolean If set, a background image is referred to with the CSS property "background-image" instead of the body-tag property "background"
879 * @return string
880 */
881 function getBackgroundImage($CSS=0) {
882 return ($this->backGroundImage
883 ? ($CSS ? ' background-image: url('.$this->backPath.$this->backGroundImage.');' : ' background="'.$this->backPath.$this->backGroundImage.'"')
884 :'');
885 }
886
887 /**
888 * Initialize the charset.
889 * Sets the internal $this->charset variable to the charset defined in $GLOBALS["LANG"] (or the default as set in this class)
890 * Returns the meta-tag for the document header
891 *
892 * @return string <meta> tag with charset from $this->charset or $GLOBALS['LANG']->charSet
893 */
894 function initCharset() {
895 // Set charset to the charset provided by the current backend users language selection:
896 $this->charset = $GLOBALS['LANG']->charSet ? $GLOBALS['LANG']->charSet : $this->charset;
897 // Return meta tag:
898 return '<meta http-equiv="Content-Type" content="text/html; charset='.$this->charset.'" />';
899 }
900
901 /**
902 * Returns generator meta tag
903 *
904 * @return string <meta> tag with name "GENERATOR"
905 */
906 function generator() {
907 $str = 'TYPO3 '.$GLOBALS['TYPO_VERSION'].', http://typo3.com, &#169; Kasper Sk&#229;rh&#248;j 1998-2003, extensions are copyright of their respective owners.';
908 return '<meta name="GENERATOR" content="'.$str .'" />';
909 }
910
911
912
913
914
915
916
917
918 /*****************************************
919 *
920 * OTHER ELEMENTS
921 * Tables, buttons, formatting dimmed/red strings
922 *
923 ******************************************/
924
925
926 /**
927 * Returns an image-tag with an 18x16 icon of the following types:
928 *
929 * $type:
930 * -1: OK icon (Check-mark)
931 * 1: Notice (Speach-bubble)
932 * 2: Warning (Yellow triangle)
933 * 3: Fatal error (Red stop sign)
934 *
935 * @param integer See description
936 * @return return HTML image tag (if applicable)
937 */
938 function icons($type) {
939 switch($type) {
940 case '3':
941 $icon = 'gfx/icon_fatalerror.gif';
942 break;
943 case '2':
944 $icon = 'gfx/icon_warning.gif';
945 break;
946 case '1':
947 $icon = 'gfx/icon_note.gif';
948 break;
949 case '-1':
950 $icon = 'gfx/icon_ok.gif';
951 break;
952 default:
953 break;
954 }
955 if ($icon) {
956 return '<img src="'.$this->backPath.$icon.'" width="18" height="16" align="absmiddle" alt="" />';
957 }
958 }
959
960 /**
961 * Returns an <input> button with the $onClick action and $label
962 *
963 * @param string The value of the onclick attribute of the input tag (submit type)
964 * @param string The label for the button (which will be htmlspecialchar'ed)
965 * @return string A <input> tag of the type "submit"
966 */
967 function t3Button($onClick,$label) {
968 $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;" />';
969 return $button;
970 }
971
972 /**
973 * dimmed-fontwrap. Returns the string wrapped in a <span>-tag defining the color to be gray/dimmed
974 *
975 * @param string Input string
976 * @return string Output string
977 */
978 function dfw($string) {
979 return '<span class="typo3-dimmed">'.$string.'</span>';
980 }
981
982 /**
983 * red-fontwrap. Returns the string wrapped in a <span>-tag defining the color to be red
984 *
985 * @param string Input string
986 * @return string Output string
987 */
988 function rfw($string) {
989 return '<span class="typo3-red">'.$string.'</span>';
990 }
991
992 /**
993 * Returns string wrapped in CDATA "tags" for XML / XHTML (wrap content of <script> and <style> sections in those!)
994 *
995 * @param string Input string
996 * @return string Output string
997 */
998 function wrapInCData($string) {
999 $string = '/*<![CDATA[*/'.
1000 $string.
1001 '/*]]>*/';
1002
1003 return $string;
1004 }
1005
1006 /**
1007 * Wraps the input string in script tags.
1008 * Automatic re-identing of the JS code is done by using the first line as ident reference.
1009 * This is nice for identing JS code with PHP code on the same level.
1010 *
1011 * @param string Input string
1012 * @param boolean Wrap script element in linebreaks? Default is TRUE.
1013 * @return string Output string
1014 */
1015 function wrapScriptTags($string, $linebreak=TRUE) {
1016 if(trim($string)) {
1017 // <script wrapped in nl?
1018 $cr = $linebreak? "\n" : '';
1019
1020 // remove nl from the beginning
1021 $string = preg_replace ('/^\n+/', '', $string);
1022 // re-ident to one tab using the first line as reference
1023 if(preg_match('/^(\t+)/',$string,$match)) {
1024 $string = str_replace($match[1],"\t", $string);
1025 }
1026 $string = $cr.'<script type="text/javascript">
1027 /*<![CDATA[*/
1028 '.$string.'
1029 /*]]>*/
1030 </script>'.$cr;
1031 }
1032 return trim($string);
1033 }
1034
1035 // These vars defines the layout for the table produced by the table() function.
1036 // You can override these values from outside if you like.
1037 var $tableLayout = Array (
1038 'defRow' => Array (
1039 'defCol' => Array('<TD valign="top">','</td>')
1040 )
1041 );
1042 var $table_TR = '<tr>';
1043 var $table_TABLE = '<table border="0" cellspacing="0" cellpadding="0">';
1044
1045 /**
1046 * Returns a table based on the input $arr
1047 *
1048 * @param array Multidim array with first levels = rows, second levels = cells
1049 * @return string The HTML table.
1050 * @internal
1051 */
1052 function table($arr) {
1053 if (is_array($arr)) {
1054 reset($arr);
1055 $code='';
1056 $rc=0;
1057 while(list(,$val)=each($arr)) {
1058 if ($rc % 2) {
1059 $layout = is_array($this->tableLayout['defRowOdd']) ? $this->tableLayout['defRowOdd'] : $this->tableLayout['defRow'];
1060 } else {
1061 $layout = is_array($this->tableLayout['defRowEven']) ? $this->tableLayout['defRowEven'] : $this->tableLayout['defRow'];
1062 }
1063 $layout = is_array($this->tableLayout[$rc]) ? $this->tableLayout[$rc] : $layout;
1064 $code_td='';
1065 if (is_array($val)) {
1066 $cc=0;
1067 while(list(,$content)=each($val)) {
1068 $wrap= is_array($layout[$cc]) ? $layout[$cc] : $layout['defCol'];
1069 $code_td.=$wrap[0].$content.$wrap[1];
1070 $cc++;
1071 }
1072 }
1073 $trWrap = is_array($layout['tr']) ? $layout['tr'] : array($this->table_TR, '</tr>');
1074 $code.=$trWrap[0].$code_td.$trWrap[1];
1075 $rc++;
1076 }
1077 $tableWrap = is_array($this->tableLayout['table']) ? $this->tableLayout['table'] : array($this->table_TABLE, '</table>');
1078 $code=$tableWrap[0].$code.$tableWrap[1];
1079 }
1080 return $code;
1081 }
1082
1083 /**
1084 * Constructs a table with content from the $arr1, $arr2 and $arr3.
1085 * Used in eg. ext/belog/mod/index.php - refer to that for examples
1086 *
1087 * @param array
1088 * @param array
1089 * @param array
1090 * @return string HTML content, <table>...</table>
1091 */
1092 function menuTable($arr1,$arr2=array(), $arr3=array()) {
1093 $rows = max(array(count($arr1),count($arr2),count($arr3)));
1094
1095 $menu='
1096 <table border="0" cellpadding="0" cellspacing="0">';
1097 for($a=0;$a<$rows;$a++) {
1098 $menu.='<tr>';
1099 $cls=array();
1100 $valign='middle';
1101 $cls[]='<td valign="'.$valign.'">'.$arr1[$a][0].'&nbsp;</td><td>'.$arr1[$a][1].'</td>';
1102 if (count($arr2)) {
1103 $cls[]='<td valign="'.$valign.'">'.$arr2[$a][0].'&nbsp;</td><td>'.$arr2[$a][1].'</td>';
1104 if (count($arr3)) {
1105 $cls[]='<td valign="'.$valign.'">'.$arr3[$a][0].'&nbsp;</td><td>'.$arr3[$a][1].'</td>';
1106 }
1107 }
1108 $menu.=implode($cls,'<td>&nbsp;&nbsp;</td>');
1109 $menu.='</tr>';
1110 }
1111 $menu.='
1112 </table>
1113 ';
1114 return $menu;
1115 }
1116
1117 /**
1118 * Returns a one-row/two-celled table with $content and $menu side by side.
1119 * The table is a 100% width table and each cell is aligned left / right
1120 *
1121 * @param string Content cell content (left)
1122 * @param string Menu cell content (right)
1123 * @return string HTML output
1124 */
1125 function funcMenu($content,$menu) {
1126 return '<table border="0" cellpadding="0" cellspacing="0" width="100%">
1127 <tr><td valign="top" nowrap="nowrap">'.$content.'</td><td valign="top" align="right" nowrap="nowrap">'.$menu.'</td></tr>
1128 </table>';
1129 }
1130
1131 /**
1132 * Creates a selector box with clear-cache items.
1133 * Rather specialized functions - at least don't use it with $addSaveOptions unless you know what you do...
1134 *
1135 * @param integer The page uid of the "current page" - the one that will be cleared as "clear cache for this page".
1136 * @param boolean If $addSaveOptions is set, then also the array of save-options for TCE_FORMS will appear.
1137 * @return string <select> tag with content - a selector box for clearing the cache
1138 */
1139 function clearCacheMenu($id,$addSaveOptions=0) {
1140 global $BE_USER;
1141 $opt=$addOptions;
1142 if ($addSaveOptions) {
1143 $opt[]='<option value="">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.menu',1).'</option>';
1144 $opt[]='<option value="TBE_EDITOR_checkAndDoSubmit(1);">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc',1).'</option>';
1145 $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>';
1146 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>';
1147 $opt[]='<option value="document.editform.closeDoc.value=2; document.editform.submit();">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc',1).'</option>';
1148 $opt[]='<option value="document.editform.closeDoc.value=3; document.editform.submit();">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeAllDocs',1).'</option>';
1149 $opt[]='<option value=""></option>';
1150 }
1151 $opt[]='<option value="">[ '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_clearCache',1).' ]</option>';
1152 if ($id) $opt[]='<option value="'.$id.'">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_thisPage',1).'</option>';
1153 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>';
1154 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>';
1155 $af_content = '<select name="cacheCmd" onchange="
1156 if (!this.options[this.selectedIndex].value) {
1157 this.selectedIndex=0;
1158 } else if (this.options[this.selectedIndex].value.indexOf(\';\')!=-1) {
1159 eval(this.options[this.selectedIndex].value);
1160 }else{
1161 document.location=\''.$this->backPath.'tce_db.php?vC='.$BE_USER->veriCode().'&redirect='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')).'&cacheCmd=\'+this.options[this.selectedIndex].value;
1162 }">'.implode("",$opt).'</select>';
1163 if (count($opt)>2) {
1164 return $af_content;
1165 }
1166 }
1167
1168 /**
1169 * Returns an array with parts (JavaScript, init-functions, <div>-layers) for use on pages which displays the clickmenu layers (context sensitive menus)
1170 *
1171 * @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
1172 */
1173 function getContextMenuCode() {
1174 if ($this->isCMlayers()) {
1175 $content='
1176 <script type="text/javascript">
1177 /*<![CDATA[*/
1178 var GLV_gap=10;
1179 var GLV_curLayerX=new Array(0,0);
1180 var GLV_curLayerY=new Array(0,0);
1181 var GLV_curLayerWidth=new Array(0,0);
1182 var GLV_curLayerHeight=new Array(0,0);
1183 var GLV_isVisible=new Array(0,0);
1184 var GLV_x=0;
1185 var GLV_y=0;
1186 var layerObj=new Array();
1187 var layerObjCss=new Array();
1188
1189 //browsercheck...
1190 function GL_checkBrowser(){
1191 this.dom= (document.getElementById);
1192 this.op= (navigator.userAgent.indexOf("Opera")>-1);
1193 this.op7= this.op && (navigator.appVersion.indexOf("7")>-1); // check for Opera version 7
1194 this.konq= (navigator.userAgent.indexOf("Konq")>-1);
1195 this.ie4= (document.all && !this.dom && !this.op && !this.konq);
1196 this.ie5= (document.all && this.dom && !this.op && !this.konq);
1197 this.ns4= (document.layers && !this.dom && !this.konq);
1198 this.ns5= (!document.all && this.dom && !this.op && !this.konq);
1199 this.ns6= (this.ns5);
1200 this.bw= (this.ie4 || this.ie5 || this.ns4 || this.ns6 || this.op || this.konq);
1201 return this;
1202 }
1203 bw= new GL_checkBrowser();
1204
1205 // GL_getObj(obj)
1206 function GL_getObj(obj){
1207 nest="";
1208 this.el= (bw.ie4||bw.op7)?document.all[obj]:bw.ns4?eval(nest+"document."+obj):document.getElementById(obj);
1209 this.css= bw.ns4?this.el:this.el.style;
1210 this.ref= bw.ns4?this.el.document:document;
1211 this.x= (bw.ns4||bw.op)?this.css.left:this.el.offsetLeft;
1212 this.y= (bw.ns4||bw.op)?this.css.top:this.el.offsetTop;
1213 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;
1214 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;
1215 return this;
1216 }
1217 // GL_getObjCss(obj)
1218 function GL_getObjCss(obj){
1219 return bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?document.layers[obj]:0;
1220 }
1221 // GL_getMouse(event)
1222 function GL_getMouse(event) {
1223 if (layerObj) {
1224 GLV_x= (bw.ns4||bw.ns5)?event.pageX:(bw.ie4||bw.op)?event.clientX:(event.clientX-2)+document.body.scrollLeft;
1225 GLV_y= (bw.ns4||bw.ns5)?event.pageY:(bw.ie4||bw.op)?event.clientY:(event.clientY-2)+document.body.scrollTop;
1226
1227 // status = (GLV_x+GLV_gap-GLV_curLayerX[0]) + " | " + (GLV_y+GLV_gap-GLV_curLayerY[0]);
1228 if (GLV_isVisible[1]) {
1229 if (outsideLayer(1)) hideSpecific(1);
1230 } else if (GLV_isVisible[0]) {
1231 if (outsideLayer(0)) hideSpecific(0);
1232 }
1233 }
1234 }
1235 // outsideLayer(level)
1236 function outsideLayer(level) {
1237 return GLV_x+GLV_gap-GLV_curLayerX[level] <0 ||
1238 GLV_y+GLV_gap-GLV_curLayerY[level] <0 ||
1239 GLV_curLayerX[level]+GLV_curLayerWidth[level]+GLV_gap-GLV_x <0 ||
1240 GLV_curLayerY[level]+GLV_curLayerHeight[level]+GLV_gap-GLV_y <0;
1241 }
1242 // setLayerObj(html,level)
1243 function setLayerObj(html,level) {
1244 var tempLayerObj = GL_getObj("contentMenu"+level);
1245 var tempLayerObjCss = GL_getObjCss("contentMenu"+level);
1246
1247 if (tempLayerObj && (level==0 || GLV_isVisible[level-1])) {
1248 tempLayerObj.el.innerHTML = html;
1249 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;
1250 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;
1251
1252 GLV_curLayerX[level] = GLV_x;
1253 GLV_curLayerY[level] = GLV_y;
1254 tempLayerObjCss.left = GLV_x+"px";
1255 tempLayerObjCss.top = GLV_y+"px";
1256 tempLayerObjCss.visibility = "visible";
1257
1258 GLV_isVisible[level]=1;
1259 GLV_curLayerWidth[level] = tempLayerObj.width;
1260 GLV_curLayerHeight[level] = tempLayerObj.height;
1261 }
1262 }
1263 // hideEmpty()
1264 function hideEmpty() {
1265 hideSpecific(0);
1266 hideSpecific(1);
1267 return false;
1268 }
1269 // hideSpecific(level)
1270 function hideSpecific(level) {
1271 GL_getObjCss("contentMenu"+level).visibility = "hidden";
1272 GL_getObj("contentMenu"+level).el.innerHTML = "";
1273 GLV_isVisible[level]=0;
1274 }
1275 // debugObj(obj,name)
1276 function debugObj(obj,name) {
1277 var acc;
1278 for (i in obj) {if (obj[i]) {acc+=i+": "+obj[i]+"\n";}}
1279 alert("Object: "+name+"\n\n"+acc);
1280 }
1281 // initLayer()
1282 function initLayer(){
1283 if (document.all) {
1284 window.onmousemove=GL_getMouse;
1285 }
1286 layerObj = GL_getObj("contentMenu1");
1287 layerObjCss = GL_getObjCss("contentMenu1");
1288 }
1289 /*]]>*/
1290 </script>
1291 ';
1292 return array(
1293 $content,
1294 ' onmousemove="GL_getMouse(event);" onload="initLayer();"',
1295 '<div id="contentMenu0" style="z-index:1; position:absolute;visibility:hidden"></div><div id="contentMenu1" style="z-index:2; position:absolute;visibility:hidden"></div>'
1296 );
1297 } else return array('','','');
1298 }
1299
1300
1301
1302
1303 /**
1304 * creates a tab menu from an array definition
1305 *
1306 * Returns a tab menu for a module
1307 * Requires the JS function jumpToUrl() to be available
1308 *
1309 *
1310 * @param string $id is the "&id=" parameter value to be sent to the module
1311 * @param string $elementName it the form elements name, probably something like "SET[...]"
1312 * @param string $currentValue is the value to be selected currently.
1313 * @param array $menuItems is an array with the menu items for the selector box
1314 * @param string $script is the script to send the &id to, if empty it's automatically found
1315 * @param string $addParams is additional parameters to pass to the script.
1316 * @return string HTML code for tab menu
1317 * @author René Fritz <r.fritz@colorcube.de>
1318 */
1319 function getTabMenu($id,$elementName,$currentValue,$menuItems,$script='',$addparams='') {
1320 $content='';
1321
1322 if (is_array($menuItems)) {
1323 if (!$script) {basename(PATH_thisScript);}
1324 $options='';
1325
1326 $count = count($menuItems);
1327 $widthLeft = 1;
1328 $addToAct = 5;
1329
1330 $widthRight = max (1,floor(30-pow($count,1.72)));
1331 $widthTabs = 100 - $widthRight - $widthLeft;
1332 $widthNo = floor(($widthTabs - $addToAct)/$count);
1333 $addToAct = max ($addToAct,$widthTabs-($widthNo*$count));
1334 $widthAct = $widthNo + $addToAct;
1335 $widthRight = 100 - ($widthLeft + ($count*$widthNo) + $addToAct);
1336
1337 $first=true;
1338 foreach($menuItems as $value => $label) {
1339 $isActive = !strcmp($currentValue,$value);
1340 $class = $isActive ? "tabact" : "tab";
1341 $width = $isActive ? $widthAct : $widthNo;
1342
1343 $label = t3lib_div::deHSCentities(htmlspecialchars($label));
1344 $link = htmlspecialchars($script.'?id='.rawurlencode($id).$addparams.'&'.$elementName.'='.$value);
1345 if($first) {
1346 $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>';
1347 } else {
1348 $options .= "\n\t".'<td width="'.$width.'%" class="'.$class.'"><a href="'.$link.'" class="'.$class.'">'.$label.'</a></td>';
1349 }
1350 $first=false;
1351 }
1352
1353 if ($options) {
1354 $content .= "\n\t".'<!-- Tab menu -->';
1355 $content .= "\n\t".'<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr>';
1356 $content .= "\n\t".'<td width="'.$widthLeft.'%">&nbsp;</td>';
1357
1358 $content .= $options;
1359
1360 $content .= "\n\t".'<td width="'.$widthRight.'%">&nbsp;</td>';
1361 $content .= "\n\t".'</tr></table>';
1362 $content .= '<div class="hr" style="display:block;margin:0px;padding:0px;"></div';
1363 }
1364
1365 // include CSS
1366 $actBgColor = t3lib_div::modifyHTMLcolor($this->bgColor6,0,0,0);
1367 $lgBgColor = t3lib_div::modifyHTMLcolor($this->bgColor5,25,25,25);
1368 $hoverBgColor = t3lib_div::modifyHTMLcolor($this->bgColor6,15,15,15);
1369
1370 $this->inDocStylesArray['getTabMenu'] = '
1371 td.tabact {
1372 border: solid black 1px;
1373 background: '.$actBgColor.';
1374 color:#000;
1375 }
1376 td.tabact>a {
1377 color:#000;
1378 }
1379 td.tab {
1380 border: solid #555 1px;
1381 border-left: solid #aaa 3px;
1382 background: '.$lgBgColor.';
1383 color:grey;
1384 }
1385 td.tab, td.tabact {
1386 border-bottom: none;
1387 border-radius: 3px;
1388 -moz-border-radius: 3px;
1389 }
1390 a.tab, a.tabact {
1391 color:grey;
1392 text-decoration:none;
1393 display: block;
1394 width:auto;
1395 padding:2px;
1396 padding-left:3px;
1397 padding-right:5px;
1398 }
1399 a.tabact {
1400 padding-left:10px;
1401 padding-right:10px;
1402 }
1403 a.tab:hover,a.tabact:hover {
1404 color:black;
1405 background: '.$hoverBgColor.';
1406 text-decoration:none;
1407 cursor: pointer;
1408 }';
1409 }
1410 return $content;
1411
1412 }
1413
1414
1415 }
1416
1417
1418
1419 // ******************************
1420 // Extension classes of the template class.
1421 // These are meant to provide backend screens with different widths.
1422 // They still do because of the different class-prefixes used for the <div>-sections
1423 // but obviously the final width is determined by the stylesheet used.
1424 // ******************************
1425
1426 /**
1427 * 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
1428 * The class were more significant in the past than today.
1429 *
1430 */
1431 class bigDoc extends template {
1432 var $divClass = 'typo3-bigDoc';
1433 }
1434
1435 /**
1436 * Extension class for "template" - used for backend pages without the "document" background image
1437 * The class were more significant in the past than today.
1438 *
1439 */
1440 class noDoc extends template {
1441 var $divClass = 'typo3-noDoc';
1442 }
1443
1444 /**
1445 * 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)
1446 * The class were more significant in the past than today.
1447 *
1448 */
1449 class smallDoc extends template {
1450 var $divClass = 'typo3-smallDoc';
1451 }
1452
1453 /**
1454 * 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.
1455 * The class were more significant in the past than today. But probably you should use this one for most modules you make.
1456 *
1457 */
1458 class mediumDoc extends template {
1459 var $divClass = 'typo3-mediumDoc';
1460 }
1461
1462
1463
1464 // Include extension to the template class?
1465 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/template.php']) {
1466 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/template.php']);
1467 }
1468
1469
1470
1471 // ******************************************************
1472 // The backend language engine is started (ext: "lang")
1473 // ******************************************************
1474 require_once(PATH_typo3.'sysext/lang/lang.php');
1475 $LANG = t3lib_div::makeInstance('language');
1476 $LANG->init($BE_USER->uc['lang']);
1477
1478
1479
1480 // ******************************
1481 // The template is loaded
1482 // ******************************
1483 $TBE_TEMPLATE = t3lib_div::makeInstance('template');
1484 ?>