DynTabMenu changed so the div changes it's background, instead of changing color...
[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';
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 ($this->divClass?'
676
677 <!-- Wrapping DIV-section for whole page END -->
678 </div>':'').
679 '
680 </body>
681 </html> ';
682
683 // Logging: Can't find better place to put it:
684 if (TYPO3_DLOG) t3lib_div::devLog('END of BACKEND session','',0,array('_FLUSH'=>TRUE));
685
686 return $str;
687 }
688
689 /**
690 * Returns the header-bar in the top of most backend modules
691 * Closes section if open.
692 *
693 * @param string The text string for the header
694 * @return string HTML content
695 */
696 function header($text) {
697 $str='
698
699 <!-- MAIN Header in page top -->
700 <h2>'.htmlspecialchars($text).'</h2>
701 ';
702 return $this->sectionEnd().$str;
703 }
704
705 /**
706 * Begins an output section and sets header and content
707 *
708 * @param string The header
709 * @param string The HTML-content
710 * @param boolean A flag that will prevent the header from being converted to uppercase
711 * @param boolean Defines the type of header (if set, "<h3>" rather than the default "h4")
712 * @param integer The number of an icon to show with the header (see the icon-function). -1,1,2,3
713 * @param boolean If set, HTML tags are allowed in $label (otherwise this value is by default htmlspecialchars()'ed)
714 * @return string HTML content
715 * @see icons(), sectionHeader()
716 */
717 function section($label,$text,$nostrtoupper=FALSE,$sH=FALSE,$type=0,$allowHTMLinHeader=FALSE) {
718 $str='';
719
720 // Setting header
721 if ($label) {
722 if (!$allowHTMLinHeader) $label = htmlspecialchars($label);
723 $str.=$this->sectionHeader($this->icons($type).$label, $sH, $nostrtoupper ? '' : ' class="uppercase"');
724 }
725 // Setting content
726 $str.='
727
728 <!-- Section content -->
729 '.$text;
730
731 return $this->sectionBegin().$str;
732 }
733
734 /**
735 * Inserts a divider image
736 * Ends a section (if open) before inserting the image
737 *
738 * @param integer The margin-top/-bottom of the <hr> ruler.
739 * @return string HTML content
740 */
741 function divider($dist) {
742 $dist = intval($dist);
743 $str='
744
745 <!-- DIVIDER -->
746 <hr style="margin-top: '.$dist.'px; margin-bottom: '.$dist.'px;" />
747 ';
748 return $this->sectionEnd().$str;
749 }
750
751 /**
752 * Returns a blank <div>-section with a height
753 *
754 * @param integer Padding-top for the div-section (should be margin-top but konquorer (3.1) don't like it :-(
755 * @return string HTML content
756 */
757 function spacer($dist) {
758 if ($dist>0) {
759 return '
760
761 <!-- Spacer element -->
762 <div style="padding-top: '.intval($dist).'px;"></div>
763 ';
764 }
765 }
766
767 /**
768 * Make a section header.
769 * Begins a section if not already open.
770 *
771 * @param string The label between the <h3> or <h4> tags. (Allows HTML)
772 * @param boolean If set, <h3> is used, otherwise <h4>
773 * @param string Additional attributes to h-tag, eg. ' class=""'
774 * @return string HTML content
775 */
776 function sectionHeader($label,$sH=FALSE,$addAttrib='') {
777 $tag = ($sH?'h3':'h4');
778 $str='
779
780 <!-- Section header -->
781 <'.$tag.$addAttrib.'>'.$label.'</'.$tag.'>
782 ';
783 return $this->sectionBegin().$str;
784 }
785
786 /**
787 * Begins an output section.
788 * Returns the <div>-begin tag AND sets the ->sectionFlag true (if the ->sectionFlag is not already set!)
789 * 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!
790 *
791 * @return string HTML content
792 */
793 function sectionBegin() {
794 if (!$this->sectionFlag) {
795 $this->sectionFlag=1;
796 $str='
797
798 <!-- ***********************
799 Begin output section.
800 *********************** -->
801 <div>
802 ';
803 return $str;
804 } else return '';
805 }
806
807 /**
808 * Ends and output section
809 * Returns the </div>-end tag AND clears the ->sectionFlag (but does so only IF the sectionFlag is set - that is a section is 'open')
810 * See sectionBegin() also.
811 *
812 * @return string HTML content
813 */
814 function sectionEnd() {
815 if ($this->sectionFlag) {
816 $this->sectionFlag=0;
817 return '
818 </div>
819 <!-- *********************
820 End output section.
821 ********************* -->
822 ';
823 } else return '';
824 }
825
826 /**
827 * Originally it printed a kind of divider.
828 * Depreciated. Just remove function calls to it or call the divider() function instead.
829 *
830 * @return void
831 * @internal
832 * @depreciated
833 */
834 function middle() {
835 }
836
837 /**
838 * If a form-tag is defined in ->form then and end-tag for that <form> element is outputted
839 * Further a JavaScript section is outputted which will update the top.busy session-expiry object (unless $this->endJS is set to false)
840 *
841 * @return string HTML content (<script> tag section)
842 */
843 function endPageJS() {
844 return ($this->endJS?'
845 <script type="text/javascript">
846 /*<![CDATA[*/
847 if (top.busy && top.busy.loginRefreshed) {
848 top.busy.loginRefreshed();
849 }
850 /*]]>*/
851 </script>':'');
852 }
853
854 /**
855 * Creates the bodyTag.
856 * You can add to the bodyTag by $this->bodyTagAdditions
857 *
858 * @return string HTML body tag
859 */
860 function docBodyTagBegin() {
861 $bodyContent = 'body '.trim($this->bodyTagAdditions.($this->bodyTagId ? ' id="'.$this->bodyTagId.'"' : ''));
862 return '<'.trim($bodyContent).'>';
863 }
864
865 /**
866 * Outputting document style
867 *
868 * @return string HTML style section/link tags
869 */
870 function docStyle() {
871
872 // Request background image:
873 if ($this->backGroundImage) {
874 $this->inDocStylesArray[]=' BODY { background-image: url('.$this->backPath.$this->backGroundImage.'); }';
875 }
876
877 // Add inDoc styles variables as well:
878 $this->inDocStylesArray[] = $this->inDocStyles;
879 $this->inDocStylesArray[] = $this->inDocStyles_TBEstyle;
880
881 // Implode it all:
882 $inDocStyles = implode('
883 ',$this->inDocStylesArray);
884
885 // The default color scheme should also in full be represented in the stylesheet.
886 $style=trim('
887 '.($this->styleSheetFile?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile.'" />':'').'
888 '.($this->styleSheetFile2?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile2.'" />':'').'
889 <style type="text/css" id="internalStyle">
890 /*<![CDATA[*/
891 '.trim($inDocStyles).'
892 /*###POSTCSSMARKER###*/
893 /*]]>*/
894 </style>
895 '.($this->styleSheetFile_post?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile_post.'" />':'')
896 )
897 ;
898 $this->inDocStyles='';
899 $this->inDocStylesArray=array();
900
901 return '
902 '.$style;
903 }
904
905 /**
906 * Insert post rendering document style into already rendered content
907 * This is needed for extobjbase
908 *
909 * @param string style-content to insert.
910 * @return string content with inserted styles
911 */
912 function insertStylesAndJS($content) {
913 // insert accumulated CSS
914 $this->inDocStylesArray[] = $this->inDocStyles;
915 $styles = "\n".implode("\n", $this->inDocStylesArray);
916 $content = str_replace('/*###POSTCSSMARKER###*/',$styles,$content);
917
918 // insert accumulated JS
919 $jscode = $this->JScode."\n".$this->wrapScriptTags(implode("\n", $this->JScodeArray));
920 $content = str_replace('<!--###POSTJSMARKER###-->',$jscode,$content);
921
922 return $content;
923 }
924
925 /**
926 * Initialize the charset.
927 * Sets the internal $this->charset variable to the charset defined in $GLOBALS["LANG"] (or the default as set in this class)
928 * Returns the meta-tag for the document header
929 *
930 * @return string <meta> tag with charset from $this->charset or $GLOBALS['LANG']->charSet
931 */
932 function initCharset() {
933 // Set charset to the charset provided by the current backend users language selection:
934 $this->charset = $GLOBALS['LANG']->charSet ? $GLOBALS['LANG']->charSet : $this->charset;
935 // Return meta tag:
936 return '<meta http-equiv="Content-Type" content="text/html; charset='.$this->charset.'" />';
937 }
938
939 /**
940 * Returns generator meta tag
941 *
942 * @return string <meta> tag with name "GENERATOR"
943 */
944 function generator() {
945 $str = 'TYPO3 '.$GLOBALS['TYPO_VERSION'].', http://typo3.com, &#169; Kasper Sk&#229;rh&#248;j 1998-2004, extensions are copyright of their respective owners.';
946 return '<meta name="GENERATOR" content="'.$str .'" />';
947 }
948
949
950
951
952
953
954
955
956 /*****************************************
957 *
958 * OTHER ELEMENTS
959 * Tables, buttons, formatting dimmed/red strings
960 *
961 ******************************************/
962
963
964 /**
965 * Returns an image-tag with an 18x16 icon of the following types:
966 *
967 * $type:
968 * -1: OK icon (Check-mark)
969 * 1: Notice (Speach-bubble)
970 * 2: Warning (Yellow triangle)
971 * 3: Fatal error (Red stop sign)
972 *
973 * @param integer See description
974 * @param string Value for style attribute
975 * @return string HTML image tag (if applicable)
976 */
977 function icons($type, $styleAttribValue='') {
978 switch($type) {
979 case '3':
980 $icon = 'gfx/icon_fatalerror.gif';
981 break;
982 case '2':
983 $icon = 'gfx/icon_warning.gif';
984 break;
985 case '1':
986 $icon = 'gfx/icon_note.gif';
987 break;
988 case '-1':
989 $icon = 'gfx/icon_ok.gif';
990 break;
991 default:
992 break;
993 }
994 if ($icon) {
995 return '<img'.t3lib_iconWorks::skinImg($this->backPath,$icon,'width="18" height="16"').' class="absmiddle"'.($styleAttribValue ? ' style="'.htmlspecialchars($styleAttribValue).'"' : '').' alt="" />';
996 }
997 }
998
999 /**
1000 * Returns an <input> button with the $onClick action and $label
1001 *
1002 * @param string The value of the onclick attribute of the input tag (submit type)
1003 * @param string The label for the button (which will be htmlspecialchar'ed)
1004 * @return string A <input> tag of the type "submit"
1005 */
1006 function t3Button($onClick,$label) {
1007 $button = '<input type="submit" onclick="'.htmlspecialchars($onClick).'; return false;" value="'.htmlspecialchars($label).'" />';
1008 return $button;
1009 }
1010
1011 /**
1012 * dimmed-fontwrap. Returns the string wrapped in a <span>-tag defining the color to be gray/dimmed
1013 *
1014 * @param string Input string
1015 * @return string Output string
1016 */
1017 function dfw($string) {
1018 return '<span class="typo3-dimmed">'.$string.'</span>';
1019 }
1020
1021 /**
1022 * red-fontwrap. Returns the string wrapped in a <span>-tag defining the color to be red
1023 *
1024 * @param string Input string
1025 * @return string Output string
1026 */
1027 function rfw($string) {
1028 return '<span class="typo3-red">'.$string.'</span>';
1029 }
1030
1031 /**
1032 * Returns string wrapped in CDATA "tags" for XML / XHTML (wrap content of <script> and <style> sections in those!)
1033 *
1034 * @param string Input string
1035 * @return string Output string
1036 */
1037 function wrapInCData($string) {
1038 $string = '/*<![CDATA[*/'.
1039 $string.
1040 '/*]]>*/';
1041
1042 return $string;
1043 }
1044
1045 /**
1046 * Wraps the input string in script tags.
1047 * Automatic re-identing of the JS code is done by using the first line as ident reference.
1048 * This is nice for identing JS code with PHP code on the same level.
1049 *
1050 * @param string Input string
1051 * @param boolean Wrap script element in linebreaks? Default is TRUE.
1052 * @return string Output string
1053 */
1054 function wrapScriptTags($string, $linebreak=TRUE) {
1055 if(trim($string)) {
1056 // <script wrapped in nl?
1057 $cr = $linebreak? "\n" : '';
1058
1059 // remove nl from the beginning
1060 $string = preg_replace ('/^\n+/', '', $string);
1061 // re-ident to one tab using the first line as reference
1062 if(preg_match('/^(\t+)/',$string,$match)) {
1063 $string = str_replace($match[1],"\t", $string);
1064 }
1065 $string = $cr.'<script type="text/javascript">
1066 /*<![CDATA[*/
1067 '.$string.'
1068 /*]]>*/
1069 </script>'.$cr;
1070 }
1071 return trim($string);
1072 }
1073
1074 // These vars defines the layout for the table produced by the table() function.
1075 // You can override these values from outside if you like.
1076 var $tableLayout = Array (
1077 'defRow' => Array (
1078 'defCol' => Array('<td valign="top">','</td>')
1079 )
1080 );
1081 var $table_TR = '<tr>';
1082 var $table_TABLE = '<table border="0" cellspacing="0" cellpadding="0" id="typo3-tmpltable">';
1083
1084 /**
1085 * Returns a table based on the input $arr
1086 *
1087 * @param array Multidim array with first levels = rows, second levels = cells
1088 * @param array If set, then this provides an alternative layout array instead of $this->tableLayout
1089 * @return string The HTML table.
1090 * @internal
1091 */
1092 function table($arr, $layout='') {
1093 if (is_array($arr)) {
1094 $tableLayout = (is_array($layout)) ? $layout : $this->tableLayout;
1095
1096 reset($arr);
1097 $code='';
1098 $rc=0;
1099 while(list(,$val)=each($arr)) {
1100 if ($rc % 2) {
1101 $layout = is_array($tableLayout['defRowOdd']) ? $tableLayout['defRowOdd'] : $tableLayout['defRow'];
1102 } else {
1103 $layout = is_array($tableLayout['defRowEven']) ? $tableLayout['defRowEven'] : $tableLayout['defRow'];
1104 }
1105 $layoutRow = is_array($tableLayout[$rc]) ? $tableLayout[$rc] : $layout;
1106 $code_td='';
1107 if (is_array($val)) {
1108 $cc=0;
1109 while(list(,$content)=each($val)) {
1110 $wrap= is_array($layoutRow[$cc]) ? $layoutRow[$cc] : (is_array($layoutRow['defCol']) ? $layoutRow['defCol'] : (is_array($layout[$cc]) ? $layout[$cc] : $layout['defCol']));
1111 $code_td.=$wrap[0].$content.$wrap[1];
1112 $cc++;
1113 }
1114 }
1115 $trWrap = is_array($layoutRow['tr']) ? $layoutRow['tr'] : (is_array($layout['tr']) ? $layout['tr'] : array($this->table_TR, '</tr>'));
1116 $code.=$trWrap[0].$code_td.$trWrap[1];
1117 $rc++;
1118 }
1119 $tableWrap = is_array($tableLayout['table']) ? $tableLayout['table'] : array($this->table_TABLE, '</table>');
1120 $code=$tableWrap[0].$code.$tableWrap[1];
1121 }
1122 return $code;
1123 }
1124
1125 /**
1126 * Constructs a table with content from the $arr1, $arr2 and $arr3.
1127 * Used in eg. ext/belog/mod/index.php - refer to that for examples
1128 *
1129 * @param array Menu elements on first level
1130 * @param array Secondary items
1131 * @param array Third-level items
1132 * @return string HTML content, <table>...</table>
1133 */
1134 function menuTable($arr1,$arr2=array(), $arr3=array()) {
1135 $rows = max(array(count($arr1),count($arr2),count($arr3)));
1136
1137 $menu='
1138 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tablemenu">';
1139 for($a=0;$a<$rows;$a++) {
1140 $menu.='<tr>';
1141 $cls=array();
1142 $valign='middle';
1143 $cls[]='<td valign="'.$valign.'">'.$arr1[$a][0].'</td><td>'.$arr1[$a][1].'</td>';
1144 if (count($arr2)) {
1145 $cls[]='<td valign="'.$valign.'">'.$arr2[$a][0].'</td><td>'.$arr2[$a][1].'</td>';
1146 if (count($arr3)) {
1147 $cls[]='<td valign="'.$valign.'">'.$arr3[$a][0].'</td><td>'.$arr3[$a][1].'</td>';
1148 }
1149 }
1150 $menu.=implode($cls,'<td>&nbsp;&nbsp;</td>');
1151 $menu.='</tr>';
1152 }
1153 $menu.='
1154 </table>
1155 ';
1156 return $menu;
1157 }
1158
1159 /**
1160 * Returns a one-row/two-celled table with $content and $menu side by side.
1161 * The table is a 100% width table and each cell is aligned left / right
1162 *
1163 * @param string Content cell content (left)
1164 * @param string Menu cell content (right)
1165 * @return string HTML output
1166 */
1167 function funcMenu($content,$menu) {
1168 return '
1169 <table border="0" cellpadding="0" cellspacing="0" width="100%" id="typo3-funcmenu">
1170 <tr>
1171 <td valign="top" nowrap="nowrap">'.$content.'</td>
1172 <td valign="top" align="right" nowrap="nowrap">'.$menu.'</td>
1173 </tr>
1174 </table>';
1175 }
1176
1177 /**
1178 * Creates a selector box with clear-cache items.
1179 * Rather specialized functions - at least don't use it with $addSaveOptions unless you know what you do...
1180 *
1181 * @param integer The page uid of the "current page" - the one that will be cleared as "clear cache for this page".
1182 * @param boolean If $addSaveOptions is set, then also the array of save-options for TCE_FORMS will appear.
1183 * @return string <select> tag with content - a selector box for clearing the cache
1184 */
1185 function clearCacheMenu($id,$addSaveOptions=0) {
1186 global $BE_USER;
1187 $opt=$addOptions;
1188 if ($addSaveOptions) {
1189 $opt[]='<option value="">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.menu',1).'</option>';
1190 $opt[]='<option value="TBE_EDITOR_checkAndDoSubmit(1);">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc',1).'</option>';
1191 $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>';
1192 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>';
1193 $opt[]='<option value="document.editform.closeDoc.value=2; document.editform.submit();">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc',1).'</option>';
1194 $opt[]='<option value="document.editform.closeDoc.value=3; document.editform.submit();">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeAllDocs',1).'</option>';
1195 $opt[]='<option value=""></option>';
1196 }
1197 $opt[]='<option value="">[ '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_clearCache',1).' ]</option>';
1198 if ($id) $opt[]='<option value="'.$id.'">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_thisPage',1).'</option>';
1199 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>';
1200 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>';
1201
1202 $onChange = 'if (!this.options[this.selectedIndex].value) {
1203 this.selectedIndex=0;
1204 } else if (this.options[this.selectedIndex].value.indexOf(\';\')!=-1) {
1205 eval(this.options[this.selectedIndex].value);
1206 }else{
1207 document.location=\''.$this->backPath.'tce_db.php?vC='.$BE_USER->veriCode().'&redirect='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')).'&cacheCmd=\'+this.options[this.selectedIndex].value;
1208 }';
1209 $af_content = '<select name="cacheCmd" onchange="'.htmlspecialchars($onChange).'">'.implode('',$opt).'</select>';
1210
1211 if (count($opt)>2) {
1212 return $af_content;
1213 }
1214 }
1215
1216 /**
1217 * Returns an array with parts (JavaScript, init-functions, <div>-layers) for use on pages which displays the clickmenu layers (context sensitive menus)
1218 *
1219 * @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
1220 */
1221 function getContextMenuCode() {
1222 if ($this->isCMlayers()) {
1223 $content='
1224 <script type="text/javascript">
1225 /*<![CDATA[*/
1226 var GLV_gap=10;
1227 var GLV_curLayerX=new Array(0,0);
1228 var GLV_curLayerY=new Array(0,0);
1229 var GLV_curLayerWidth=new Array(0,0);
1230 var GLV_curLayerHeight=new Array(0,0);
1231 var GLV_isVisible=new Array(0,0);
1232 var GLV_x=0;
1233 var GLV_y=0;
1234 var GLV_xRel=0;
1235 var GLV_yRel=0;
1236 var layerObj=new Array();
1237 var layerObjCss=new Array();
1238
1239 //browsercheck...
1240 function GL_checkBrowser(){ //
1241 this.dom= (document.getElementById);
1242 this.op= (navigator.userAgent.indexOf("Opera")>-1);
1243 this.op7= this.op && (navigator.appVersion.indexOf("7")>-1); // check for Opera version 7
1244 this.konq= (navigator.userAgent.indexOf("Konq")>-1);
1245 this.ie4= (document.all && !this.dom && !this.op && !this.konq);
1246 this.ie5= (document.all && this.dom && !this.op && !this.konq);
1247 this.ns4= (document.layers && !this.dom && !this.konq);
1248 this.ns5= (!document.all && this.dom && !this.op && !this.konq);
1249 this.ns6= (this.ns5);
1250 this.bw= (this.ie4 || this.ie5 || this.ns4 || this.ns6 || this.op || this.konq);
1251 return this;
1252 }
1253 bw= new GL_checkBrowser();
1254
1255 // GL_getObj(obj)
1256 function GL_getObj(obj){ //
1257 nest="";
1258 this.el= (bw.ie4||bw.op7)?document.all[obj]:bw.ns4?eval(nest+"document."+obj):document.getElementById(obj);
1259 this.css= bw.ns4?this.el:this.el.style;
1260 this.ref= bw.ns4?this.el.document:document;
1261 this.x= (bw.ns4||bw.op)?this.css.left:this.el.offsetLeft;
1262 this.y= (bw.ns4||bw.op)?this.css.top:this.el.offsetTop;
1263 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;
1264 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;
1265 return this;
1266 }
1267 // GL_getObjCss(obj)
1268 function GL_getObjCss(obj){ //
1269 return bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?document.layers[obj]:0;
1270 }
1271 // GL_getMouse(event)
1272 function GL_getMouse(event) { //
1273 if (layerObj) {
1274 // GLV_x= (bw.ns4||bw.ns5)?event.pageX:(bw.ie4||bw.op)?event.clientX:(event.clientX-2)+document.body.scrollLeft;
1275 // GLV_y= (bw.ns4||bw.ns5)?event.pageY:(bw.ie4||bw.op)?event.clientY:(event.clientY-2)+document.body.scrollTop;
1276 // 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:
1277
1278 GLV_xRel = event.clientX-2;
1279 GLV_yRel = event.clientY-2;
1280 GLV_x = GLV_xRel + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
1281 GLV_y = GLV_yRel + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
1282
1283 // status = (GLV_x+GLV_gap-GLV_curLayerX[0]) + " | " + (GLV_y+GLV_gap-GLV_curLayerY[0]);
1284 if (GLV_isVisible[1]) {
1285 if (outsideLayer(1)) hideSpecific(1);
1286 } else if (GLV_isVisible[0]) {
1287 if (outsideLayer(0)) hideSpecific(0);
1288 }
1289 }
1290 }
1291 // outsideLayer(level)
1292 function outsideLayer(level) { //
1293 return GLV_x+GLV_gap-GLV_curLayerX[level] <0 ||
1294 GLV_y+GLV_gap-GLV_curLayerY[level] <0 ||
1295 GLV_curLayerX[level]+GLV_curLayerWidth[level]+GLV_gap-GLV_x <0 ||
1296 GLV_curLayerY[level]+GLV_curLayerHeight[level]+GLV_gap-GLV_y <0;
1297 }
1298 // setLayerObj(html,level)
1299 function setLayerObj(html,level) { //
1300 var winHeight = document.documentElement.clientHeight && !bw.op7 ? document.documentElement.clientHeight : document.body.clientHeight;
1301 var winWidth = document.documentElement.clientWidth && !bw.op7 ? document.documentElement.clientWidth : document.body.clientWidth;
1302 var tempLayerObj = GL_getObj("contentMenu"+level);
1303 var tempLayerObjCss = GL_getObjCss("contentMenu"+level);
1304
1305 if (tempLayerObj && (level==0 || GLV_isVisible[level-1])) {
1306 tempLayerObj.el.innerHTML = html;
1307 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;
1308 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;
1309
1310 // konqueror (3.2.2) workaround
1311 winHeight = (bw.konq)?window.innerHeight:winHeight;
1312 winWidth = (bw.konq)?window.innerWidth:winWidth;
1313
1314 // Adjusting the Y-height of the layer to fit it into the window frame if it goes under the window frame in the bottom:
1315 if (winHeight-tempLayerObj.height < GLV_yRel) {
1316 if (GLV_yRel < tempLayerObj.height) {
1317 GLV_y+= (winHeight-tempLayerObj.height-GLV_yRel); // Setting it so bottom is just above window height.
1318 } else {
1319 GLV_y-= tempLayerObj.height-8; // Showing the menu upwards
1320 }
1321 }
1322 // Adjusting the X position like Y above
1323 if (winWidth-tempLayerObj.width < GLV_xRel) {
1324 if (GLV_xRel < tempLayerObj.width) {
1325 GLV_x+= (winWidth-tempLayerObj.width-GLV_xRel);
1326 } else {
1327 GLV_x-= tempLayerObj.width-8;
1328 }
1329 }
1330 GLV_x = Math.max(GLV_x,1);
1331 GLV_y = Math.max(GLV_y,1);
1332
1333 GLV_curLayerX[level] = GLV_x;
1334 GLV_curLayerY[level] = GLV_y;
1335 tempLayerObjCss.left = GLV_x+"px";
1336 tempLayerObjCss.top = GLV_y+"px";
1337 tempLayerObjCss.visibility = "visible";
1338 if (bw.ie5) showHideSelectorBoxes("hidden");
1339
1340 GLV_isVisible[level]=1;
1341 GLV_curLayerWidth[level] = tempLayerObj.width;
1342 GLV_curLayerHeight[level] = tempLayerObj.height;
1343 }
1344 }
1345 // hideEmpty()
1346 function hideEmpty() { //
1347 hideSpecific(0);
1348 hideSpecific(1);
1349 return false;
1350 }
1351 // hideSpecific(level)
1352 function hideSpecific(level) { //
1353 GL_getObjCss("contentMenu"+level).visibility = "hidden";
1354 GL_getObj("contentMenu"+level).el.innerHTML = "";
1355 GLV_isVisible[level]=0;
1356
1357 if (bw.ie5 && level==0) showHideSelectorBoxes("visible");
1358 }
1359 // debugObj(obj,name)
1360 function debugObj(obj,name) { //
1361 var acc;
1362 for (i in obj) {if (obj[i]) {acc+=i+": "+obj[i]+"\n";}}
1363 alert("Object: "+name+"\n\n"+acc);
1364 }
1365 // initLayer()
1366 function initLayer(){ //
1367 if (document.all) {
1368 window.onmousemove=GL_getMouse;
1369 }
1370 layerObj = GL_getObj("contentMenu1");
1371 layerObjCss = GL_getObjCss("contentMenu1");
1372 }
1373 function showHideSelectorBoxes(action) { // This function by Michiel van Leening
1374 for (i=0;i<document.forms.length;i++) {
1375 for (j=0;j<document.forms[i].elements.length;j++) {
1376 if(document.forms[i].elements[j].type=="select-one") {
1377 document.forms[i].elements[j].style.visibility=action;
1378 }
1379 }
1380 }
1381 }
1382 /*]]>*/
1383 </script>
1384 ';
1385 return array(
1386 $content,
1387 ' onmousemove="GL_getMouse(event);" onload="initLayer();"',
1388 '<div id="contentMenu0" style="z-index:1; position:absolute;visibility:hidden"></div><div id="contentMenu1" style="z-index:2; position:absolute;visibility:hidden"></div>'
1389 );
1390 } else return array('','','');
1391 }
1392
1393 /**
1394 * Creates a tab menu from an array definition
1395 *
1396 * Returns a tab menu for a module
1397 * Requires the JS function jumpToUrl() to be available
1398 *
1399 * @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=...
1400 * @param string $elementName it the form elements name, probably something like "SET[...]"
1401 * @param string $currentValue is the value to be selected currently.
1402 * @param array $menuItems is an array with the menu items for the selector box
1403 * @param string $script is the script to send the &id to, if empty it's automatically found
1404 * @param string $addParams is additional parameters to pass to the script.
1405 * @return string HTML code for tab menu
1406 * @author René Fritz <r.fritz@colorcube.de>
1407 */
1408 function getTabMenu($mainParams,$elementName,$currentValue,$menuItems,$script='',$addparams='') {
1409 $content='';
1410
1411 if (is_array($menuItems)) {
1412 if (!is_array($mainParams)) {
1413 $mainParams = array('id' => $mainParams);
1414 }
1415 $mainParams = t3lib_div::implodeArrayForUrl('',$mainParams);
1416
1417 if (!$script) {$script=basename(PATH_thisScript);}
1418
1419 $menuDef = array();
1420 foreach($menuItems as $value => $label) {
1421 $menuDef[$value]['isActive'] = !strcmp($currentValue,$value);
1422 $menuDef[$value]['label'] = t3lib_div::deHSCentities(htmlspecialchars($label));
1423 $menuDef[$value]['url'] = htmlspecialchars($script.'?'.$mainParams.$addparams.'&'.$elementName.'='.$value);
1424 }
1425 $content = $this->getTabMenuRaw($menuDef);
1426
1427 }
1428 return $content;
1429 }
1430
1431 /**
1432 * Creates the HTML content for the tab menu
1433 *
1434 * @param array Menu items for tabs
1435 * @return string Table HTML
1436 * @access private
1437 */
1438 function getTabMenuRaw($menuItems) {
1439 $content='';
1440
1441 if (is_array($menuItems)) {
1442 $options='';
1443
1444 $count = count($menuItems);
1445 $widthLeft = 1;
1446 $addToAct = 5;
1447
1448 $widthRight = max (1,floor(30-pow($count,1.72)));
1449 $widthTabs = 100 - $widthRight - $widthLeft;
1450 $widthNo = floor(($widthTabs - $addToAct)/$count);
1451 $addToAct = max ($addToAct,$widthTabs-($widthNo*$count));
1452 $widthAct = $widthNo + $addToAct;
1453 $widthRight = 100 - ($widthLeft + ($count*$widthNo) + $addToAct);
1454
1455 $first=true;
1456 foreach($menuItems as $id => $def) {
1457 $isActive = $def['isActive'];
1458 $class = $isActive ? 'tabact' : 'tab';
1459 $width = $isActive ? $widthAct : $widthNo;
1460
1461 // @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.
1462 $label = $def['label'];
1463 $url = htmlspecialchars($def['url']);
1464 $params = $def['addParams'];
1465
1466 if($first) {
1467 $options.= '
1468 <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>';
1469 } else {
1470 $options.='
1471 <td width="'.$width.'%" class="'.$class.'"><a href="'.$url.'" '.$params.'>'.$label.'</a></td>';
1472 }
1473 $first=false;
1474 }
1475
1476 if ($options) {
1477 $content .= '
1478 <!-- Tab menu -->
1479 <table cellpadding="0" cellspacing="0" border="0" width="100%" id="typo3-tabmenu">
1480 <tr>
1481 <td width="'.$widthLeft.'%">&nbsp;</td>
1482 '.$options.'
1483 <td width="'.$widthRight.'%">&nbsp;</td>
1484 </tr>
1485 </table>
1486 <div class="hr" style="margin:0px"></div>';
1487 }
1488
1489 }
1490 return $content;
1491 }
1492
1493 /**
1494 * Creates a DYNAMIC tab-menu where the tabs are switched between with DHTML.
1495 * 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!
1496 *
1497 * @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.
1498 * @param string Identification string. This should be unique for every instance of a dynamic menu!
1499 * @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.
1500 * @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.
1501 * @param integer Character limit for a new row.
1502 * @param boolean If set, tab table cells are not allowed to wrap their content
1503 * @param boolean If set, the tabs will span the full width of their position
1504 * @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.
1505 * @return string JavaScript section for the HTML header.
1506 */
1507 function getDynTabMenu($menuItems,$identString,$toggle=0,$foldout=FALSE,$newRowCharLimit=50,$noWrap=1,$fullWidth=FALSE,$defaultTabIndex=1) {
1508 $content = '';
1509
1510 if (is_array($menuItems)) {
1511
1512 // Init:
1513 $options = array(array());
1514 $divs = array();
1515 $JSinit = array();
1516 $id = 'DTM-'.t3lib_div::shortMD5($identString);
1517 $noWrap = $noWrap ? ' nowrap="nowrap"' : '';
1518
1519 // Traverse menu items
1520 $c=0;
1521 $tabRows=0;
1522 $titleLenCount = 0;
1523 foreach($menuItems as $index => $def) {
1524 $index+=1; // Need to add one so checking for first index in JavaScript is different than if it is not set at all.
1525
1526 // Switch to next tab row if needed
1527 if (!$foldout && $titleLenCount>$newRowCharLimit) { // 50 characters is probably a reasonable count of characters before switching to next row of tabs.
1528 $titleLenCount=0;
1529 $tabRows++;
1530 $options[$tabRows] = array();
1531 }
1532
1533 if ($toggle==1) {
1534 $onclick = 'this.blur(); DTM_toggle("'.$id.'","'.$index.'"); return false;';
1535 } else {
1536 $onclick = 'this.blur(); DTM_activate("'.$id.'","'.$index.'", '.($toggle<0?1:0).'); return false;';
1537 }
1538
1539 $isActive = strcmp($def['content'],'');
1540
1541 $mouseOverOut = 'onmouseover="DTM_mouseOver(this);" onmouseout="DTM_mouseOut(this);"';
1542
1543 if (!$foldout) {
1544 // Create TAB cell:
1545 $options[$tabRows][] = '
1546 <td class="'.($isActive ? 'tab' : 'disabled').'" id="'.$id.'-'.$index.'-MENU"'.$noWrap.$mouseOverOut.'>'.
1547 ($isActive ? '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ? ' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>' : '').
1548 $def['icon'].
1549 ($def['label'] ? htmlspecialchars($def['label']) : '&nbsp;').
1550 $this->icons($def['stateIcon'],'margin-left: 10px;').
1551 ($isActive ? '</a>' :'').
1552 '</td>';
1553 $titleLenCount+= strlen($def['label']);
1554 } else {
1555 // Create DIV layer for content:
1556 $divs[] = '
1557 <div class="'.($isActive ? 'tab' : 'disabled').'" id="'.$id.'-'.$index.'-MENU"'.$mouseOverOut.'>'.
1558 ($isActive ? '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ? ' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>' : '').
1559 $def['icon'].
1560 ($def['label'] ? htmlspecialchars($def['label']) : '&nbsp;').
1561 ($isActive ? '</a>' : '').
1562 '</div>';
1563 }
1564
1565 if ($isActive) {
1566 // Create DIV layer for content:
1567 $divs[] = '
1568 <div style="display: none;" id="'.$id.'-'.$index.'-DIV" class="c-tablayer">'.
1569 ($def['description'] ? '<p class="c-descr">'.nl2br(htmlspecialchars($def['description'])).'</p>' : '').
1570 $def['content'].
1571 '</div>';
1572 // Create initialization string:
1573 $JSinit[] = '
1574 DTM_array["'.$id.'"]['.$c.'] = "'.$id.'-'.$index.'";
1575 ';
1576 if ($toggle==1) {
1577 $JSinit[] = '
1578 if (top.DTM_currentTabs["'.$id.'-'.$index.'"]) { DTM_toggle("'.$id.'","'.$index.'",1); }
1579 ';
1580 }
1581
1582 $c++;
1583 }
1584 }
1585
1586 // Render menu:
1587 if (count($options)) {
1588
1589 // Tab menu is compiled:
1590 if (!$foldout) {
1591 $tabContent = '';
1592 for($a=0;$a<=$tabRows;$a++) {
1593 $tabContent.= '
1594
1595 <!-- Tab menu -->
1596 <table cellpadding="0" cellspacing="0" border="0"'.($fullWidth ? ' width="100%"' : '').' class="typo3-dyntabmenu">
1597 <tr>
1598 '.implode('',$options[$a]).'
1599 </tr>
1600 </table>';
1601 }
1602 $content.= '<div class="typo3-dyntabmenu-tabs">'.$tabContent.'</div>';
1603 }
1604
1605 // Div layers are added:
1606 $content.= '
1607 <!-- Div layers for tab menu: -->
1608 <div class="typo3-dyntabmenu-divs'.($foldout?'-foldout':'').'">
1609 '.implode('',$divs).'</div>';
1610
1611 // Java Script section added:
1612 $content.= '
1613 <!-- Initialization JavaScript for the menu -->
1614 <script type="text/javascript">
1615 DTM_array["'.$id.'"] = new Array();
1616 '.implode('',$JSinit).'
1617 '.($toggle<=0 ? 'DTM_activate("'.$id.'", top.DTM_currentTabs["'.$id.'"]?top.DTM_currentTabs["'.$id.'"]:'.intval($defaultTabIndex).', 0);' : '').'
1618 </script>
1619
1620 ';
1621 }
1622
1623 }
1624 return $content;
1625 }
1626
1627 /**
1628 * Returns dynamic tab menu header JS code.
1629 *
1630 * @return string JavaScript section for the HTML header.
1631 */
1632 function getDynTabMenuJScode() {
1633 return '
1634 <script type="text/javascript">
1635 /*<![CDATA[*/
1636 var DTM_array = new Array();
1637 var DTM_origClass = new String();
1638
1639 function DTM_activate(idBase,index,doToogle) { //
1640 // Hiding all:
1641 if (DTM_array[idBase]) {
1642 for(cnt = 0; cnt < DTM_array[idBase].length ; cnt++) {
1643 if (DTM_array[idBase][cnt] != idBase+"-"+index) {
1644 document.getElementById(DTM_array[idBase][cnt]+"-DIV").style.display = "none";
1645 document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
1646 }
1647 }
1648 }
1649
1650 // Showing one:
1651 if (document.getElementById(idBase+"-"+index+"-DIV")) {
1652 if (doToogle && document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
1653 document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
1654 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
1655 top.DTM_currentTabs[idBase] = -1;
1656 } else {
1657 document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
1658 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
1659 top.DTM_currentTabs[idBase] = index;
1660 }
1661 }
1662 }
1663 function DTM_toggle(idBase,index,isInit) { //
1664 // Showing one:
1665 if (document.getElementById(idBase+"-"+index+"-DIV")) {
1666 if (document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
1667 document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
1668 if(isInit) {
1669 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
1670 } else {
1671 DTM_origClass = "tab";
1672 }
1673 top.DTM_currentTabs[idBase+"-"+index] = 0;
1674 } else {
1675 document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
1676 if(isInit) {
1677 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
1678 } else {
1679 DTM_origClass = "tabact";
1680 }
1681 top.DTM_currentTabs[idBase+"-"+index] = 1;
1682 }
1683 }
1684 }
1685
1686 function DTM_mouseOver(obj) {
1687 DTM_origClass = obj.attributes.getNamedItem(\'class\').nodeValue;
1688 obj.attributes.getNamedItem(\'class\').nodeValue += "_over";
1689 }
1690
1691 function DTM_mouseOut(obj) {
1692 obj.attributes.getNamedItem(\'class\').nodeValue = DTM_origClass;
1693 DTM_origClass = "";
1694 }
1695
1696
1697 /*]]>*/
1698 </script>
1699 ';
1700 }
1701
1702 /**
1703 * Creates the version selector for the page id inputted.
1704 * Requires the core version management extension, "version" to be loaded.
1705 *
1706 * @param integer Page id to create selector for.
1707 * @param boolean If set, there will be no button for swapping page.
1708 * @return void
1709 */
1710 function getVersionSelector($id,$noAction=FALSE) {
1711
1712 if ($id>0 && t3lib_extMgm::isLoaded('version')) {
1713
1714 // Get Current page record:
1715 $curPage = t3lib_BEfunc::getRecord('pages',$id);
1716 // If the selected page is not online, find the right ID
1717 $onlineId = ($curPage['pid']==-1 ? $curPage['t3ver_oid'] : $id);
1718 // Select all versions of online version:
1719 $versions = t3lib_BEfunc::selectVersionsOfRecord('pages', $onlineId, 'uid,pid,t3ver_label,t3ver_oid,t3ver_id');
1720
1721 // If more than one was found...:
1722 if (count($versions)>1) {
1723
1724 // Create selector box entries:
1725 $opt = array();
1726 foreach($versions as $vRow) {
1727 $opt[] = '<option value="'.htmlspecialchars(t3lib_div::linkThisScript(array('id'=>$vRow['uid']))).'"'.($id==$vRow['uid']?' selected="selected"':'').'>'.
1728 htmlspecialchars($vRow['t3ver_label'].' [v#'.$vRow['t3ver_id'].']'.($vRow['uid']==$onlineId ? ' =>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.online').'<=':'')).
1729 '</option>';
1730 }
1731
1732 // Add management link:
1733 $opt[] = '<option value="'.htmlspecialchars(t3lib_div::linkThisScript(array('id'=>$id))).'">---</option>';
1734 $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>';
1735
1736 // Create onchange handler:
1737 $onChange = "document.location=this.options[this.selectedIndex].value;";
1738
1739 // Controls:
1740 if ($id==$onlineId) {
1741 $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>';
1742 } elseif (!$noAction) {
1743 $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))).'">'.
1744 '<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).'" />'.
1745 '<b>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.swap',1).'</b></a>';
1746 }
1747
1748 // Write out HTML code:
1749 return '
1750
1751 <!--
1752 Version selector:
1753 -->
1754 <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
1755 <tr>
1756 <td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.selVer',1).'</td>
1757 <td>
1758 <select onchange="'.htmlspecialchars($onChange).'">
1759 '.implode('',$opt).'
1760 </select></td>
1761 <td>'.$controls.'</td>
1762 </tr>
1763 </table>
1764 ';
1765 }
1766 }
1767 }
1768 }
1769
1770
1771
1772 // ******************************
1773 // Extension classes of the template class.
1774 // These are meant to provide backend screens with different widths.
1775 // They still do because of the different class-prefixes used for the <div>-sections
1776 // but obviously the final width is determined by the stylesheet used.
1777 // ******************************
1778
1779 /**
1780 * 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
1781 * The class were more significant in the past than today.
1782 *
1783 */
1784 class bigDoc extends template {
1785 var $divClass = 'typo3-bigDoc';
1786 }
1787
1788 /**
1789 * Extension class for "template" - used for backend pages without the "document" background image
1790 * The class were more significant in the past than today.
1791 *
1792 */
1793 class noDoc extends template {
1794 var $divClass = 'typo3-noDoc';
1795 }
1796
1797 /**
1798 * 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)
1799 * The class were more significant in the past than today.
1800 *
1801 */
1802 class smallDoc extends template {
1803 var $divClass = 'typo3-smallDoc';
1804 }
1805
1806 /**
1807 * 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.
1808 * The class were more significant in the past than today. But probably you should use this one for most modules you make.
1809 *
1810 */
1811 class mediumDoc extends template {
1812 var $divClass = 'typo3-mediumDoc';
1813 }
1814
1815
1816
1817 // Include extension to the template class?
1818 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/template.php']) {
1819 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/template.php']);
1820 }
1821
1822
1823
1824 // ******************************************************
1825 // The backend language engine is started (ext: "lang")
1826 // ******************************************************
1827 require_once(PATH_typo3.'sysext/lang/lang.php');
1828 $LANG = t3lib_div::makeInstance('language');
1829 $LANG->init($BE_USER->uc['lang']);
1830
1831
1832
1833 // ******************************
1834 // The template is loaded
1835 // ******************************
1836 $TBE_TEMPLATE = t3lib_div::makeInstance('template');
1837 ?>