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