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