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