See changelog
[Packages/TYPO3.CMS.git] / typo3 / template.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2004 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 * 133: function fw($str)
40 *
41 *
42 * 157: class template
43 * 212: function template()
44 *
45 * SECTION: EVALUATION FUNCTIONS
46 * 284: function wrapClickMenuOnIcon($str,$table,$uid='',$listFr=1,$addParams='')
47 * 301: function viewPageIcon($id,$backPath,$addParams='hspace="3"')
48 * 326: function issueCommand($params,$rUrl='')
49 * 341: function isCMlayers()
50 * 351: function thisBlur()
51 * 361: function helpStyle()
52 * 378: function getHeader($table,$row,$path,$noViewPageIcon=0,$tWrap=array('',''))
53 * 404: function getFileheader($title,$path,$iconfile)
54 * 419: function makeShortcutIcon($gvList,$setList,$modName,$motherModName="")
55 * 452: function makeShortcutUrl($gvList,$setList)
56 * 473: function formWidth($size=48,$textarea=0,$styleOverride='')
57 * 498: function formWidthText($size=48,$styleOverride='',$wrap='')
58 * 515: function redirectUrls($thisLocation='')
59 * 539: function formatTime($tstamp,$type)
60 * 552: function parseTime()
61 *
62 * SECTION: PAGE BUILDING FUNCTIONS.
63 * 585: function startPage($title)
64 * 660: function endPage()
65 * 689: function header($text)
66 * 710: function section($label,$text,$nostrtoupper=FALSE,$sH=FALSE,$type=0,$allowHTMLinHeader=FALSE)
67 * 734: function divider($dist)
68 * 750: function spacer($dist)
69 * 769: function sectionHeader($label,$sH=FALSE,$addAttrib='')
70 * 786: function sectionBegin()
71 * 807: function sectionEnd()
72 * 827: function middle()
73 * 836: function endPageJS()
74 * 853: function docBodyTagBegin()
75 * 863: function docStyle()
76 * 904: function insertStylesAndJS($content)
77 * 924: function initCharset()
78 * 936: function generator()
79 *
80 * SECTION: OTHER ELEMENTS
81 * 968: function icons($type)
82 * 997: function t3Button($onClick,$label)
83 * 1008: function dfw($string)
84 * 1018: function rfw($string)
85 * 1028: function wrapInCData($string)
86 * 1045: function wrapScriptTags($string, $linebreak=TRUE)
87 * 1082: function table($arr)
88 * 1122: function menuTable($arr1,$arr2=array(), $arr3=array())
89 * 1155: function funcMenu($content,$menu)
90 * 1173: function clearCacheMenu($id,$addSaveOptions=0)
91 * 1209: function getContextMenuCode()
92 * 1385: function getTabMenu($id,$elementName,$currentValue,$menuItems,$script='',$addparams='')
93 *
94 *
95 * 1497: class bigDoc extends template
96 *
97 *
98 * 1506: class noDoc extends template
99 *
100 *
101 * 1515: class smallDoc extends template
102 *
103 *
104 * 1524: class mediumDoc extends template
105 *
106 * TOTAL FUNCTIONS: 45
107 * (This index is automatically created/updated by the extension "extdeveval")
108 *
109 */
110
111
112
113 if (!defined('TYPO3_MODE')) die("Can't include this file directly.");
114
115
116
117
118
119
120
121
122
123
124
125
126 /**
127 * Depreciated fontwrap function. Is just transparent now.
128 *
129 * @param string Input string
130 * @return string Output string (in the old days this was wrapped in <font> tags)
131 * @depreciated
132 */
133 function fw($str) {
134 return $str;
135 }
136
137
138 /**
139 * TYPO3 Backend Template Class
140 *
141 * This class contains functions for starting and ending the HTML of backend modules
142 * It also contains methods for outputting sections of content.
143 * Further there are functions for making icons, links, setting form-field widths etc.
144 * Color scheme and stylesheet definitions are also available here.
145 * Finally this file includes the language class for TYPO3's backend.
146 *
147 * After this file $LANG and $TBE_TEMPLATE are global variables / instances of their respective classes.
148 * This file is typically included right after the init.php file,
149 * if language and layout is needed.
150 *
151 * Please refer to Inside TYPO3 for a discussion of how to use this API.
152 *
153 * @author Kasper Skaarhoj <kasper@typo3.com>
154 * @package TYPO3
155 * @subpackage core
156 */
157 class template {
158
159 // Vars you typically might want to/should set from outside after making instance of this class:
160 var $backPath = ''; // 'backPath' pointing back to the PATH_typo3
161 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.
162 var $JScode=''; // Additional header code (eg. a JavaScript section) could be accommulated in this var. It will be directly outputted in the header.
163 var $JScodeArray = array(); // Similar to $JScode but for use as array with associative keys to prevent double inclusion of JS code. a <script> tag is automatically wrapped around.
164 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.
165 var $docType = ''; // Doc-type used in the header. Default is HTML 4. You can also set it to 'strict', 'xhtml_trans', or 'xhtml_frames'.
166
167 // Other vars you can change, but less frequently used:
168 var $scriptID=''; // Script ID.
169 var $bodyTagId=''; // Id which can be set for the body tag. Default value is based on script ID
170 var $bodyTagAdditions=''; // You can add additional attributes to the body-tag through this variable.
171 var $inDocStyles=''; // Additional CSS styles which will be added to the <style> section in the header
172 var $inDocStylesArray=array(); // Like $inDocStyles but for use as array with associative keys to prevent double inclusion of css code
173 var $form_rowsToStylewidth = 9.58; // Multiplication factor for formWidth() input size (default is 48* this value).
174 var $form_largeComp = 1.33; // Compensation for large documents (used in class.t3lib_tceforms.php)
175 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.
176
177 // TYPO3 Colorscheme.
178 // If you want to change this, please do so through a skin using the global var $TBE_STYLES
179 var $bgColor = '#F7F3EF'; // Light background color
180 var $bgColor2 = '#9BA1A8'; // Steel-blue
181 var $bgColor3 = '#F6F2E6'; // dok.color
182 var $bgColor4 = '#D9D5C9'; // light tablerow background, brownish
183 var $bgColor5 = '#ABBBB4'; // light tablerow background, greenish
184 var $bgColor6 = '#E7DBA8'; // light tablerow background, yellowish, for section headers. Light.
185 var $hoverColor = '#254D7B';
186 var $styleSheetFile = 'stylesheet.css'; // Filename of stylesheet (relative to PATH_typo3)
187 var $styleSheetFile2 = ''; // Filename of stylesheet #2 - linked to right after the $this->styleSheetFile script (relative to PATH_typo3)
188 var $styleSheetFile_post = ''; // Filename of a post-stylesheet - included right after all inline styles.
189 var $backGroundImage = ''; // Background image of page (relative to PATH_typo3)
190 var $inDocStyles_TBEstyle = ''; // Inline css styling set from TBE_STYLES array
191
192 // DEV:
193 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.
194
195 // INTERNAL
196 var $charset = 'iso-8859-1'; // Default charset. see function initCharset()
197
198 var $sectionFlag=0; // Internal: Indicates if a <div>-output section is open
199 var $divClass = ''; // (Default) Class for wrapping <DIV>-tag of page. Is set in class extensions.
200
201
202
203
204
205
206 /**
207 * Constructor
208 * Imports relevant parts from global $TBE_STYLES (colorscheme)
209 *
210 * @return void
211 */
212 function template() {
213 global $TBE_STYLES;
214
215 // Setting default scriptID:
216 $this->scriptID = ereg_replace('^.*\/(sysext|ext)\/','ext/',substr(PATH_thisScript,strlen(PATH_site)));
217 if (TYPO3_mainDir!='typo3/' && substr($this->scriptID,0,strlen(TYPO3_mainDir)) == TYPO3_mainDir) {
218 $this->scriptID = 'typo3/'.substr($this->scriptID,strlen(TYPO3_mainDir)); // This fixes if TYPO3_mainDir has been changed so the script ids are STILL "typo3/..."
219 }
220
221 $this->bodyTagId = ereg_replace('[^[:alnum:]-]','-',$this->scriptID);
222
223 // Individual configuration per script? If so, make a recursive merge of the arrays:
224 if (is_array($TBE_STYLES['scriptIDindex'][$this->scriptID])) {
225 $ovr = $TBE_STYLES['scriptIDindex'][$this->scriptID]; // Make copy
226 $TBE_STYLES = t3lib_div::array_merge_recursive_overrule($TBE_STYLES,$ovr); // merge styles.
227 unset($TBE_STYLES['scriptIDindex'][$this->scriptID]); // Have to unset - otherwise the second instantiation will do it again!
228 }
229
230 // Color scheme:
231 if ($TBE_STYLES['mainColors']['bgColor']) $this->bgColor=$TBE_STYLES['mainColors']['bgColor'];
232 if ($TBE_STYLES['mainColors']['bgColor1']) $this->bgColor1=$TBE_STYLES['mainColors']['bgColor1'];
233 if ($TBE_STYLES['mainColors']['bgColor2']) $this->bgColor2=$TBE_STYLES['mainColors']['bgColor2'];
234 if ($TBE_STYLES['mainColors']['bgColor3']) $this->bgColor3=$TBE_STYLES['mainColors']['bgColor3'];
235 if ($TBE_STYLES['mainColors']['bgColor4']) $this->bgColor4=$TBE_STYLES['mainColors']['bgColor4'];
236 if ($TBE_STYLES['mainColors']['bgColor5']) $this->bgColor5=$TBE_STYLES['mainColors']['bgColor5'];
237 if ($TBE_STYLES['mainColors']['bgColor6']) $this->bgColor6=$TBE_STYLES['mainColors']['bgColor6'];
238 if ($TBE_STYLES['mainColors']['hoverColor']) $this->hoverColor=$TBE_STYLES['mainColors']['hoverColor'];
239
240 // Main Stylesheets:
241 if ($TBE_STYLES['stylesheet']) $this->styleSheetFile = $TBE_STYLES['stylesheet'];
242 if ($TBE_STYLES['stylesheet2']) $this->styleSheetFile2 = $TBE_STYLES['stylesheet2'];
243 if ($TBE_STYLES['styleSheetFile_post']) $this->styleSheetFile_post = $TBE_STYLES['styleSheetFile_post'];
244 if ($TBE_STYLES['inDocStyles_TBEstyle']) $this->inDocStyles_TBEstyle = $TBE_STYLES['inDocStyles_TBEstyle'];
245
246 // Background image
247 if ($TBE_STYLES['background']) $this->backGroundImage = $TBE_STYLES['background'];
248 }
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265 /*****************************************
266 *
267 * EVALUATION FUNCTIONS
268 * Various centralized processing
269 *
270 *****************************************/
271
272 /**
273 * Makes click menu link (context sensitive menu)
274 * 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)
275 * 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)
276 *
277 * @param string String to be wrapped in link, typ. image tag.
278 * @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
279 * @param integer If icon is for database record this is the UID for the record from $table
280 * @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.
281 * @param string Additional GET parameters for the link to alt_clickmenu.php
282 * @param string Enable / Disable click menu items. Example: "+new,view" will display ONLY these two items (and any spacers in between), "new,view" will display all BUT these two items.
283 * @param boolean If set, will return only the onclick JavaScript, not the whole link.
284 * @return string The link-wrapped input string.
285 */
286 function wrapClickMenuOnIcon($str,$table,$uid='',$listFr=1,$addParams='',$enDisItems='', $returnOnClick=FALSE) {
287 $backPath = '&backPath='.rawurlencode($this->backPath).'|'.t3lib_div::shortMD5($this->backPath.'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']);
288 $onClick = 'top.loadTopMenu(\''.$this->backPath.'alt_clickmenu.php?item='.rawurlencode($table.'|'.$uid.'|'.$listFr.'|'.$enDisItems).$backPath.$addParams.'\');'.$this->thisBlur().'return false;';
289 return $returnOnClick ? $onClick : '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.$str.'</a>';
290 }
291
292 /**
293 * Makes link to page $id in frontend (view page)
294 * Returns an magnifier-glass icon which links to the frontend index.php document for viewing the page with id $id
295 * $id must be a page-uid
296 * If the BE_USER has access to Web>List then a link to that module is shown as well (with return-url)
297 *
298 * @param integer The page id
299 * @param string The current "BACK_PATH" (the back relative to the typo3/ directory)
300 * @param string Additional parameters for the image tag(s)
301 * @return string HTML string with linked icon(s)
302 */
303 function viewPageIcon($id,$backPath,$addParams='hspace="3"') {
304 global $BE_USER;
305 $str = '';
306 // If access to Web>List for user, then link to that module.
307 if ($BE_USER->check('modules','web_list')) {
308 $href=$backPath.'db_list.php?id='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
309 $str.= '<a href="'.htmlspecialchars($href).'">'.
310 '<img'.t3lib_iconWorks::skinImg($backPath,'gfx/list.gif','width="11" height="11"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList',1).'"'.($addParams?' '.trim($addParams):'').' alt="" />'.
311 '</a>';
312 }
313 // Make link to view page
314 $str.= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($id,$backPath,t3lib_BEfunc::BEgetRootLine($id))).'">'.
315 '<img'.t3lib_iconWorks::skinImg($backPath,'gfx/zoom.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage',1).'"'.($addParams?' '.trim($addParams):"").' hspace="3" alt="" />'.
316 '</a>';
317 return $str;
318 }
319
320 /**
321 * Returns a URL with a command to TYPO3 Core Engine (tce_db.php)
322 * See description of the API elsewhere.
323 *
324 * @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"
325 * @param string Redirect URL if any other that t3lib_div::getIndpEnv('REQUEST_URI') is wished
326 * @return string URL to tce_db.php + parameters (backpath is taken from $this->backPath)
327 * @see t3lib_BEfunc::editOnClick()
328 */
329 function issueCommand($params,$rUrl='') {
330 $rUrl = $rUrl ? $rUrl : t3lib_div::getIndpEnv('REQUEST_URI');
331 return $this->backPath.'tce_db.php?'.
332 $params.
333 '&redirect='.($rUrl==-1?"'+T3_THIS_LOCATION+'":rawurlencode($rUrl)).
334 '&vC='.rawurlencode($GLOBALS['BE_USER']->veriCode()).
335 '&prErr=1&uPT=1';
336 }
337
338 /**
339 * Returns true if click-menu layers can be displayed for the current user/browser
340 * Use this to test if click-menus (context sensitive menus) can and should be displayed in the backend.
341 *
342 * @return boolean
343 */
344 function isCMlayers() {
345 return !$GLOBALS['BE_USER']->uc['disableCMlayers'] && $GLOBALS['CLIENT']['FORMSTYLE'] && $GLOBALS['CLIENT']['SYSTEM']!='mac';
346 }
347
348 /**
349 * Returns 'this.blur();' if the client supports CSS styles
350 * Use this in links to remove the underlining after being clicked
351 *
352 * @return string
353 */
354 function thisBlur() {
355 return ($GLOBALS['CLIENT']['FORMSTYLE']?'this.blur();':'');
356 }
357
358 /**
359 * Returns ' style='cursor:help;'' if the client supports CSS styles
360 * Use for <a>-links to help texts
361 *
362 * @return string
363 */
364 function helpStyle() {
365 return $GLOBALS['CLIENT']['FORMSTYLE'] ? ' style="cursor:help;"':'';
366 }
367
368 /**
369 * Makes the header (icon+title) for a page (or other record). Used in most modules under Web>*
370 * $table and $row must be a tablename/record from that table
371 * $path will be shown as alt-text for the icon.
372 * The title will be truncated to 45 chars.
373 *
374 * @param string Table name
375 * @param array Record row
376 * @param string Alt text
377 * @param boolean Set $noViewPageIcon true if you don't want a magnifier-icon for viewing the page in the frontend
378 * @param array $tWrap is an array with indexes 0 and 1 each representing HTML-tags (start/end) which will wrap the title
379 * @return string HTML content
380 */
381 function getHeader($table,$row,$path,$noViewPageIcon=0,$tWrap=array('','')) {
382 global $TCA;
383 if (is_array($row) && $row['uid']) {
384 $iconImgTag=t3lib_iconWorks::getIconImage($table,$row,$this->backPath,'title="'.htmlspecialchars($path).'"');
385 $title= strip_tags($row[$TCA[$table]['ctrl']['label']]);
386 $viewPage = $noViewPageIcon ? '' : $this->viewPageIcon($row['uid'],$this->backPath,'');
387 if ($table=='pages') $path.=' - '.t3lib_BEfunc::titleAttribForPages($row,'',0);
388 } else {
389 $iconImgTag='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/_icon_website.gif',$wHattribs='width="18" height="16"').' title="'.htmlspecialchars($path).'" alt="" />';
390 $title=$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
391 }
392
393 return '<span class="typo3-moduleHeader">'.$this->wrapClickMenuOnIcon($iconImgTag,$table,$row['uid']).
394 $viewPage.
395 $tWrap[0].htmlspecialchars(t3lib_div::fixed_lgd_cs($title,45)).$tWrap[1].'</span>';
396 }
397
398 /**
399 * Like ->getHeader() but for files in the File>* main module/submodules
400 * Returns the file-icon with the path of the file set in the alt/title attribute. Shows the file-name after the icon.
401 *
402 * @param string Title string, expected to be the filepath
403 * @param string Alt text
404 * @param string The icon file (relative to TYPO3 dir)
405 * @return string HTML content
406 */
407 function getFileheader($title,$path,$iconfile) {
408 $fileInfo = t3lib_div::split_fileref($title);
409 $title = htmlspecialchars(t3lib_div::fixed_lgd_cs($fileInfo['path'],-35)).'<b>'.htmlspecialchars($fileInfo['file']).'</b>';
410 return '<span class="typo3-moduleHeader"><img'.t3lib_iconWorks::skinImg($this->backPath,$iconfile,'width="18" height="16"').' title="'.htmlspecialchars($path).'" alt="" />'.$title.'</span>';
411 }
412
413 /**
414 * Returns a linked shortcut-icon which will call the shortcut frame and set a shortcut there back to the calling page/module
415 *
416 * @param string Is the list of GET variables to store (if any)
417 * @param string Is the list of SET[] variables to store (if any) - SET[] variables a stored in $GLOBALS["SOBE"]->MOD_SETTINGS for backend modules
418 * @param string Module name string
419 * @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.
420 * @return string HTML content
421 */
422 function makeShortcutIcon($gvList,$setList,$modName,$motherModName="") {
423 $backPath=$this->backPath;
424 $storeUrl=$this->makeShortcutUrl($gvList,$setList);
425 $pathInfo = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
426
427 if (!strcmp($motherModName,'1')) {
428 $mMN="&motherModName='+top.currentModuleLoaded+'";
429 } elseif ($motherModName) {
430 $mMN='&motherModName='.rawurlencode($motherModName);
431 } else $mMN="";
432
433 $onClick = 'if (top.shortcutFrame && confirm('.
434 $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.makeShortcut')).
435 ')){top.shortcutFrame.document.location=\''.$backPath.'alt_shortcut.php?modName='.rawurlencode($modName).
436 '&URL='.rawurlencode($pathInfo['path']."?".$storeUrl).
437 $mMN.
438 '\';}return false;';
439
440 $sIcon = '<a href="#" onclick="'.htmlspecialchars($onClick).'">
441 <img'.t3lib_iconWorks::skinImg($backPath,'gfx/shortcut.gif','width="14" height="14"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.makeShortcut',1).'" alt="" /></a>';
442 return $sIcon;
443 }
444
445 /**
446 * MAKE url for storing
447 * Internal func
448 *
449 * @param string Is the list of GET variables to store (if any)
450 * @param string Is the list of SET[] variables to store (if any) - SET[] variables a stored in $GLOBALS["SOBE"]->MOD_SETTINGS for backend modules
451 * @return string
452 * @access private
453 * @see makeShortcutIcon()
454 */
455 function makeShortcutUrl($gvList,$setList) {
456 $GET = t3lib_div::_GET();
457 $storeArray = array_merge(
458 t3lib_div::compileSelectedGetVarsFromArray($gvList,$GET),
459 array('SET'=>t3lib_div::compileSelectedGetVarsFromArray($setList,$GLOBALS['SOBE']->MOD_SETTINGS))
460 );
461 $storeUrl = t3lib_div::implodeArrayForUrl('',$storeArray);
462 return $storeUrl;
463 }
464
465 /**
466 * Returns <input> attributes to set the width of an text-type input field.
467 * For client browsers with no CSS support the cols/size attribute is returned.
468 * For CSS compliant browsers (recommended) a ' style="width: ...px;"' is returned.
469 *
470 * @param integer A relative number which multiplied with approx. 10 will lead to the width in pixels
471 * @param boolean A flag you can set for textareas - DEPRECIATED, use ->formWidthText() for textareas!!!
472 * @param string A string which will be returned as attribute-value for style="" instead of the calculated width (if CSS is enabled)
473 * @return string Tag attributes for an <input> tag (regarding width)
474 * @see formWidthText()
475 */
476 function formWidth($size=48,$textarea=0,$styleOverride='') {
477 $wAttrib = $textarea?'cols':'size';
478 if (!$GLOBALS['CLIENT']['FORMSTYLE']) { // If not setting the width by style-attribute
479 $size = $size;
480 $retVal = ' '.$wAttrib.'="'.$size.'"';
481 } else { // Setting width by style-attribute. 'cols' MUST be avoided with NN6+
482 $pixels = ceil($size*$this->form_rowsToStylewidth);
483 $retVal = $styleOverride ? ' style="'.$styleOverride.'"' : ' style="width:'.$pixels.'px;"';
484 }
485 return $retVal;
486 }
487
488 /**
489 * This function is dedicated to textareas, which has the wrapping on/off option to observe.
490 * EXAMPLE:
491 * <textarea rows="10" wrap="off" '.$GLOBALS["TBE_TEMPLATE"]->formWidthText(48,"","off").'>
492 * or
493 * <textarea rows="10" wrap="virtual" '.$GLOBALS["TBE_TEMPLATE"]->formWidthText(48,"","virtual").'>
494 *
495 * @param integer A relative number which multiplied with approx. 10 will lead to the width in pixels
496 * @param string A string which will be returned as attribute-value for style="" instead of the calculated width (if CSS is enabled)
497 * @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.
498 * @return string Tag attributes for an <input> tag (regarding width)
499 * @see formWidth()
500 */
501 function formWidthText($size=48,$styleOverride='',$wrap='') {
502 $wTags = $this->formWidth($size,1,$styleOverride);
503 // 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...
504 if (strtolower(trim($wrap))!='off' && $GLOBALS['CLIENT']['BROWSER']=='net' && $GLOBALS['CLIENT']['VERSION']>=5) {
505 $wTags.=' cols="'.$size.'"';
506 }
507 return $wTags;
508 }
509
510 /**
511 * Returns JavaScript variables setting the returnUrl and thisScript location for use by JavaScript on the page.
512 * Used in fx. db_list.php (Web>List)
513 *
514 * @param string URL to "this location" / current script
515 * @return string
516 * @see typo3/db_list.php
517 */
518 function redirectUrls($thisLocation='') {
519 $thisLocation = $thisLocation?$thisLocation:t3lib_div::linkThisScript(
520 array(
521 'CB'=>'',
522 'SET'=>'',
523 'cmd' => '',
524 'popViewId'=>''
525 ));
526
527 $out ="
528 var T3_RETURN_URL = '".str_replace('%20','',rawurlencode(t3lib_div::_GP('returnUrl')))."';
529 var T3_THIS_LOCATION = '".str_replace('%20','',rawurlencode($thisLocation))."';
530 ";
531 return $out;
532 }
533
534 /**
535 * Returns a formatted string of $tstamp
536 * Uses $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] and $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] to format date and time
537 *
538 * @param integer UNIX timestamp, seconds since 1970
539 * @param integer How much data to show: $type = 1: hhmm, $type = 10: ddmmmyy
540 * @return string Formatted timestamp
541 */
542 function formatTime($tstamp,$type) {
543 switch($type) {
544 case 1: return date($GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'],$tstamp); break;
545 case 10: return date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'],$tstamp); break;
546 }
547 }
548
549 /**
550 * Returns script parsetime IF ->parseTimeFlag is set and user is "admin"
551 * Automatically outputted in page end
552 *
553 * @return string
554 */
555 function parseTime() {
556 if ($this->parseTimeFlag && $GLOBALS['BE_USER']->isAdmin()) {
557 return '<p>(ParseTime: '.(t3lib_div::milliseconds()-$GLOBALS['PARSETIME_START']).' ms</p>
558 <p>REQUEST_URI-length: '.strlen(t3lib_div::getIndpEnv('REQUEST_URI')).')</p>';
559 }
560 }
561
562
563
564
565
566
567
568
569
570
571
572
573 /*****************************************
574 *
575 * PAGE BUILDING FUNCTIONS.
576 * Use this to build the HTML of your backend modules
577 *
578 *****************************************/
579
580 /**
581 * Returns page start
582 * This includes the proper header with charset, title, meta tag and beginning body-tag.
583 *
584 * @param string HTML Page title for the header
585 * @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)
586 * @see endPage()
587 */
588 function startPage($title) {
589 // Get META tag containing the currently selected charset for backend output. The function sets $this->charSet.
590 $charSet = $this->initCharset();
591 $generator = $this->generator();
592
593 // For debugging: If this outputs "QuirksMode"/"BackCompat" (IE) the browser runs in quirks-mode. Otherwise the value is "CSS1Compat"
594 # $this->JScodeArray[]='alert(document.compatMode);';
595
596 // Send HTTP header for selected charset. Added by Robert Lemke 23.10.2003
597 header ('Content-Type:text/html;charset='.$this->charset);
598
599 switch($this->docType) {
600 case 'xhtml_strict':
601 $headerStart= '<!DOCTYPE html
602 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
603 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
604 <?xml version="1.0" encoding="'.$this->charset.'"?>
605 <?xml-stylesheet href="#internalStyle" type="text/css"?>
606 ';
607 break;
608 case 'xhtml_trans':
609 $headerStart= '<!DOCTYPE html
610 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
611 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
612 <?xml version="1.0" encoding="'.$this->charset.'"?>
613 <?xml-stylesheet href="#internalStyle" type="text/css"?>
614 ';
615 break;
616 case 'xhtml_frames':
617 $headerStart= '<!DOCTYPE html
618 PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
619 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
620 <?xml version="1.0" encoding="'.$this->charset.'"?>
621 ';
622 break;
623 default:
624 $headerStart='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">';
625 break;
626 }
627
628 // Construct page header.
629 $str = $headerStart.'
630 <html>
631 <head>
632 <!-- TYPO3 Script ID: '.htmlspecialchars($this->scriptID).' -->
633 '.$charSet.'
634 '.$generator.'
635 <title>'.htmlspecialchars($title).'</title>
636 '.$this->docStyle().'
637 '.$this->JScode.'
638 '.$this->wrapScriptTags(implode("\n", $this->JScodeArray)).'
639 <!--###POSTJSMARKER###-->
640 </head>
641 ';
642 $this->JScode='';
643 $this->JScodeArray=array();
644
645 if ($this->docType=='xhtml_frames') {
646 return $str;
647 } else
648 $str.=$this->docBodyTagBegin().
649 ($this->divClass?'
650
651 <!-- Wrapping DIV-section for whole page BEGIN -->
652 <div class="'.$this->divClass.'">
653 ':'').trim($this->form);
654 return $str;
655 }
656
657 /**
658 * Returns page end; This includes finishing form, div, body and html tags.
659 *
660 * @return string The HTML end of a page
661 * @see startPage()
662 */
663 function endPage() {
664 $str = $this->sectionEnd().
665 $this->postCode.
666 $this->endPageJS().
667 t3lib_BEfunc::getSetUpdateSignal().
668 $this->parseTime().
669 ($this->form?'
670 </form>':'').
671 ($this->divClass?'
672
673 <!-- Wrapping DIV-section for whole page END -->
674 </div>':'').
675 '
676 </body>
677 </html> ';
678
679 // Logging: Can't find better place to put it:
680 if (TYPO3_DLOG) t3lib_div::devLog('END of BACKEND session','',0,array('_FLUSH'=>TRUE));
681
682 return $str;
683 }
684
685 /**
686 * Returns the header-bar in the top of most backend modules
687 * Closes section if open.
688 *
689 * @param string The text string for the header
690 * @return string HTML content
691 */
692 function header($text) {
693 $str='
694
695 <!-- MAIN Header in page top -->
696 <h2>'.htmlspecialchars($text).'</h2>
697 ';
698 return $this->sectionEnd().$str;
699 }
700
701 /**
702 * Begins an output section and sets header and content
703 *
704 * @param string The header
705 * @param string The HTML-content
706 * @param boolean A flag that will prevent the header from being converted to uppercase
707 * @param boolean Defines the type of header (if set, "<h3>" rather than the default "h4")
708 * @param integer The number of an icon to show with the header (see the icon-function). -1,1,2,3
709 * @param boolean If set, HTML tags are allowed in $label (otherwise this value is by default htmlspecialchars()'ed)
710 * @return string HTML content
711 * @see icons(), sectionHeader()
712 */
713 function section($label,$text,$nostrtoupper=FALSE,$sH=FALSE,$type=0,$allowHTMLinHeader=FALSE) {
714 $str='';
715
716 // Setting header
717 if ($label) {
718 if (!$allowHTMLinHeader) $label = htmlspecialchars($label);
719 $str.=$this->sectionHeader($this->icons($type).$label, $sH, $nostrtoupper ? '' : ' class="uppercase"');
720 }
721 // Setting content
722 $str.='
723
724 <!-- Section content -->
725 '.$text;
726
727 return $this->sectionBegin().$str;
728 }
729
730 /**
731 * Inserts a divider image
732 * Ends a section (if open) before inserting the image
733 *
734 * @param integer The margin-top/-bottom of the <hr> ruler.
735 * @return string HTML content
736 */
737 function divider($dist) {
738 $dist = intval($dist);
739 $str='
740
741 <!-- DIVIDER -->
742 <hr style="margin-top: '.$dist.'px; margin-bottom: '.$dist.'px;" />
743 ';
744 return $this->sectionEnd().$str;
745 }
746
747 /**
748 * Returns a blank <div>-section with a height
749 *
750 * @param integer Padding-top for the div-section (should be margin-top but konquorer (3.1) don't like it :-(
751 * @return string HTML content
752 */
753 function spacer($dist) {
754 if ($dist>0) {
755 return '
756
757 <!-- Spacer element -->
758 <div style="padding-top: '.intval($dist).'px;"></div>
759 ';
760 }
761 }
762
763 /**
764 * Make a section header.
765 * Begins a section if not already open.
766 *
767 * @param string The label between the <h3> or <h4> tags. (Allows HTML)
768 * @param boolean If set, <h3> is used, otherwise <h4>
769 * @param string Additional attributes to h-tag, eg. ' class=""'
770 * @return string HTML content
771 */
772 function sectionHeader($label,$sH=FALSE,$addAttrib='') {
773 $tag = ($sH?'h3':'h4');
774 $str='
775
776 <!-- Section header -->
777 <'.$tag.$addAttrib.'>'.$label.'</'.$tag.'>
778 ';
779 return $this->sectionBegin().$str;
780 }
781
782 /**
783 * Begins an output section.
784 * Returns the <div>-begin tag AND sets the ->sectionFlag true (if the ->sectionFlag is not already set!)
785 * 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!
786 *
787 * @return string HTML content
788 */
789 function sectionBegin() {
790 if (!$this->sectionFlag) {
791 $this->sectionFlag=1;
792 $str='
793
794 <!-- ***********************
795 Begin output section.
796 *********************** -->
797 <div>
798 ';
799 return $str;
800 } else return '';
801 }
802
803 /**
804 * Ends and output section
805 * Returns the </div>-end tag AND clears the ->sectionFlag (but does so only IF the sectionFlag is set - that is a section is 'open')
806 * See sectionBegin() also.
807 *
808 * @return string HTML content
809 */
810 function sectionEnd() {
811 if ($this->sectionFlag) {
812 $this->sectionFlag=0;
813 return '
814 </div>
815 <!-- *********************
816 End output section.
817 ********************* -->
818 ';
819 } else return '';
820 }
821
822 /**
823 * Originally it printed a kind of divider.
824 * Depreciated. Just remove function calls to it or call the divider() function instead.
825 *
826 * @return void
827 * @internal
828 * @depreciated
829 */
830 function middle() {
831 }
832
833 /**
834 * If a form-tag is defined in ->form then and end-tag for that <form> element is outputted
835 * Further a JavaScript section is outputted which will update the top.busy session-expiry object (unless $this->endJS is set to false)
836 *
837 * @return string HTML content (<script> tag section)
838 */
839 function endPageJS() {
840 return ($this->endJS?'
841 <script type="text/javascript">
842 /*<![CDATA[*/
843 if (top.busy && top.busy.loginRefreshed) {
844 top.busy.loginRefreshed();
845 }
846 /*]]>*/
847 </script>':'');
848 }
849
850 /**
851 * Creates the bodyTag.
852 * You can add to the bodyTag by $this->bodyTagAdditions
853 *
854 * @return string HTML body tag
855 */
856 function docBodyTagBegin() {
857 $bodyContent = 'body '.trim($this->bodyTagAdditions.($this->bodyTagId ? ' id="'.$this->bodyTagId.'"' : ''));
858 return '<'.trim($bodyContent).'>';
859 }
860
861 /**
862 * Outputting document style
863 *
864 * @return string HTML style section/link tags
865 */
866 function docStyle() {
867
868 // Request background image:
869 if ($this->backGroundImage) {
870 $this->inDocStylesArray[]=' BODY { background-image: url('.$this->backPath.$this->backGroundImage.'); }';
871 }
872
873 // Add inDoc styles variables as well:
874 $this->inDocStylesArray[] = $this->inDocStyles;
875 $this->inDocStylesArray[] = $this->inDocStyles_TBEstyle;
876
877 // Implode it all:
878 $inDocStyles = implode('
879 ',$this->inDocStylesArray);
880
881 // The default color scheme should also in full be represented in the stylesheet.
882 $style=trim('
883 '.($this->styleSheetFile?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile.'" />':'').'
884 '.($this->styleSheetFile2?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile2.'" />':'').'
885 <style type="text/css" id="internalStyle">
886 /*<![CDATA[*/
887 '.trim($inDocStyles).'
888 /*###POSTCSSMARKER###*/
889 /*]]>*/
890 </style>
891 '.($this->styleSheetFile_post?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile_post.'" />':'')
892 )
893 ;
894 $this->inDocStyles='';
895 $this->inDocStylesArray=array();
896
897 return '
898 '.$style;
899 }
900
901 /**
902 * Insert post rendering document style into already rendered content
903 * This is needed for extobjbase
904 *
905 * @param string style-content to insert.
906 * @return string content with inserted styles
907 */
908 function insertStylesAndJS($content) {
909 // insert accumulated CSS
910 $this->inDocStylesArray[] = $this->inDocStyles;
911 $styles = "\n".implode("\n", $this->inDocStylesArray);
912 $content = str_replace('/*###POSTCSSMARKER###*/',$styles,$content);
913
914 // insert accumulated JS
915 $jscode = $this->JScode."\n".$this->wrapScriptTags(implode("\n", $this->JScodeArray));
916 $content = str_replace('<!--###POSTJSMARKER###-->',$jscode,$content);
917
918 return $content;
919 }
920
921 /**
922 * Initialize the charset.
923 * Sets the internal $this->charset variable to the charset defined in $GLOBALS["LANG"] (or the default as set in this class)
924 * Returns the meta-tag for the document header
925 *
926 * @return string <meta> tag with charset from $this->charset or $GLOBALS['LANG']->charSet
927 */
928 function initCharset() {
929 // Set charset to the charset provided by the current backend users language selection:
930 $this->charset = $GLOBALS['LANG']->charSet ? $GLOBALS['LANG']->charSet : $this->charset;
931 // Return meta tag:
932 return '<meta http-equiv="Content-Type" content="text/html; charset='.$this->charset.'" />';
933 }
934
935 /**
936 * Returns generator meta tag
937 *
938 * @return string <meta> tag with name "GENERATOR"
939 */
940 function generator() {
941 $str = 'TYPO3 '.$GLOBALS['TYPO_VERSION'].', http://typo3.com, &#169; Kasper Sk&#229;rh&#248;j 1998-2004, extensions are copyright of their respective owners.';
942 return '<meta name="GENERATOR" content="'.$str .'" />';
943 }
944
945
946
947
948
949
950
951
952 /*****************************************
953 *
954 * OTHER ELEMENTS
955 * Tables, buttons, formatting dimmed/red strings
956 *
957 ******************************************/
958
959
960 /**
961 * Returns an image-tag with an 18x16 icon of the following types:
962 *
963 * $type:
964 * -1: OK icon (Check-mark)
965 * 1: Notice (Speach-bubble)
966 * 2: Warning (Yellow triangle)
967 * 3: Fatal error (Red stop sign)
968 *
969 * @param integer See description
970 * @param string Value for style attribute
971 * @return string HTML image tag (if applicable)
972 */
973 function icons($type, $styleAttribValue='') {
974 switch($type) {
975 case '3':
976 $icon = 'gfx/icon_fatalerror.gif';
977 break;
978 case '2':
979 $icon = 'gfx/icon_warning.gif';
980 break;
981 case '1':
982 $icon = 'gfx/icon_note.gif';
983 break;
984 case '-1':
985 $icon = 'gfx/icon_ok.gif';
986 break;
987 default:
988 break;
989 }
990 if ($icon) {
991 return '<img'.t3lib_iconWorks::skinImg($this->backPath,$icon,'width="18" height="16"').' class="absmiddle"'.($styleAttribValue ? ' style="'.htmlspecialchars($styleAttribValue).'"' : '').' alt="" />';
992 }
993 }
994
995 /**
996 * Returns an <input> button with the $onClick action and $label
997 *
998 * @param string The value of the onclick attribute of the input tag (submit type)
999 * @param string The label for the button (which will be htmlspecialchar'ed)
1000 * @return string A <input> tag of the type "submit"
1001 */
1002 function t3Button($onClick,$label) {
1003 $button = '<input type="submit" onclick="'.htmlspecialchars($onClick).'; return false;" value="'.htmlspecialchars($label).'" />';
1004 return $button;
1005 }
1006
1007 /**
1008 * dimmed-fontwrap. Returns the string wrapped in a <span>-tag defining the color to be gray/dimmed
1009 *
1010 * @param string Input string
1011 * @return string Output string
1012 */
1013 function dfw($string) {
1014 return '<span class="typo3-dimmed">'.$string.'</span>';
1015 }
1016
1017 /**
1018 * red-fontwrap. Returns the string wrapped in a <span>-tag defining the color to be red
1019 *
1020 * @param string Input string
1021 * @return string Output string
1022 */
1023 function rfw($string) {
1024 return '<span class="typo3-red">'.$string.'</span>';
1025 }
1026
1027 /**
1028 * Returns string wrapped in CDATA "tags" for XML / XHTML (wrap content of <script> and <style> sections in those!)
1029 *
1030 * @param string Input string
1031 * @return string Output string
1032 */
1033 function wrapInCData($string) {
1034 $string = '/*<![CDATA[*/'.
1035 $string.
1036 '/*]]>*/';
1037
1038 return $string;
1039 }
1040
1041 /**
1042 * Wraps the input string in script tags.
1043 * Automatic re-identing of the JS code is done by using the first line as ident reference.
1044 * This is nice for identing JS code with PHP code on the same level.
1045 *
1046 * @param string Input string
1047 * @param boolean Wrap script element in linebreaks? Default is TRUE.
1048 * @return string Output string
1049 */
1050 function wrapScriptTags($string, $linebreak=TRUE) {
1051 if(trim($string)) {
1052 // <script wrapped in nl?
1053 $cr = $linebreak? "\n" : '';
1054
1055 // remove nl from the beginning
1056 $string = preg_replace ('/^\n+/', '', $string);
1057 // re-ident to one tab using the first line as reference
1058 if(preg_match('/^(\t+)/',$string,$match)) {
1059 $string = str_replace($match[1],"\t", $string);
1060 }
1061 $string = $cr.'<script type="text/javascript">
1062 /*<![CDATA[*/
1063 '.$string.'
1064 /*]]>*/
1065 </script>'.$cr;
1066 }
1067 return trim($string);
1068 }
1069
1070 // These vars defines the layout for the table produced by the table() function.
1071 // You can override these values from outside if you like.
1072 var $tableLayout = Array (
1073 'defRow' => Array (
1074 'defCol' => Array('<td valign="top">','</td>')
1075 )
1076 );
1077 var $table_TR = '<tr>';
1078 var $table_TABLE = '<table border="0" cellspacing="0" cellpadding="0" id="typo3-tmpltable">';
1079
1080 /**
1081 * Returns a table based on the input $arr
1082 *
1083 * @param array Multidim array with first levels = rows, second levels = cells
1084 * @return string The HTML table.
1085 * @internal
1086 */
1087 function table($arr, $layout='') {
1088 if (is_array($arr)) {
1089 $tableLayout = (is_array($layout)) ? $layout : $this->tableLayout;
1090
1091 reset($arr);
1092 $code='';
1093 $rc=0;
1094 while(list(,$val)=each($arr)) {
1095 if ($rc % 2) {
1096 $layout = is_array($tableLayout['defRowOdd']) ? $tableLayout['defRowOdd'] : $tableLayout['defRow'];
1097 } else {
1098 $layout = is_array($tableLayout['defRowEven']) ? $tableLayout['defRowEven'] : $tableLayout['defRow'];
1099 }
1100 $layoutRow = is_array($tableLayout[$rc]) ? $tableLayout[$rc] : $layout;
1101 $code_td='';
1102 if (is_array($val)) {
1103 $cc=0;
1104 while(list(,$content)=each($val)) {
1105 $wrap= is_array($layoutRow[$cc]) ? $layoutRow[$cc] : (is_array($layoutRow['defCol']) ? $layoutRow['defCol'] : (is_array($layout[$cc]) ? $layout[$cc] : $layout['defCol']));
1106 $code_td.=$wrap[0].$content.$wrap[1];
1107 $cc++;
1108 }
1109 }
1110 $trWrap = is_array($layoutRow['tr']) ? $layoutRow['tr'] : (is_array($layout['tr']) ? $layout['tr'] : array($this->table_TR, '</tr>'));
1111 $code.=$trWrap[0].$code_td.$trWrap[1];
1112 $rc++;
1113 }
1114 $tableWrap = is_array($tableLayout['table']) ? $tableLayout['table'] : array($this->table_TABLE, '</table>');
1115 $code=$tableWrap[0].$code.$tableWrap[1];
1116 }
1117 return $code;
1118 }
1119
1120 /**
1121 * Constructs a table with content from the $arr1, $arr2 and $arr3.
1122 * Used in eg. ext/belog/mod/index.php - refer to that for examples
1123 *
1124 * @param array Menu elements on first level
1125 * @param array Secondary items
1126 * @param array Third-level items
1127 * @return string HTML content, <table>...</table>
1128 */
1129 function menuTable($arr1,$arr2=array(), $arr3=array()) {
1130 $rows = max(array(count($arr1),count($arr2),count($arr3)));
1131
1132 $menu='
1133 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tablemenu">';
1134 for($a=0;$a<$rows;$a++) {
1135 $menu.='<tr>';
1136 $cls=array();
1137 $valign='middle';
1138 $cls[]='<td valign="'.$valign.'">'.$arr1[$a][0].'</td><td>'.$arr1[$a][1].'</td>';
1139 if (count($arr2)) {
1140 $cls[]='<td valign="'.$valign.'">'.$arr2[$a][0].'</td><td>'.$arr2[$a][1].'</td>';
1141 if (count($arr3)) {
1142 $cls[]='<td valign="'.$valign.'">'.$arr3[$a][0].'</td><td>'.$arr3[$a][1].'</td>';
1143 }
1144 }
1145 $menu.=implode($cls,'<td>&nbsp;&nbsp;</td>');
1146 $menu.='</tr>';
1147 }
1148 $menu.='
1149 </table>
1150 ';
1151 return $menu;
1152 }
1153
1154 /**
1155 * Returns a one-row/two-celled table with $content and $menu side by side.
1156 * The table is a 100% width table and each cell is aligned left / right
1157 *
1158 * @param string Content cell content (left)
1159 * @param string Menu cell content (right)
1160 * @return string HTML output
1161 */
1162 function funcMenu($content,$menu) {
1163 return '
1164 <table border="0" cellpadding="0" cellspacing="0" width="100%" id="typo3-funcmenu">
1165 <tr>
1166 <td valign="top" nowrap="nowrap">'.$content.'</td>
1167 <td valign="top" align="right" nowrap="nowrap">'.$menu.'</td>
1168 </tr>
1169 </table>';
1170 }
1171
1172 /**
1173 * Creates a selector box with clear-cache items.
1174 * Rather specialized functions - at least don't use it with $addSaveOptions unless you know what you do...
1175 *
1176 * @param integer The page uid of the "current page" - the one that will be cleared as "clear cache for this page".
1177 * @param boolean If $addSaveOptions is set, then also the array of save-options for TCE_FORMS will appear.
1178 * @return string <select> tag with content - a selector box for clearing the cache
1179 */
1180 function clearCacheMenu($id,$addSaveOptions=0) {
1181 global $BE_USER;
1182 $opt=$addOptions;
1183 if ($addSaveOptions) {
1184 $opt[]='<option value="">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.menu',1).'</option>';
1185 $opt[]='<option value="TBE_EDITOR_checkAndDoSubmit(1);">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc',1).'</option>';
1186 $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>';
1187 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>';
1188 $opt[]='<option value="document.editform.closeDoc.value=2; document.editform.submit();">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc',1).'</option>';
1189 $opt[]='<option value="document.editform.closeDoc.value=3; document.editform.submit();">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeAllDocs',1).'</option>';
1190 $opt[]='<option value=""></option>';
1191 }
1192 $opt[]='<option value="">[ '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_clearCache',1).' ]</option>';
1193 if ($id) $opt[]='<option value="'.$id.'">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_thisPage',1).'</option>';
1194 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>';
1195 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>';
1196
1197 $onChange = 'if (!this.options[this.selectedIndex].value) {
1198 this.selectedIndex=0;
1199 } else if (this.options[this.selectedIndex].value.indexOf(\';\')!=-1) {
1200 eval(this.options[this.selectedIndex].value);
1201 }else{
1202 document.location=\''.$this->backPath.'tce_db.php?vC='.$BE_USER->veriCode().'&redirect='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')).'&cacheCmd=\'+this.options[this.selectedIndex].value;
1203 }';
1204 $af_content = '<select name="cacheCmd" onchange="'.htmlspecialchars($onChange).'">'.implode('',$opt).'</select>';
1205
1206 if (count($opt)>2) {
1207 return $af_content;
1208 }
1209 }
1210
1211 /**
1212 * Returns an array with parts (JavaScript, init-functions, <div>-layers) for use on pages which displays the clickmenu layers (context sensitive menus)
1213 *
1214 * @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
1215 */
1216 function getContextMenuCode() {
1217 if ($this->isCMlayers()) {
1218 $content='
1219 <script type="text/javascript">
1220 /*<![CDATA[*/
1221 var GLV_gap=10;
1222 var GLV_curLayerX=new Array(0,0);
1223 var GLV_curLayerY=new Array(0,0);
1224 var GLV_curLayerWidth=new Array(0,0);
1225 var GLV_curLayerHeight=new Array(0,0);
1226 var GLV_isVisible=new Array(0,0);
1227 var GLV_x=0;
1228 var GLV_y=0;
1229 var GLV_xRel=0;
1230 var GLV_yRel=0;
1231 var layerObj=new Array();
1232 var layerObjCss=new Array();
1233
1234 //browsercheck...
1235 function GL_checkBrowser(){ //
1236 this.dom= (document.getElementById);
1237 this.op= (navigator.userAgent.indexOf("Opera")>-1);
1238 this.op7= this.op && (navigator.appVersion.indexOf("7")>-1); // check for Opera version 7
1239 this.konq= (navigator.userAgent.indexOf("Konq")>-1);
1240 this.ie4= (document.all && !this.dom && !this.op && !this.konq);
1241 this.ie5= (document.all && this.dom && !this.op && !this.konq);
1242 this.ns4= (document.layers && !this.dom && !this.konq);
1243 this.ns5= (!document.all && this.dom && !this.op && !this.konq);
1244 this.ns6= (this.ns5);
1245 this.bw= (this.ie4 || this.ie5 || this.ns4 || this.ns6 || this.op || this.konq);
1246 return this;
1247 }
1248 bw= new GL_checkBrowser();
1249
1250 // GL_getObj(obj)
1251 function GL_getObj(obj){ //
1252 nest="";
1253 this.el= (bw.ie4||bw.op7)?document.all[obj]:bw.ns4?eval(nest+"document."+obj):document.getElementById(obj);
1254 this.css= bw.ns4?this.el:this.el.style;
1255 this.ref= bw.ns4?this.el.document:document;
1256 this.x= (bw.ns4||bw.op)?this.css.left:this.el.offsetLeft;
1257 this.y= (bw.ns4||bw.op)?this.css.top:this.el.offsetTop;
1258 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;
1259 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;
1260 return this;
1261 }
1262 // GL_getObjCss(obj)
1263 function GL_getObjCss(obj){ //
1264 return bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?document.layers[obj]:0;
1265 }
1266 // GL_getMouse(event)
1267 function GL_getMouse(event) { //
1268 if (layerObj) {
1269 // GLV_x= (bw.ns4||bw.ns5)?event.pageX:(bw.ie4||bw.op)?event.clientX:(event.clientX-2)+document.body.scrollLeft;
1270 // GLV_y= (bw.ns4||bw.ns5)?event.pageY:(bw.ie4||bw.op)?event.clientY:(event.clientY-2)+document.body.scrollTop;
1271 // 17/12 2003: When documents run in XHTML standard compliance mode, the old scrollLeft/Top properties of document.body is gone - and for Opera/MSIE we have to use document.documentElement:
1272
1273 GLV_xRel = event.clientX-2;
1274 GLV_yRel = event.clientY-2;
1275 GLV_x = GLV_xRel + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
1276 GLV_y = GLV_yRel + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
1277
1278 // status = (GLV_x+GLV_gap-GLV_curLayerX[0]) + " | " + (GLV_y+GLV_gap-GLV_curLayerY[0]);
1279 if (GLV_isVisible[1]) {
1280 if (outsideLayer(1)) hideSpecific(1);
1281 } else if (GLV_isVisible[0]) {
1282 if (outsideLayer(0)) hideSpecific(0);
1283 }
1284 }
1285 }
1286 // outsideLayer(level)
1287 function outsideLayer(level) { //
1288 return GLV_x+GLV_gap-GLV_curLayerX[level] <0 ||
1289 GLV_y+GLV_gap-GLV_curLayerY[level] <0 ||
1290 GLV_curLayerX[level]+GLV_curLayerWidth[level]+GLV_gap-GLV_x <0 ||
1291 GLV_curLayerY[level]+GLV_curLayerHeight[level]+GLV_gap-GLV_y <0;
1292 }
1293 // setLayerObj(html,level)
1294 function setLayerObj(html,level) { //
1295 var winHeight = document.documentElement.clientHeight && !bw.op7 ? document.documentElement.clientHeight : document.body.clientHeight;
1296 var winWidth = document.documentElement.clientWidth && !bw.op7 ? document.documentElement.clientWidth : document.body.clientWidth;
1297 var tempLayerObj = GL_getObj("contentMenu"+level);
1298 var tempLayerObjCss = GL_getObjCss("contentMenu"+level);
1299
1300 if (tempLayerObj && (level==0 || GLV_isVisible[level-1])) {
1301 tempLayerObj.el.innerHTML = html;
1302 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;
1303 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;
1304
1305 // konqueror (3.2.2) workaround
1306 winHeight = (bw.konq)?window.innerHeight:winHeight;
1307 winWidth = (bw.konq)?window.innerWidth:winWidth;
1308
1309 // Adjusting the Y-height of the layer to fit it into the window frame if it goes under the window frame in the bottom:
1310 if (winHeight-tempLayerObj.height < GLV_yRel) {
1311 if (GLV_yRel < tempLayerObj.height) {
1312 GLV_y+= (winHeight-tempLayerObj.height-GLV_yRel); // Setting it so bottom is just above window height.
1313 } else {
1314 GLV_y-= tempLayerObj.height-8; // Showing the menu upwards
1315 }
1316 }
1317 // Adjusting the X position like Y above
1318 if (winWidth-tempLayerObj.width < GLV_xRel) {
1319 if (GLV_xRel < tempLayerObj.width) {
1320 GLV_x+= (winWidth-tempLayerObj.width-GLV_xRel);
1321 } else {
1322 GLV_x-= tempLayerObj.width-8;
1323 }
1324 }
1325 GLV_x = Math.max(GLV_x,1);
1326 GLV_y = Math.max(GLV_y,1);
1327
1328 GLV_curLayerX[level] = GLV_x;
1329 GLV_curLayerY[level] = GLV_y;
1330 tempLayerObjCss.left = GLV_x+"px";
1331 tempLayerObjCss.top = GLV_y+"px";
1332 tempLayerObjCss.visibility = "visible";
1333 if (bw.ie5) showHideSelectorBoxes("hidden");
1334
1335 GLV_isVisible[level]=1;
1336 GLV_curLayerWidth[level] = tempLayerObj.width;
1337 GLV_curLayerHeight[level] = tempLayerObj.height;
1338 }
1339 }
1340 // hideEmpty()
1341 function hideEmpty() { //
1342 hideSpecific(0);
1343 hideSpecific(1);
1344 return false;
1345 }
1346 // hideSpecific(level)
1347 function hideSpecific(level) { //
1348 GL_getObjCss("contentMenu"+level).visibility = "hidden";
1349 GL_getObj("contentMenu"+level).el.innerHTML = "";
1350 GLV_isVisible[level]=0;
1351
1352 if (bw.ie5 && level==0) showHideSelectorBoxes("visible");
1353 }
1354 // debugObj(obj,name)
1355 function debugObj(obj,name) { //
1356 var acc;
1357 for (i in obj) {if (obj[i]) {acc+=i+": "+obj[i]+"\n";}}
1358 alert("Object: "+name+"\n\n"+acc);
1359 }
1360 // initLayer()
1361 function initLayer(){ //
1362 if (document.all) {
1363 window.onmousemove=GL_getMouse;
1364 }
1365 layerObj = GL_getObj("contentMenu1");
1366 layerObjCss = GL_getObjCss("contentMenu1");
1367 }
1368 function showHideSelectorBoxes(action) { // This function by Michiel van Leening
1369 for (i=0;i<document.forms.length;i++) {
1370 for (j=0;j<document.forms[i].elements.length;j++) {
1371 if(document.forms[i].elements[j].type=="select-one") {
1372 document.forms[i].elements[j].style.visibility=action;
1373 }
1374 }
1375 }
1376 }
1377 /*]]>*/
1378 </script>
1379 ';
1380 return array(
1381 $content,
1382 ' onmousemove="GL_getMouse(event);" onload="initLayer();"',
1383 '<div id="contentMenu0" style="z-index:1; position:absolute;visibility:hidden"></div><div id="contentMenu1" style="z-index:2; position:absolute;visibility:hidden"></div>'
1384 );
1385 } else return array('','','');
1386 }
1387
1388 /**
1389 * Creates a tab menu from an array definition
1390 *
1391 * Returns a tab menu for a module
1392 * Requires the JS function jumpToUrl() to be available
1393 *
1394 * @param mixed $id is the "&id=" parameter value to be sent to the module, but it can be also a parameter array which will be passed instead of the &id=...
1395 * @param string $elementName it the form elements name, probably something like "SET[...]"
1396 * @param string $currentValue is the value to be selected currently.
1397 * @param array $menuItems is an array with the menu items for the selector box
1398 * @param string $script is the script to send the &id to, if empty it's automatically found
1399 * @param string $addParams is additional parameters to pass to the script.
1400 * @return string HTML code for tab menu
1401 * @author René Fritz <r.fritz@colorcube.de>
1402 */
1403 function getTabMenu($mainParams,$elementName,$currentValue,$menuItems,$script='',$addparams='') {
1404 $content='';
1405
1406 if (is_array($menuItems)) {
1407 if (!is_array($mainParams)) {
1408 $mainParams = array('id' => $mainParams);
1409 }
1410 $mainParams = t3lib_div::implodeArrayForUrl('',$mainParams);
1411
1412 if (!$script) {$script=basename(PATH_thisScript);}
1413
1414 $menuDef = array();
1415 foreach($menuItems as $value => $label) {
1416 $menuDef[$value]['isActive'] = !strcmp($currentValue,$value);
1417 $menuDef[$value]['label'] = t3lib_div::deHSCentities(htmlspecialchars($label));
1418 $menuDef[$value]['url'] = htmlspecialchars($script.'?'.$mainParams.$addparams.'&'.$elementName.'='.$value);
1419 }
1420 $content = $this->getTabMenuRaw($menuDef);
1421
1422 }
1423 return $content;
1424 }
1425
1426 function getTabMenuRaw($menuItems) {
1427 $content='';
1428
1429 if (is_array($menuItems)) {
1430 $options='';
1431
1432 $count = count($menuItems);
1433 $widthLeft = 1;
1434 $addToAct = 5;
1435
1436 $widthRight = max (1,floor(30-pow($count,1.72)));
1437 $widthTabs = 100 - $widthRight - $widthLeft;
1438 $widthNo = floor(($widthTabs - $addToAct)/$count);
1439 $addToAct = max ($addToAct,$widthTabs-($widthNo*$count));
1440 $widthAct = $widthNo + $addToAct;
1441 $widthRight = 100 - ($widthLeft + ($count*$widthNo) + $addToAct);
1442
1443 $first=true;
1444 foreach($menuItems as $id => $def) {
1445 $isActive = $def['isActive'];
1446 $class = $isActive ? 'tabact' : 'tab';
1447 $width = $isActive ? $widthAct : $widthNo;
1448
1449 // @rene: Here you should probably wrap $label and $url in htmlspecialchars() in order to make sure its XHTML compatible! I did it for $url already since that is VERY likely to break.
1450 $label = $def['label'];
1451 $url = htmlspecialchars($def['url']);
1452 $params = $def['addParams'];
1453
1454 if($first) {
1455 $options.= '
1456 <td width="'.$width.'%" class="'.$class.'" style="border-left: solid #000 1px;"><a href="'.$url.'" style="padding-left:5px;padding-right:2px;" '.$params.'>'.$label.'</a></td>';
1457 } else {
1458 $options.='
1459 <td width="'.$width.'%" class="'.$class.'"><a href="'.$url.'" '.$params.'>'.$label.'</a></td>';
1460 }
1461 $first=false;
1462 }
1463
1464 if ($options) {
1465 $content .= '
1466 <!-- Tab menu -->
1467 <table cellpadding="0" cellspacing="0" border="0" width="100%" id="typo3-tabmenu">
1468 <tr>
1469 <td width="'.$widthLeft.'%">&nbsp;</td>
1470 '.$options.'
1471 <td width="'.$widthRight.'%">&nbsp;</td>
1472 </tr>
1473 </table>
1474 <div class="hr" style="margin:0px"></div>';
1475 }
1476
1477 }
1478 return $content;
1479 }
1480
1481 /**
1482 * Creates a DYNAMIC tab-menu where the tabs are switched between with DHTML.
1483 * Should work in MSIE, Mozilla, Opera and Konqueror. On Konqueror I did find a serious problem: <textarea> fields loose their content when you switch tabs!
1484 *
1485 * @param array Numeric array where each entry is an array in itself with associative keys: "label" contains the label for the TAB, "content" contains the HTML content that goes into the div-layer of the tabs content. "description" contains description text to be shown in the layer. "linkTitle" is short text for the title attribute of the tab-menu link (mouse-over text of tab). "stateIcon" indicates a standard status icon (see ->icon(), values: -1, 1, 2, 3). "icon" is an image tag placed before the text.
1486 * @param string Identification string. This should be unique for every instance of a dynamic menu!
1487 * @param integer If "1", then enabling one tab does not hide the others - they simply toggles each sheet on/off. This makes most sense together with the $foldout option. If "-1" then it acts normally where only one tab can be active at a time BUT you can click a tab and it will close so you have no active tabs.
1488 * @param boolean If set, the tabs are rendered as headers instead over each sheet. Effectively this means there is no tab menu, but rather a foldout/foldin menu. Make sure to set $toggle as well for this option.
1489 * @param integer Character limit for a new row.
1490 * @param boolean If set, tab table cells are not allowed to wrap their content
1491 * @param integer Default tab to open (for toggle <=0). Value corresponds to integer-array index + 1 (index zero is "1", index "1" is 2 etc.). A value of zero (or something non-existing) will result in no default tab open.
1492 * @return string JavaScript section for the HTML header.
1493 */
1494 function getDynTabMenu($menuItems,$identString,$toggle=0,$foldout=FALSE,$newRowCharLimit=50,$noWrap=1,$fullWidth=FALSE,$defaultTabIndex=1) {
1495 $content = '';
1496
1497 if (is_array($menuItems)) {
1498
1499 // Init:
1500 $options = array(array());
1501 $divs = array();
1502 $JSinit = array();
1503 $id = 'DTM-'.t3lib_div::shortMD5($identString);
1504 $noWrap = $noWrap ? ' nowrap="nowrap"' : '';
1505
1506 // Traverse menu items
1507 $c=0;
1508 $tabRows=0;
1509 $titleLenCount = 0;
1510 foreach($menuItems as $index => $def) {
1511 $index+=1; // Need to add one so checking for first index in JavaScript is different than if it is not set at all.
1512
1513 // Switch to next tab row if needed
1514 if (!$foldout && $titleLenCount>$newRowCharLimit) { // 50 characters is probably a reasonable count of characters before switching to next row of tabs.
1515 $titleLenCount=0;
1516 $tabRows++;
1517 $options[$tabRows] = array();
1518 }
1519
1520 if ($toggle==1) {
1521 $onclick = 'this.blur(); DTM_toggle("'.$id.'","'.$index.'"); return false;';
1522 } else {
1523 $onclick = 'this.blur(); DTM_activate("'.$id.'","'.$index.'", '.($toggle<0?1:0).'); return false;';
1524 }
1525
1526 $isActive = strcmp($def['content'],'');
1527
1528 if (!$foldout) {
1529 // Create TAB cell:
1530 $options[$tabRows][] = '
1531 <td class="'.($isActive ? 'tab' : 'disabled').'" id="'.$id.'-'.$index.'-MENU"'.$noWrap.'>'.
1532 ($isActive ? '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ? ' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>' : '').
1533 $def['icon'].
1534 ($def['label'] ? htmlspecialchars($def['label']) : '&nbsp;').
1535 $this->icons($def['stateIcon'],'margin-left: 10px;').
1536 ($isActive ? '</a>' :'').
1537 '</td>';
1538 $titleLenCount+= strlen($def['label']);
1539 } else {
1540 // Create DIV layer for content:
1541 $divs[] = '
1542 <div class="'.($isActive ? 'tab' : 'disabled').'" id="'.$id.'-'.$index.'-MENU">'.
1543 ($isActive ? '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ? ' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>' : '').
1544 ($def['label'] ? htmlspecialchars($def['label']) : '&nbsp;').
1545 ($isActive ? '</a>' : '').
1546 '</div>';
1547 }
1548
1549 if ($isActive) {
1550 // Create DIV layer for content:
1551 $divs[] = '
1552 <div style="display: none;" id="'.$id.'-'.$index.'-DIV" class="c-tablayer">'.
1553 ($def['description'] ? '<p class="c-descr">'.nl2br(htmlspecialchars($def['description'])).'</p>' : '').
1554 $def['content'].
1555 '</div>';
1556 // Create initialization string:
1557 $JSinit[] = '
1558 DTM_array["'.$id.'"]['.$c.'] = "'.$id.'-'.$index.'";
1559 ';
1560 if ($toggle==1) {
1561 $JSinit[] = '
1562 if (top.DTM_currentTabs["'.$id.'-'.$index.'"]) { DTM_toggle("'.$id.'","'.$index.'"); }
1563 ';
1564 }
1565
1566 $c++;
1567 }
1568 }
1569
1570 // Render menu:
1571 if (count($options)) {
1572
1573 // Tab menu is compiled:
1574 if (!$foldout) {
1575 $tabContent = '';
1576 for($a=0;$a<=$tabRows;$a++) {
1577 $tabContent.= '
1578
1579 <!-- Tab menu -->
1580 <table cellpadding="0" cellspacing="0" border="0"'.($fullWidth ? ' width="100%"' : '').' class="typo3-dyntabmenu">
1581 <tr>
1582 '.implode('',$options[$a]).'
1583 </tr>
1584 </table>';
1585 }
1586 $content.= '<div class="typo3-dyntabmenu-tabs">'.$tabContent.'</div>';
1587 }
1588
1589 // Div layers are added:
1590 $content.= '
1591 <!-- Div layers for tab menu: -->
1592 <div class="typo3-dyntabmenu-divs'.($foldout?'-foldout':'').'">
1593 '.implode('',$divs).'</div>';
1594
1595 // Java Script section added:
1596 $content.= '
1597 <!-- Initialization JavaScript for the menu -->
1598 <script type="text/javascript">
1599 DTM_array["'.$id.'"] = new Array();
1600 '.implode('',$JSinit).'
1601
1602 '.($toggle<=0 ? 'DTM_activate("'.$id.'", top.DTM_currentTabs["'.$id.'"]?top.DTM_currentTabs["'.$id.'"]:'.intval($defaultTabIndex).', 0);' : '').'
1603 </script>
1604
1605 ';
1606 }
1607
1608 }
1609 return $content;
1610 }
1611
1612 /**
1613 * Returns dynamic tab menu header JS code.
1614 *
1615 * @return string JavaScript section for the HTML header.
1616 */
1617 function getDynTabMenuJScode() {
1618 return '
1619 <script type="text/javascript">
1620 /*<![CDATA[*/
1621 var DTM_array = new Array();
1622
1623 function DTM_activate(idBase,index,doToogle) { //
1624 // Hiding all:
1625 if (DTM_array[idBase]) {
1626 for(cnt = 0; cnt < DTM_array[idBase].length ; cnt++) {
1627 if (DTM_array[idBase][cnt] != idBase+"-"+index) {
1628 document.getElementById(DTM_array[idBase][cnt]+"-DIV").style.display = "none";
1629 document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
1630 }
1631 }
1632 }
1633
1634 // Showing one:
1635 if (document.getElementById(idBase+"-"+index+"-DIV")) {
1636 if (doToogle && document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
1637 document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
1638 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
1639 top.DTM_currentTabs[idBase] = -1;
1640 } else {
1641 document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
1642 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
1643 top.DTM_currentTabs[idBase] = index;
1644 }
1645 }
1646 }
1647 function DTM_toggle(idBase,index) { //
1648 // Showing one:
1649 if (document.getElementById(idBase+"-"+index+"-DIV")) {
1650 if (document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
1651 document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
1652 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
1653 top.DTM_currentTabs[idBase+"-"+index] = 0;
1654 } else {
1655 document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
1656 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
1657 top.DTM_currentTabs[idBase+"-"+index] = 1;
1658 }
1659 }
1660 }
1661 /*]]>*/
1662 </script>
1663 ';
1664 }
1665
1666 /**
1667 * Creates the version selector for the page id inputted.
1668 * Requires the core version management extension, "version" to be loaded.
1669 *
1670 * @param integer Page id to create selector for.
1671 * @param boolean If set, there will be no button for swapping page.
1672 * @return void
1673 */
1674 function getVersionSelector($id,$noAction=FALSE) {
1675
1676 if ($id>0 && t3lib_extMgm::isLoaded('version')) {
1677
1678 // Get Current page record:
1679 $curPage = t3lib_BEfunc::getRecord('pages',$id);
1680 // If the selected page is not online, find the right ID
1681 $onlineId = ($curPage['pid']==-1 ? $curPage['t3ver_oid'] : $id);
1682 // Select all versions of online version:
1683 $versions = t3lib_BEfunc::selectVersionsOfRecord('pages', $onlineId, 'uid,pid,t3ver_label,t3ver_oid,t3ver_id');
1684
1685 // If more than one was found...:
1686 if (count($versions)>1) {
1687
1688 // Create selector box entries:
1689 $opt = array();
1690 foreach($versions as $vRow) {
1691 $opt[] = '<option value="'.htmlspecialchars(t3lib_div::linkThisScript(array('id'=>$vRow['uid']))).'"'.($id==$vRow['uid']?' selected="selected"':'').'>'.
1692 htmlspecialchars($vRow['t3ver_label'].' [v#'.$vRow['t3ver_id'].']'.($vRow['uid']==$onlineId ? ' =>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.online').'<=':'')).
1693 '</option>';
1694 }
1695
1696 // Add management link:
1697 $opt[] = '<option value="'.htmlspecialchars(t3lib_div::linkThisScript(array('id'=>$id))).'">---</option>';
1698 $opt[] = '<option value="'.htmlspecialchars($this->backPath.t3lib_extMgm::extRelPath('version').'cm1/index.php?table=pages&uid='.$onlineId).'">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.mgm',1).'</option>';
1699
1700 // Create onchange handler:
1701 $onChange = "document.location=this.options[this.selectedIndex].value;";
1702
1703 // Controls:
1704 if ($id==$onlineId) {
1705 $controls = '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/blinkarrow_left.gif','width="5" height="9"').' class="absmiddle" alt="" /> <b>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.online',1).'</b>';
1706 } elseif (!$noAction) {
1707 $controls = '<a href="'.$this->issueCommand('&cmd[pages]['.$onlineId.'][version][swapWith]='.$id.'&cmd[pages]['.$onlineId.'][version][action]=swap&cmd[pages]['.$onlineId.'][version][swapContent]=1',t3lib_div::linkThisScript(array('id'=>$onlineId))).'">'.
1708 '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/insert2.gif','width="14" height="14"').' style="margin-right: 2px;" class="absmiddle" alt="" title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.swapPage',1).'" />'.
1709 '<b>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.swap',1).'</b></a>';
1710 }
1711
1712 // Write out HTML code:
1713 return '
1714
1715 <!--
1716 Version selector:
1717 -->
1718 <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
1719 <tr>
1720 <td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.selVer',1).'</td>
1721 <td>
1722 <select onchange="'.htmlspecialchars($onChange).'">
1723 '.implode('',$opt).'
1724 </select></td>
1725 <td>'.$controls.'</td>
1726 </tr>
1727 </table>
1728 ';
1729 }
1730 }
1731 }
1732 }
1733
1734
1735
1736 // ******************************
1737 // Extension classes of the template class.
1738 // These are meant to provide backend screens with different widths.
1739 // They still do because of the different class-prefixes used for the <div>-sections
1740 // but obviously the final width is determined by the stylesheet used.
1741 // ******************************
1742
1743 /**
1744 * 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
1745 * The class were more significant in the past than today.
1746 *
1747 */
1748 class bigDoc extends template {
1749 var $divClass = 'typo3-bigDoc';
1750 }
1751
1752 /**
1753 * Extension class for "template" - used for backend pages without the "document" background image
1754 * The class were more significant in the past than today.
1755 *
1756 */
1757 class noDoc extends template {
1758 var $divClass = 'typo3-noDoc';
1759 }
1760
1761 /**
1762 * 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)
1763 * The class were more significant in the past than today.
1764 *
1765 */
1766 class smallDoc extends template {
1767 var $divClass = 'typo3-smallDoc';
1768 }
1769
1770 /**
1771 * 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.
1772 * The class were more significant in the past than today. But probably you should use this one for most modules you make.
1773 *
1774 */
1775 class mediumDoc extends template {
1776 var $divClass = 'typo3-mediumDoc';
1777 }
1778
1779
1780
1781 // Include extension to the template class?
1782 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/template.php']) {
1783 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/template.php']);
1784 }
1785
1786
1787
1788 // ******************************************************
1789 // The backend language engine is started (ext: "lang")
1790 // ******************************************************
1791 require_once(PATH_typo3.'sysext/lang/lang.php');
1792 $LANG = t3lib_div::makeInstance('language');
1793 $LANG->init($BE_USER->uc['lang']);
1794
1795
1796
1797 // ******************************
1798 // The template is loaded
1799 // ******************************
1800 $TBE_TEMPLATE = t3lib_div::makeInstance('template');
1801 ?>