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