Fixed bug #5949: BE-Shortcut to Tools->User Admin returns error
[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 $JScode=''; // Additional header code (eg. a JavaScript section) could be accommulated in this var. It will be directly outputted in the header.
175 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.
176 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.
177 var $docType = ''; // Doc-type used in the header. Default is HTML 4. You can also set it to 'strict', 'xhtml_trans', or 'xhtml_frames'.
178
179 // Other vars you can change, but less frequently used:
180 var $scriptID=''; // Script ID.
181 var $bodyTagId=''; // Id which can be set for the body tag. Default value is based on script ID
182 var $bodyTagAdditions=''; // You can add additional attributes to the body-tag through this variable.
183 var $inDocStyles=''; // Additional CSS styles which will be added to the <style> section in the header
184 var $inDocStylesArray=array(); // Like $inDocStyles but for use as array with associative keys to prevent double inclusion of css code
185 var $form_rowsToStylewidth = 9.58; // Multiplication factor for formWidth() input size (default is 48* this value).
186 var $form_largeComp = 1.33; // Compensation for large documents (used in class.t3lib_tceforms.php)
187 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.
188
189 // TYPO3 Colorscheme.
190 // If you want to change this, please do so through a skin using the global var $TBE_STYLES
191 var $bgColor = '#F7F3EF'; // Light background color
192 var $bgColor2 = '#9BA1A8'; // Steel-blue
193 var $bgColor3 = '#F6F2E6'; // dok.color
194 var $bgColor4 = '#D9D5C9'; // light tablerow background, brownish
195 var $bgColor5 = '#ABBBB4'; // light tablerow background, greenish
196 var $bgColor6 = '#E7DBA8'; // light tablerow background, yellowish, for section headers. Light.
197 var $hoverColor = '#254D7B';
198 var $styleSheetFile = 'stylesheet.css'; // Filename of stylesheet (relative to PATH_typo3)
199 var $styleSheetFile2 = ''; // Filename of stylesheet #2 - linked to right after the $this->styleSheetFile script (relative to PATH_typo3)
200 var $styleSheetFile_post = ''; // Filename of a post-stylesheet - included right after all inline styles.
201 var $backGroundImage = ''; // Background image of page (relative to PATH_typo3)
202 var $inDocStyles_TBEstyle = ''; // Inline css styling set from TBE_STYLES array
203
204 // DEV:
205 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.
206
207 // INTERNAL
208 var $charset = 'iso-8859-1'; // Default charset. see function initCharset()
209
210 var $sectionFlag=0; // Internal: Indicates if a <div>-output section is open
211 var $divClass = ''; // (Default) Class for wrapping <DIV>-tag of page. Is set in class extensions.
212
213
214
215
216
217
218 /**
219 * Constructor
220 * Imports relevant parts from global $TBE_STYLES (colorscheme)
221 *
222 * @return void
223 */
224 function template() {
225 global $TBE_STYLES;
226
227 // Setting default scriptID:
228 $this->scriptID = ereg_replace('^.*\/(sysext|ext)\/','ext/',substr(PATH_thisScript,strlen(PATH_site)));
229 if (TYPO3_mainDir!='typo3/' && substr($this->scriptID,0,strlen(TYPO3_mainDir)) == TYPO3_mainDir) {
230 $this->scriptID = 'typo3/'.substr($this->scriptID,strlen(TYPO3_mainDir)); // This fixes if TYPO3_mainDir has been changed so the script ids are STILL "typo3/..."
231 }
232
233 $this->bodyTagId = ereg_replace('[^[:alnum:]-]','-',$this->scriptID);
234
235 // Individual configuration per script? If so, make a recursive merge of the arrays:
236 if (is_array($TBE_STYLES['scriptIDindex'][$this->scriptID])) {
237 $ovr = $TBE_STYLES['scriptIDindex'][$this->scriptID]; // Make copy
238 $TBE_STYLES = t3lib_div::array_merge_recursive_overrule($TBE_STYLES,$ovr); // merge styles.
239 unset($TBE_STYLES['scriptIDindex'][$this->scriptID]); // Have to unset - otherwise the second instantiation will do it again!
240 }
241
242 // Color scheme:
243 if ($TBE_STYLES['mainColors']['bgColor']) $this->bgColor=$TBE_STYLES['mainColors']['bgColor'];
244 if ($TBE_STYLES['mainColors']['bgColor1']) $this->bgColor1=$TBE_STYLES['mainColors']['bgColor1'];
245 if ($TBE_STYLES['mainColors']['bgColor2']) $this->bgColor2=$TBE_STYLES['mainColors']['bgColor2'];
246 if ($TBE_STYLES['mainColors']['bgColor3']) $this->bgColor3=$TBE_STYLES['mainColors']['bgColor3'];
247 if ($TBE_STYLES['mainColors']['bgColor4']) $this->bgColor4=$TBE_STYLES['mainColors']['bgColor4'];
248 if ($TBE_STYLES['mainColors']['bgColor5']) $this->bgColor5=$TBE_STYLES['mainColors']['bgColor5'];
249 if ($TBE_STYLES['mainColors']['bgColor6']) $this->bgColor6=$TBE_STYLES['mainColors']['bgColor6'];
250 if ($TBE_STYLES['mainColors']['hoverColor']) $this->hoverColor=$TBE_STYLES['mainColors']['hoverColor'];
251
252 // Main Stylesheets:
253 if ($TBE_STYLES['stylesheet']) $this->styleSheetFile = $TBE_STYLES['stylesheet'];
254 if ($TBE_STYLES['stylesheet2']) $this->styleSheetFile2 = $TBE_STYLES['stylesheet2'];
255 if ($TBE_STYLES['styleSheetFile_post']) $this->styleSheetFile_post = $TBE_STYLES['styleSheetFile_post'];
256 if ($TBE_STYLES['inDocStyles_TBEstyle']) $this->inDocStyles_TBEstyle = $TBE_STYLES['inDocStyles_TBEstyle'];
257
258 // Background image
259 if ($TBE_STYLES['background']) $this->backGroundImage = $TBE_STYLES['background'];
260 }
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277 /*****************************************
278 *
279 * EVALUATION FUNCTIONS
280 * Various centralized processing
281 *
282 *****************************************/
283
284 /**
285 * Makes click menu link (context sensitive menu)
286 * 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)
287 * 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)
288 *
289 * @param string String to be wrapped in link, typ. image tag.
290 * @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
291 * @param integer If icon is for database record this is the UID for the record from $table
292 * @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.
293 * @param string Additional GET parameters for the link to alt_clickmenu.php
294 * @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.
295 * @param boolean If set, will return only the onclick JavaScript, not the whole link.
296 * @return string The link-wrapped input string.
297 */
298 function wrapClickMenuOnIcon($str,$table,$uid='',$listFr=1,$addParams='',$enDisItems='', $returnOnClick=FALSE) {
299 $backPath = rawurlencode($this->backPath).'|'.t3lib_div::shortMD5($this->backPath.'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']);
300 $onClick = 'showClickmenu("'.$table.'","'.$uid.'","'.$listFr.'","'.str_replace('+','%2B',$enDisItems).'","'.str_replace('&','&amp;',addcslashes($backPath,'"')).'","'.str_replace('&','&amp;',addcslashes($addParams,'"')).'");return false;';
301 return $returnOnClick ? $onClick : '<a href="#" onclick="'.htmlspecialchars($onClick).'"'.($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler'] ? ' oncontextmenu="'.htmlspecialchars($onClick).'"' : '').'>'.$str.'</a>';
302 }
303
304 /**
305 * Makes link to page $id in frontend (view page)
306 * Returns an magnifier-glass icon which links to the frontend index.php document for viewing the page with id $id
307 * $id must be a page-uid
308 * If the BE_USER has access to Web>List then a link to that module is shown as well (with return-url)
309 *
310 * @param integer The page id
311 * @param string The current "BACK_PATH" (the back relative to the typo3/ directory)
312 * @param string Additional parameters for the image tag(s)
313 * @return string HTML string with linked icon(s)
314 */
315 function viewPageIcon($id,$backPath,$addParams='hspace="3"') {
316 global $BE_USER;
317 $str = '';
318 // If access to Web>List for user, then link to that module.
319 if ($BE_USER->check('modules','web_list')) {
320 $href=$backPath.'db_list.php?id='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
321 $str.= '<a href="'.htmlspecialchars($href).'">'.
322 '<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="" />'.
323 '</a>';
324 }
325 // Make link to view page
326 $str.= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($id,$backPath,t3lib_BEfunc::BEgetRootLine($id))).'">'.
327 '<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="" />'.
328 '</a>';
329 return $str;
330 }
331
332 /**
333 * Returns a URL with a command to TYPO3 Core Engine (tce_db.php)
334 * See description of the API elsewhere.
335 *
336 * @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"
337 * @param string Redirect URL if any other that t3lib_div::getIndpEnv('REQUEST_URI') is wished
338 * @return string URL to tce_db.php + parameters (backpath is taken from $this->backPath)
339 * @see t3lib_BEfunc::editOnClick()
340 */
341 function issueCommand($params,$rUrl='') {
342 $rUrl = $rUrl ? $rUrl : t3lib_div::getIndpEnv('REQUEST_URI');
343 return $this->backPath.'tce_db.php?'.
344 $params.
345 '&redirect='.($rUrl==-1?"'+T3_THIS_LOCATION+'":rawurlencode($rUrl)).
346 '&vC='.rawurlencode($GLOBALS['BE_USER']->veriCode()).
347 '&prErr=1&uPT=1';
348 }
349
350 /**
351 * Returns true if click-menu layers can be displayed for the current user/browser
352 * Use this to test if click-menus (context sensitive menus) can and should be displayed in the backend.
353 *
354 * @return boolean
355 */
356 function isCMlayers() {
357 return !$GLOBALS['BE_USER']->uc['disableCMlayers'] && $GLOBALS['CLIENT']['FORMSTYLE'] && !($GLOBALS['CLIENT']['SYSTEM']=='mac' && $GLOBALS['CLIENT']['BROWSER']=='Opera');
358 }
359
360 /**
361 * Returns 'this.blur();' if the client supports CSS styles
362 * Use this in links to remove the underlining after being clicked
363 *
364 * @return string
365 */
366 function thisBlur() {
367 return ($GLOBALS['CLIENT']['FORMSTYLE']?'this.blur();':'');
368 }
369
370 /**
371 * Returns ' style='cursor:help;'' if the client supports CSS styles
372 * Use for <a>-links to help texts
373 *
374 * @return string
375 */
376 function helpStyle() {
377 return $GLOBALS['CLIENT']['FORMSTYLE'] ? ' style="cursor:help;"':'';
378 }
379
380 /**
381 * Makes the header (icon+title) for a page (or other record). Used in most modules under Web>*
382 * $table and $row must be a tablename/record from that table
383 * $path will be shown as alt-text for the icon.
384 * The title will be truncated to 45 chars.
385 *
386 * @param string Table name
387 * @param array Record row
388 * @param string Alt text
389 * @param boolean Set $noViewPageIcon true if you don't want a magnifier-icon for viewing the page in the frontend
390 * @param array $tWrap is an array with indexes 0 and 1 each representing HTML-tags (start/end) which will wrap the title
391 * @return string HTML content
392 */
393 function getHeader($table,$row,$path,$noViewPageIcon=0,$tWrap=array('','')) {
394 global $TCA;
395 if (is_array($row) && $row['uid']) {
396 $iconImgTag=t3lib_iconWorks::getIconImage($table,$row,$this->backPath,'title="'.htmlspecialchars($path).'"');
397 $title= strip_tags($row[$TCA[$table]['ctrl']['label']]);
398 $viewPage = $noViewPageIcon ? '' : $this->viewPageIcon($row['uid'],$this->backPath,'');
399 if ($table=='pages') $path.=' - '.t3lib_BEfunc::titleAttribForPages($row,'',0);
400 } else {
401 $iconImgTag='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/_icon_website.gif',$wHattribs='width="18" height="16"').' title="'.htmlspecialchars($path).'" alt="" />';
402 $title=$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
403 }
404
405 return '<span class="typo3-moduleHeader">'.$this->wrapClickMenuOnIcon($iconImgTag,$table,$row['uid']).
406 $viewPage.
407 $tWrap[0].htmlspecialchars(t3lib_div::fixed_lgd_cs($title,45)).$tWrap[1].'</span>';
408 }
409
410 /**
411 * Like ->getHeader() but for files in the File>* main module/submodules
412 * Returns the file-icon with the path of the file set in the alt/title attribute. Shows the file-name after the icon.
413 *
414 * @param string Title string, expected to be the filepath
415 * @param string Alt text
416 * @param string The icon file (relative to TYPO3 dir)
417 * @return string HTML content
418 */
419 function getFileheader($title,$path,$iconfile) {
420 $fileInfo = t3lib_div::split_fileref($title);
421 $title = htmlspecialchars(t3lib_div::fixed_lgd_cs($fileInfo['path'],-35)).'<b>'.htmlspecialchars($fileInfo['file']).'</b>';
422 return '<span class="typo3-moduleHeader"><img'.t3lib_iconWorks::skinImg($this->backPath,$iconfile,'width="18" height="16"').' title="'.htmlspecialchars($path).'" alt="" />'.$title.'</span>';
423 }
424
425 /**
426 * Returns a linked shortcut-icon which will call the shortcut frame and set a shortcut there back to the calling page/module
427 *
428 * @param string Is the list of GET variables to store (if any)
429 * @param string Is the list of SET[] variables to store (if any) - SET[] variables a stored in $GLOBALS["SOBE"]->MOD_SETTINGS for backend modules
430 * @param string Module name string
431 * @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.
432 * @return string HTML content
433 */
434 function makeShortcutIcon($gvList,$setList,$modName,$motherModName="") {
435 $backPath=$this->backPath;
436 $storeUrl=$this->makeShortcutUrl($gvList,$setList);
437 $pathInfo = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
438
439 // Add the module identifier automatically if typo3/mod.php is used:
440 if (ereg('typo3/mod\.php$', $pathInfo['path']) && isset($GLOBALS['TBE_MODULES']['_PATHS'][$modName])) {
441 $storeUrl = '&M='.$modName.$storeUrl;
442 }
443
444 if (!strcmp($motherModName,'1')) {
445 $mMN="&motherModName='+top.currentModuleLoaded+'";
446 } elseif ($motherModName) {
447 $mMN='&motherModName='.rawurlencode($motherModName);
448 } else $mMN='';
449
450 $onClick = 'if (top.shortcutFrame && confirm('.
451 $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.makeShortcut')).
452 ')){top.shortcutFrame.location.href=\''.$backPath.'alt_shortcut.php?modName='.rawurlencode($modName).
453 '&URL='.rawurlencode($pathInfo['path']."?".$storeUrl).
454 $mMN.
455 '\';}return false;';
456
457 $sIcon = '<a href="#" onclick="'.htmlspecialchars($onClick).'">
458 <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 '.$this->JScode.'
665 '.$tabJScode.'
666 '.$this->wrapScriptTags(implode("\n", $this->JScodeArray)).'
667 <!--###POSTJSMARKER###-->
668 </head>
669 ';
670 $this->JScode='';
671 $this->JScodeArray=array();
672
673 if ($this->docType=='xhtml_frames') {
674 return $str;
675 } else
676 $str.=$this->docBodyTagBegin().
677 ($this->divClass?'
678
679 <!-- Wrapping DIV-section for whole page BEGIN -->
680 <div class="'.$this->divClass.'">
681 ':'').trim($this->form);
682 return $str;
683 }
684
685 /**
686 * Returns page end; This includes finishing form, div, body and html tags.
687 *
688 * @return string The HTML end of a page
689 * @see startPage()
690 */
691 function endPage() {
692 $str = $this->sectionEnd().
693 $this->postCode.
694 $this->endPageJS().
695 t3lib_BEfunc::getSetUpdateSignal().
696 $this->parseTime().
697 ($this->form?'
698 </form>':'');
699
700 if ($this->docType!='xhtml_frames') {
701
702 $str .= ($this->divClass?'
703
704 <!-- Wrapping DIV-section for whole page END -->
705 </div>':'').'
706 </body> ';
707
708 }
709
710 $str .= '</html>';
711
712 // Logging: Can't find better place to put it:
713 if (TYPO3_DLOG) t3lib_div::devLog('END of BACKEND session','',0,array('_FLUSH'=>TRUE));
714
715 return $str;
716 }
717
718 /**
719 * Returns the header-bar in the top of most backend modules
720 * Closes section if open.
721 *
722 * @param string The text string for the header
723 * @return string HTML content
724 */
725 function header($text) {
726 $str='
727
728 <!-- MAIN Header in page top -->
729 <h2>'.htmlspecialchars($text).'</h2>
730 ';
731 return $this->sectionEnd().$str;
732 }
733
734 /**
735 * Begins an output section and sets header and content
736 *
737 * @param string The header
738 * @param string The HTML-content
739 * @param boolean A flag that will prevent the header from being converted to uppercase
740 * @param boolean Defines the type of header (if set, "<h3>" rather than the default "h4")
741 * @param integer The number of an icon to show with the header (see the icon-function). -1,1,2,3
742 * @param boolean If set, HTML tags are allowed in $label (otherwise this value is by default htmlspecialchars()'ed)
743 * @return string HTML content
744 * @see icons(), sectionHeader()
745 */
746 function section($label,$text,$nostrtoupper=FALSE,$sH=FALSE,$type=0,$allowHTMLinHeader=FALSE) {
747 $str='';
748
749 // Setting header
750 if ($label) {
751 if (!$allowHTMLinHeader) $label = htmlspecialchars($label);
752 $str.=$this->sectionHeader($this->icons($type).$label, $sH, $nostrtoupper ? '' : ' class="uppercase"');
753 }
754 // Setting content
755 $str.='
756
757 <!-- Section content -->
758 '.$text;
759
760 return $this->sectionBegin().$str;
761 }
762
763 /**
764 * Inserts a divider image
765 * Ends a section (if open) before inserting the image
766 *
767 * @param integer The margin-top/-bottom of the <hr> ruler.
768 * @return string HTML content
769 */
770 function divider($dist) {
771 $dist = intval($dist);
772 $str='
773
774 <!-- DIVIDER -->
775 <hr style="margin-top: '.$dist.'px; margin-bottom: '.$dist.'px;" />
776 ';
777 return $this->sectionEnd().$str;
778 }
779
780 /**
781 * Returns a blank <div>-section with a height
782 *
783 * @param integer Padding-top for the div-section (should be margin-top but konqueror (3.1) doesn't like it :-(
784 * @return string HTML content
785 */
786 function spacer($dist) {
787 if ($dist>0) {
788 return '
789
790 <!-- Spacer element -->
791 <div style="padding-top: '.intval($dist).'px;"></div>
792 ';
793 }
794 }
795
796 /**
797 * Make a section header.
798 * Begins a section if not already open.
799 *
800 * @param string The label between the <h3> or <h4> tags. (Allows HTML)
801 * @param boolean If set, <h3> is used, otherwise <h4>
802 * @param string Additional attributes to h-tag, eg. ' class=""'
803 * @return string HTML content
804 */
805 function sectionHeader($label,$sH=FALSE,$addAttrib='') {
806 $tag = ($sH?'h3':'h4');
807 $str='
808
809 <!-- Section header -->
810 <'.$tag.$addAttrib.'>'.$label.'</'.$tag.'>
811 ';
812 return $this->sectionBegin().$str;
813 }
814
815 /**
816 * Begins an output section.
817 * Returns the <div>-begin tag AND sets the ->sectionFlag true (if the ->sectionFlag is not already set!)
818 * 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!
819 *
820 * @return string HTML content
821 */
822 function sectionBegin() {
823 if (!$this->sectionFlag) {
824 $this->sectionFlag=1;
825 $str='
826
827 <!-- ***********************
828 Begin output section.
829 *********************** -->
830 <div>
831 ';
832 return $str;
833 } else return '';
834 }
835
836 /**
837 * Ends and output section
838 * Returns the </div>-end tag AND clears the ->sectionFlag (but does so only IF the sectionFlag is set - that is a section is 'open')
839 * See sectionBegin() also.
840 *
841 * @return string HTML content
842 */
843 function sectionEnd() {
844 if ($this->sectionFlag) {
845 $this->sectionFlag=0;
846 return '
847 </div>
848 <!-- *********************
849 End output section.
850 ********************* -->
851 ';
852 } else return '';
853 }
854
855 /**
856 * Originally it printed a kind of divider.
857 * Deprecated. Just remove function calls to it or call the divider() function instead.
858 *
859 * @return void
860 * @internal
861 * @deprecated
862 */
863 function middle() {
864 }
865
866 /**
867 * If a form-tag is defined in ->form then and end-tag for that <form> element is outputted
868 * Further a JavaScript section is outputted which will update the top.busy session-expiry object (unless $this->endJS is set to false)
869 *
870 * @return string HTML content (<script> tag section)
871 */
872 function endPageJS() {
873 return ($this->endJS?'
874 <script type="text/javascript">
875 /*<![CDATA[*/
876 if (top.busy && top.busy.loginRefreshed) {
877 top.busy.loginRefreshed();
878 }
879 /*]]>*/
880 </script>':'');
881 }
882
883 /**
884 * Creates the bodyTag.
885 * You can add to the bodyTag by $this->bodyTagAdditions
886 *
887 * @return string HTML body tag
888 */
889 function docBodyTagBegin() {
890 $bodyContent = 'body onclick="if (top.menuReset) top.menuReset();" '.trim($this->bodyTagAdditions.($this->bodyTagId ? ' id="'.$this->bodyTagId.'"' : ''));
891 return '<'.trim($bodyContent).'>';
892 }
893
894 /**
895 * Outputting document style
896 *
897 * @return string HTML style section/link tags
898 */
899 function docStyle() {
900
901 // Request background image:
902 if ($this->backGroundImage) {
903 $this->inDocStylesArray[]=' BODY { background-image: url('.$this->backPath.$this->backGroundImage.'); }';
904 }
905
906 // Add inDoc styles variables as well:
907 $this->inDocStylesArray[] = $this->inDocStyles;
908 $this->inDocStylesArray[] = $this->inDocStyles_TBEstyle;
909
910 // Implode it all:
911 $inDocStyles = implode('
912 ',$this->inDocStylesArray);
913
914 // The default color scheme should also in full be represented in the stylesheet.
915 $style=trim('
916 '.($this->styleSheetFile?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile.'" />':'').'
917 '.($this->styleSheetFile2?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile2.'" />':'').'
918 <style type="text/css" id="internalStyle">
919 /*<![CDATA[*/
920 '.trim($inDocStyles).'
921 /*###POSTCSSMARKER###*/
922 /*]]>*/
923 </style>
924 '.($this->styleSheetFile_post?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile_post.'" />':'')
925 )
926 ;
927 $this->inDocStyles='';
928 $this->inDocStylesArray=array();
929
930 return '
931 '.$style;
932 }
933
934 /**
935 * Insert post rendering document style into already rendered content
936 * This is needed for extobjbase
937 *
938 * @param string style-content to insert.
939 * @return string content with inserted styles
940 */
941 function insertStylesAndJS($content) {
942 // insert accumulated CSS
943 $this->inDocStylesArray[] = $this->inDocStyles;
944 $styles = "\n".implode("\n", $this->inDocStylesArray);
945 $content = str_replace('/*###POSTCSSMARKER###*/',$styles,$content);
946
947 // insert accumulated JS
948 $jscode = $this->JScode."\n".$this->wrapScriptTags(implode("\n", $this->JScodeArray));
949 $content = str_replace('<!--###POSTJSMARKER###-->',$jscode,$content);
950
951 return $content;
952 }
953
954 /**
955 * Initialize the charset.
956 * Sets the internal $this->charset variable to the charset defined in $GLOBALS["LANG"] (or the default as set in this class)
957 * Returns the meta-tag for the document header
958 *
959 * @return string <meta> tag with charset from $this->charset or $GLOBALS['LANG']->charSet
960 */
961 function initCharset() {
962 // Set charset to the charset provided by the current backend users language selection:
963 $this->charset = $GLOBALS['LANG']->charSet ? $GLOBALS['LANG']->charSet : $this->charset;
964 // Return meta tag:
965 return '<meta http-equiv="Content-Type" content="text/html; charset='.$this->charset.'" />';
966 }
967
968 /**
969 * Returns generator meta tag
970 *
971 * @return string <meta> tag with name "generator"
972 */
973 function generator() {
974 $str = 'TYPO3 '.TYPO3_branch.', http://typo3.com, &#169; Kasper Sk&#229;rh&#248;j 1998-2006, extensions are copyright of their respective owners.';
975 return '<meta name="generator" content="'.$str .'" />';
976 }
977
978
979
980
981
982
983
984
985 /*****************************************
986 *
987 * OTHER ELEMENTS
988 * Tables, buttons, formatting dimmed/red strings
989 *
990 ******************************************/
991
992
993 /**
994 * Returns an image-tag with an 18x16 icon of the following types:
995 *
996 * $type:
997 * -1: OK icon (Check-mark)
998 * 1: Notice (Speach-bubble)
999 * 2: Warning (Yellow triangle)
1000 * 3: Fatal error (Red stop sign)
1001 *
1002 * @param integer See description
1003 * @param string Value for style attribute
1004 * @return string HTML image tag (if applicable)
1005 */
1006 function icons($type, $styleAttribValue='') {
1007 switch($type) {
1008 case '3':
1009 $icon = 'gfx/icon_fatalerror.gif';
1010 break;
1011 case '2':
1012 $icon = 'gfx/icon_warning.gif';
1013 break;
1014 case '1':
1015 $icon = 'gfx/icon_note.gif';
1016 break;
1017 case '-1':
1018 $icon = 'gfx/icon_ok.gif';
1019 break;
1020 default:
1021 break;
1022 }
1023 if ($icon) {
1024 return '<img'.t3lib_iconWorks::skinImg($this->backPath,$icon,'width="18" height="16"').' class="absmiddle"'.($styleAttribValue ? ' style="'.htmlspecialchars($styleAttribValue).'"' : '').' alt="" />';
1025 }
1026 }
1027
1028 /**
1029 * Returns an <input> button with the $onClick action and $label
1030 *
1031 * @param string The value of the onclick attribute of the input tag (submit type)
1032 * @param string The label for the button (which will be htmlspecialchar'ed)
1033 * @return string A <input> tag of the type "submit"
1034 */
1035 function t3Button($onClick,$label) {
1036 $button = '<input type="submit" onclick="'.htmlspecialchars($onClick).'; return false;" value="'.htmlspecialchars($label).'" />';
1037 return $button;
1038 }
1039
1040 /**
1041 * dimmed-fontwrap. Returns the string wrapped in a <span>-tag defining the color to be gray/dimmed
1042 *
1043 * @param string Input string
1044 * @return string Output string
1045 */
1046 function dfw($string) {
1047 return '<span class="typo3-dimmed">'.$string.'</span>';
1048 }
1049
1050 /**
1051 * red-fontwrap. Returns the string wrapped in a <span>-tag defining the color to be red
1052 *
1053 * @param string Input string
1054 * @return string Output string
1055 */
1056 function rfw($string) {
1057 return '<span class="typo3-red">'.$string.'</span>';
1058 }
1059
1060 /**
1061 * Returns string wrapped in CDATA "tags" for XML / XHTML (wrap content of <script> and <style> sections in those!)
1062 *
1063 * @param string Input string
1064 * @return string Output string
1065 */
1066 function wrapInCData($string) {
1067 $string = '/*<![CDATA[*/'.
1068 $string.
1069 '/*]]>*/';
1070
1071 return $string;
1072 }
1073
1074 /**
1075 * Wraps the input string in script tags.
1076 * Automatic re-identing of the JS code is done by using the first line as ident reference.
1077 * This is nice for identing JS code with PHP code on the same level.
1078 *
1079 * @param string Input string
1080 * @param boolean Wrap script element in linebreaks? Default is TRUE.
1081 * @return string Output string
1082 */
1083 function wrapScriptTags($string, $linebreak=TRUE) {
1084 if(trim($string)) {
1085 // <script wrapped in nl?
1086 $cr = $linebreak? "\n" : '';
1087
1088 // remove nl from the beginning
1089 $string = preg_replace ('/^\n+/', '', $string);
1090 // re-ident to one tab using the first line as reference
1091 $match = array();
1092 if(preg_match('/^(\t+)/',$string,$match)) {
1093 $string = str_replace($match[1],"\t", $string);
1094 }
1095 $string = $cr.'<script type="text/javascript">
1096 /*<![CDATA[*/
1097 '.$string.'
1098 /*]]>*/
1099 </script>'.$cr;
1100 }
1101 return trim($string);
1102 }
1103
1104 // These vars defines the layout for the table produced by the table() function.
1105 // You can override these values from outside if you like.
1106 var $tableLayout = Array (
1107 'defRow' => Array (
1108 'defCol' => Array('<td valign="top">','</td>')
1109 )
1110 );
1111 var $table_TR = '<tr>';
1112 var $table_TABLE = '<table border="0" cellspacing="0" cellpadding="0" id="typo3-tmpltable">';
1113
1114 /**
1115 * Returns a table based on the input $arr
1116 *
1117 * @param array Multidim array with first levels = rows, second levels = cells
1118 * @param array If set, then this provides an alternative layout array instead of $this->tableLayout
1119 * @return string The HTML table.
1120 * @internal
1121 */
1122 function table($arr, $layout='') {
1123 if (is_array($arr)) {
1124 $tableLayout = (is_array($layout)) ? $layout : $this->tableLayout;
1125
1126 reset($arr);
1127 $code='';
1128 $rc=0;
1129 while(list(,$val)=each($arr)) {
1130 if ($rc % 2) {
1131 $layout = is_array($tableLayout['defRowOdd']) ? $tableLayout['defRowOdd'] : $tableLayout['defRow'];
1132 } else {
1133 $layout = is_array($tableLayout['defRowEven']) ? $tableLayout['defRowEven'] : $tableLayout['defRow'];
1134 }
1135 $layoutRow = is_array($tableLayout[$rc]) ? $tableLayout[$rc] : $layout;
1136 $code_td='';
1137 if (is_array($val)) {
1138 $cc=0;
1139 while(list(,$content)=each($val)) {
1140 $wrap= is_array($layoutRow[$cc]) ? $layoutRow[$cc] : (is_array($layoutRow['defCol']) ? $layoutRow['defCol'] : (is_array($layout[$cc]) ? $layout[$cc] : $layout['defCol']));
1141 $code_td.=$wrap[0].$content.$wrap[1];
1142 $cc++;
1143 }
1144 }
1145 $trWrap = is_array($layoutRow['tr']) ? $layoutRow['tr'] : (is_array($layout['tr']) ? $layout['tr'] : array($this->table_TR, '</tr>'));
1146 $code.=$trWrap[0].$code_td.$trWrap[1];
1147 $rc++;
1148 }
1149 $tableWrap = is_array($tableLayout['table']) ? $tableLayout['table'] : array($this->table_TABLE, '</table>');
1150 $code=$tableWrap[0].$code.$tableWrap[1];
1151 }
1152 return $code;
1153 }
1154
1155 /**
1156 * Constructs a table with content from the $arr1, $arr2 and $arr3.
1157 * Used in eg. ext/belog/mod/index.php - refer to that for examples
1158 *
1159 * @param array Menu elements on first level
1160 * @param array Secondary items
1161 * @param array Third-level items
1162 * @return string HTML content, <table>...</table>
1163 */
1164 function menuTable($arr1,$arr2=array(), $arr3=array()) {
1165 $rows = max(array(count($arr1),count($arr2),count($arr3)));
1166
1167 $menu='
1168 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tablemenu">';
1169 for($a=0;$a<$rows;$a++) {
1170 $menu.='<tr>';
1171 $cls=array();
1172 $valign='middle';
1173 $cls[]='<td valign="'.$valign.'">'.$arr1[$a][0].'</td><td>'.$arr1[$a][1].'</td>';
1174 if (count($arr2)) {
1175 $cls[]='<td valign="'.$valign.'">'.$arr2[$a][0].'</td><td>'.$arr2[$a][1].'</td>';
1176 if (count($arr3)) {
1177 $cls[]='<td valign="'.$valign.'">'.$arr3[$a][0].'</td><td>'.$arr3[$a][1].'</td>';
1178 }
1179 }
1180 $menu.=implode($cls,'<td>&nbsp;&nbsp;</td>');
1181 $menu.='</tr>';
1182 }
1183 $menu.='
1184 </table>
1185 ';
1186 return $menu;
1187 }
1188
1189 /**
1190 * Returns a one-row/two-celled table with $content and $menu side by side.
1191 * The table is a 100% width table and each cell is aligned left / right
1192 *
1193 * @param string Content cell content (left)
1194 * @param string Menu cell content (right)
1195 * @return string HTML output
1196 */
1197 function funcMenu($content,$menu) {
1198 return '
1199 <table border="0" cellpadding="0" cellspacing="0" width="100%" id="typo3-funcmenu">
1200 <tr>
1201 <td valign="top" nowrap="nowrap">'.$content.'</td>
1202 <td valign="top" align="right" nowrap="nowrap">'.$menu.'</td>
1203 </tr>
1204 </table>';
1205 }
1206
1207 /**
1208 * Creates a selector box with clear-cache items.
1209 * Rather specialized functions - at least don't use it with $addSaveOptions unless you know what you do...
1210 *
1211 * @param integer The page uid of the "current page" - the one that will be cleared as "clear cache for this page".
1212 * @param boolean If $addSaveOptions is set, then also the array of save-options for TCE_FORMS will appear.
1213 * @return string <select> tag with content - a selector box for clearing the cache
1214 */
1215 function clearCacheMenu($id,$addSaveOptions=0) {
1216 global $BE_USER;
1217 $opt=array();
1218 if ($addSaveOptions) {
1219 $opt[]='<option value="">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.menu',1).'</option>';
1220 $opt[]='<option value="TBE_EDITOR.checkAndDoSubmit(1);">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc',1).'</option>';
1221 $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>';
1222 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>';
1223 $opt[]='<option value="document.editform.closeDoc.value=2; document.editform.submit();">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc',1).'</option>';
1224 $opt[]='<option value="document.editform.closeDoc.value=3; document.editform.submit();">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeAllDocs',1).'</option>';
1225 $opt[]='<option value=""></option>';
1226 }
1227 $opt[]='<option value="">[ '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_clearCache',1).' ]</option>';
1228 if ($id) $opt[]='<option value="'.$id.'">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_thisPage',1).'</option>';
1229 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>';
1230 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>';
1231
1232 $onChange = 'if (!this.options[this.selectedIndex].value) {
1233 this.selectedIndex=0;
1234 } else if (this.options[this.selectedIndex].value.indexOf(\';\')!=-1) {
1235 eval(this.options[this.selectedIndex].value);
1236 }else{
1237 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;
1238 }';
1239 $af_content = '<select name="cacheCmd" onchange="'.htmlspecialchars($onChange).'">'.implode('',$opt).'</select>';
1240
1241 if (count($opt)>1) {
1242 return $af_content;
1243 }
1244 }
1245
1246 /**
1247 * Returns an array with parts (JavaScript, init-functions, <div>-layers) for use on pages which displays the clickmenu layers (context sensitive menus)
1248 *
1249 * @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
1250 */
1251 function getContextMenuCode() {
1252 $content = '
1253 <script type="text/javascript">
1254 /*<![CDATA[*/
1255 // is called from most clickmenu links
1256 function showClickmenu(table, uid, listFr, enDisItems, backPath, addParams) {
1257 var url = "'.$this->backPath.'alt_clickmenu.php?table=" + encodeURIComponent(table)
1258 + "&uid=" + uid
1259 + "&listFr=" + listFr
1260 + "&enDisItems=" + enDisItems
1261 + "&backPath=" + backPath
1262 + "&addParams=" + addParams;
1263
1264 showClickmenu_raw(url);
1265 }
1266 // switch - either forwards call to ajax or does the request in the top frame
1267 function showClickmenu_raw(url) {';
1268 if ($this->isCMlayers()) { // AJAX
1269 $content.= '
1270 url += "&ajax=1";
1271 ajax_doRequest(url);';
1272 } else { // no AJAX
1273 $content.= '
1274 showClickmenu_noajax(url);';
1275 }
1276 $content.= '
1277 }
1278
1279 function showClickmenu_noajax(url) {
1280 top.loadTopMenu(url);
1281 }';
1282 if ($this->isCMlayers()) {
1283 $content.= t3lib_ajax::getJScode('showClickmenu_ajax', 'showClickmenu_noajax');
1284 $content.='
1285 // opens the clickmenu, is called from ajax_doRequest
1286 function showClickmenu_ajax(t3ajax) {
1287 if (t3ajax.getElementsByTagName("data")[0]) {
1288 var clickmenu = t3ajax.getElementsByTagName("data")[0].getElementsByTagName("clickmenu")[0];
1289 var tableData = clickmenu.getElementsByTagName("htmltable")[0].firstChild.data;
1290 var cmlevel = clickmenu.getElementsByTagName("cmlevel")[0].firstChild.data;
1291 setLayerObj(tableData,cmlevel);
1292 }
1293 }
1294
1295 var GLV_gap=10;
1296 var GLV_curLayerX=new Array(0,0);
1297 var GLV_curLayerY=new Array(0,0);
1298 var GLV_curLayerWidth=new Array(0,0);
1299 var GLV_curLayerHeight=new Array(0,0);
1300 var GLV_isVisible=new Array(0,0);
1301 var GLV_x=0;
1302 var GLV_y=0;
1303 var GLV_xRel=0;
1304 var GLV_yRel=0;
1305 var layerObj=new Array();
1306 var layerObjCss=new Array();
1307
1308 //browsercheck...
1309 function GL_checkBrowser(){ //
1310 this.dom= (document.getElementById);
1311 this.safari = (navigator.userAgent.indexOf("Safari")>-1);
1312 this.op= (navigator.userAgent.indexOf("Opera")>-1);
1313 this.op7= this.op && (navigator.appVersion.indexOf("7")>-1); // check for Opera version 7
1314 this.konq= (navigator.userAgent.indexOf("Konq")>-1);
1315 this.ie4= (document.all && !this.dom && !this.op && !this.konq);
1316 this.ie5= (document.all && this.dom && !this.op && !this.konq);
1317 this.ns4= (document.layers && !this.dom && !this.konq);
1318 this.ns5= (!document.all && this.dom && !this.op && !this.konq);
1319 this.ns6= (this.ns5);
1320 this.bw= (this.ie4 || this.ie5 || this.ns4 || this.ns6 || this.op || this.konq);
1321 return this;
1322 }
1323 bw= new GL_checkBrowser();
1324
1325 // GL_getObj(obj)
1326 function GL_getObj(obj){ //
1327 nest="";
1328 this.el= (bw.ie4||bw.op7)?document.all[obj]:bw.ns4?eval(nest+"document."+obj):document.getElementById(obj);
1329 this.css= bw.ns4?this.el:this.el.style;
1330 this.ref= bw.ns4?this.el.document:document;
1331 this.x= (bw.ns4||bw.op)?this.css.left:this.el.offsetLeft;
1332 this.y= (bw.ns4||bw.op)?this.css.top:this.el.offsetTop;
1333 this.height= (bw.ie4||bw.dom)?this.el.offsetHeight:bw.ns4?this.ref.height:0;
1334 this.width= (bw.ie4||bw.dom)?this.el.offsetWidth:bw.ns4?this.ref.width:0;
1335 return this;
1336 }
1337 // GL_getObjCss(obj)
1338 function GL_getObjCss(obj){ //
1339 return bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?document.layers[obj]:0;
1340 }
1341 // GL_getMouse(event)
1342 function GL_getMouse(event) { //
1343 if (layerObj) {
1344 // GLV_x= (bw.ns4||bw.ns5)?event.pageX:(bw.ie4||bw.op)?event.clientX:(event.clientX-2)+document.body.scrollLeft;
1345 // GLV_y= (bw.ns4||bw.ns5)?event.pageY:(bw.ie4||bw.op)?event.clientY:(event.clientY-2)+document.body.scrollTop;
1346 // 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:
1347
1348 GLV_xRel = event.clientX-2;
1349 GLV_yRel = event.clientY-2;
1350
1351 GLV_x = GLV_xRel;
1352 GLV_y = GLV_yRel;
1353
1354 GLV_x = GLV_xRel + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
1355 GLV_y = GLV_yRel + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
1356
1357 // status = (GLV_x+GLV_gap-GLV_curLayerX[0]) + " | " + (GLV_y+GLV_gap-GLV_curLayerY[0]);
1358 if (GLV_isVisible[1]) {
1359 if (outsideLayer(1)) hideSpecific(1);
1360 } else if (GLV_isVisible[0]) {
1361 if (outsideLayer(0)) hideSpecific(0);
1362 }
1363 }
1364 }
1365 // outsideLayer(level)
1366 function outsideLayer(level) { //
1367 return GLV_x+GLV_gap-GLV_curLayerX[level] <0 ||
1368 GLV_y+GLV_gap-GLV_curLayerY[level] <0 ||
1369 GLV_curLayerX[level]+GLV_curLayerWidth[level]+GLV_gap-GLV_x <0 ||
1370 GLV_curLayerY[level]+GLV_curLayerHeight[level]+GLV_gap-GLV_y <0;
1371 }
1372 // setLayerObj(html,level)
1373 function setLayerObj(html,level) { //
1374 var winHeight = document.documentElement.clientHeight && !bw.op7 ? document.documentElement.clientHeight : document.body.clientHeight;
1375 var winWidth = document.documentElement.clientWidth && !bw.op7 ? document.documentElement.clientWidth : document.body.clientWidth;
1376 var tempLayerObj = GL_getObj("contentMenu"+level);
1377 var tempLayerObjCss = GL_getObjCss("contentMenu"+level);
1378
1379 if (tempLayerObj && (level==0 || GLV_isVisible[level-1])) {
1380 tempLayerObj.el.innerHTML = html;
1381 tempLayerObj.width= (bw.ie4||bw.dom)?this.el.offsetWidth:bw.ns4?this.ref.width:0;
1382 tempLayerObj.height= (bw.ie4||bw.dom)?this.el.offsetHeight:bw.ns4?this.ref.height:0;
1383
1384 // konqueror (3.2.2) workaround
1385 winHeight = (bw.konq)?window.innerHeight:winHeight;
1386 winWidth = (bw.konq)?window.innerWidth:winWidth;
1387
1388 // Adjusting the Y-height of the layer to fit it into the window frame if it goes under the window frame in the bottom:
1389 if (winHeight-tempLayerObj.height < GLV_yRel) {
1390 if (GLV_yRel < tempLayerObj.height) {
1391 GLV_y+= (winHeight-tempLayerObj.height-GLV_yRel); // Setting it so bottom is just above window height.
1392 } else {
1393 GLV_y-= tempLayerObj.height-8; // Showing the menu upwards
1394 }
1395 }
1396 // Adjusting the X position like Y above
1397 if (winWidth-tempLayerObj.width < GLV_xRel) {
1398 if (GLV_xRel < tempLayerObj.width) {
1399 GLV_x+= (winWidth-tempLayerObj.width-GLV_xRel);
1400 } else {
1401 GLV_x-= tempLayerObj.width-8;
1402 }
1403 }
1404 GLV_x = Math.max(GLV_x,1);
1405 GLV_y = Math.max(GLV_y,1);
1406
1407 GLV_curLayerX[level] = GLV_x;
1408 GLV_curLayerY[level] = GLV_y;
1409 tempLayerObjCss.left = GLV_x+"px";
1410 tempLayerObjCss.top = GLV_y+"px";
1411 tempLayerObjCss.visibility = "visible";
1412 if (bw.ie5) showHideSelectorBoxes("hidden");
1413
1414 GLV_isVisible[level]=1;
1415 GLV_curLayerWidth[level] = tempLayerObj.width;
1416 GLV_curLayerHeight[level] = tempLayerObj.height;
1417 }
1418 }
1419 // hideEmpty()
1420 function hideEmpty() { //
1421 hideSpecific(0);
1422 hideSpecific(1);
1423 return false;
1424 }
1425 // hideSpecific(level)
1426 function hideSpecific(level) { //
1427 GL_getObjCss("contentMenu"+level).visibility = "hidden";
1428 GL_getObj("contentMenu"+level).el.innerHTML = "";
1429 GLV_isVisible[level]=0;
1430
1431 if (bw.ie5 && level==0) showHideSelectorBoxes("visible");
1432 }
1433 // debugObj(obj,name)
1434 function debugObj(obj,name) { //
1435 var acc;
1436 for (i in obj) {if (obj[i]) {acc+=i+": "+obj[i]+"\n";}}
1437 alert("Object: "+name+"\n\n"+acc);
1438 }
1439 // initLayer()
1440 function initLayer(){ //
1441 if (document.all) {
1442 window.onmousemove=GL_getMouse;
1443 }
1444 layerObj = GL_getObj("contentMenu1");
1445 layerObjCss = GL_getObjCss("contentMenu1");
1446 }
1447 function showHideSelectorBoxes(action) { // This function by Michiel van Leening
1448 for (i=0;i<document.forms.length;i++) {
1449 for (j=0;j<document.forms[i].elements.length;j++) {
1450 if(document.forms[i].elements[j].type=="select-one") {
1451 document.forms[i].elements[j].style.visibility=action;
1452 }
1453 }
1454 }
1455 }';
1456 $content.=' /*]]>*/
1457 </script>';
1458 return array(
1459 $content,
1460 ' onmousemove="GL_getMouse(event);" onload="initLayer();"',
1461 '<div id="contentMenu0" style="z-index:1; position:absolute;visibility:hidden"></div><div id="contentMenu1" style="z-index:2; position:absolute;visibility:hidden"></div>'
1462 );
1463 } else {
1464 $content.=' /*]]>*/
1465 </script>';
1466 return array($content,'','');
1467 }
1468 }
1469
1470 /**
1471 * Returns an array with parts (JavaScript, init-functions, <div>-layers) for use on pages which have the drag and drop functionality (usually pages and folder display trees)
1472 *
1473 * @param string indicator of which table the drag and drop function should work on (pages or folders)
1474 * @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
1475 */
1476 function getDragDropCode($table) {
1477 $content = '
1478 <script type="text/javascript">
1479 /*<![CDATA[*/
1480 ';
1481
1482 if ($this->isCMlayers()) {
1483 $content.= '
1484 var dragID = null;
1485 var dragIconCSS = null;
1486
1487 function cancelDragEvent(event) {
1488 dragID = null;
1489 dragIconCSS.visibility = "hidden";
1490 document.onmouseup = null;
1491 document.onmousemove = null;
1492 }
1493
1494 /**
1495 * [Describe function...]
1496 *
1497 * @param [type] $event: ...
1498 * @return [type] ...
1499 */
1500 function mouseMoveEvent (event) {
1501 dragIconCSS.left = GLV_x+5+"px";
1502 dragIconCSS.top = GLV_y-5+"px";
1503 dragIconCSS.visibility = "visible";
1504 return false;
1505 }
1506
1507 /**
1508 * [Describe function...]
1509 *
1510 * @param [type] $id,elementID: ...
1511 * @return [type] ...
1512 */
1513 function dragElement(id,elementID) {
1514 dragID = id;
1515 if (elementID == null) {
1516 elementID = id;
1517 }
1518 document.getElementById("dragIcon").innerHTML=document.getElementById("dragIconID_"+elementID).innerHTML + document.getElementById("dragTitleID_"+elementID).getElementsByTagName("a")[0].innerHTML;
1519 dragIconCSS = new GL_getObjCss("dragIcon");
1520 dragIconCSS.whiteSpace = "nowrap";
1521 document.onmouseup = cancelDragEvent;
1522 document.onmousemove = mouseMoveEvent;
1523 return false;
1524 }
1525
1526 /**
1527 * [Describe function...]
1528 *
1529 * @param [type] $id: ...
1530 * @return [type] ...
1531 */
1532 function dropElement(id) {
1533 if ((dragID != null) && (dragID != id)) {
1534 var url = "'.$this->backPath.'alt_clickmenu.php?dragDrop='.$table.'"
1535 + "&srcId=" + dragID
1536 + "&dstId=" + id
1537 + "&backPath='.t3lib_div::shortMD5(''.'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']).'";
1538 showClickmenu_raw(url);
1539 }
1540 cancelDragEvent();
1541 return false;
1542 }
1543 ';
1544 }
1545 else {
1546 $content.= '
1547 function dragElement(id) { return false; }
1548 function dropElement(id) { return false; }
1549 ';
1550 }
1551 $content.='
1552 /*]]>*/
1553 </script>';
1554
1555 if ($this->isCMlayers()) {
1556 return array(
1557 $content,
1558 '',
1559 '<div id="dragIcon" style="z-index:1;position:absolute;visibility:hidden;filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;"><img src="" width="18" height="16"></div>'
1560 );
1561 } else {
1562 return array($content,'','');
1563 }
1564 }
1565
1566 /**
1567 * Creates a tab menu from an array definition
1568 *
1569 * Returns a tab menu for a module
1570 * Requires the JS function jumpToUrl() to be available
1571 *
1572 * @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=...
1573 * @param string $elementName it the form elements name, probably something like "SET[...]"
1574 * @param string $currentValue is the value to be selected currently.
1575 * @param array $menuItems is an array with the menu items for the selector box
1576 * @param string $script is the script to send the &id to, if empty it's automatically found
1577 * @param string $addParams is additional parameters to pass to the script.
1578 * @return string HTML code for tab menu
1579 * @author Rene Fritz <r.fritz@colorcube.de>
1580 */
1581 function getTabMenu($mainParams,$elementName,$currentValue,$menuItems,$script='',$addparams='') {
1582 $content='';
1583
1584 if (is_array($menuItems)) {
1585 if (!is_array($mainParams)) {
1586 $mainParams = array('id' => $mainParams);
1587 }
1588 $mainParams = t3lib_div::implodeArrayForUrl('',$mainParams);
1589
1590 if (!$script) {$script=basename(PATH_thisScript);}
1591
1592 $menuDef = array();
1593 foreach($menuItems as $value => $label) {
1594 $menuDef[$value]['isActive'] = !strcmp($currentValue,$value);
1595 $menuDef[$value]['label'] = t3lib_div::deHSCentities(htmlspecialchars($label));
1596 $menuDef[$value]['url'] = htmlspecialchars($script.'?'.$mainParams.$addparams.'&'.$elementName.'='.$value);
1597 }
1598 $content = $this->getTabMenuRaw($menuDef);
1599
1600 }
1601 return $content;
1602 }
1603
1604 /**
1605 * Creates the HTML content for the tab menu
1606 *
1607 * @param array Menu items for tabs
1608 * @return string Table HTML
1609 * @access private
1610 */
1611 function getTabMenuRaw($menuItems) {
1612 $content='';
1613
1614 if (is_array($menuItems)) {
1615 $options='';
1616
1617 $count = count($menuItems);
1618 $widthLeft = 1;
1619 $addToAct = 5;
1620
1621 $widthRight = max (1,floor(30-pow($count,1.72)));
1622 $widthTabs = 100 - $widthRight - $widthLeft;
1623 $widthNo = floor(($widthTabs - $addToAct)/$count);
1624 $addToAct = max ($addToAct,$widthTabs-($widthNo*$count));
1625 $widthAct = $widthNo + $addToAct;
1626 $widthRight = 100 - ($widthLeft + ($count*$widthNo) + $addToAct);
1627
1628 $first=true;
1629 foreach($menuItems as $id => $def) {
1630 $isActive = $def['isActive'];
1631 $class = $isActive ? 'tabact' : 'tab';
1632 $width = $isActive ? $widthAct : $widthNo;
1633
1634 // @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.
1635 $label = $def['label'];
1636 $url = htmlspecialchars($def['url']);
1637 $params = $def['addParams'];
1638
1639 if($first) {
1640 $options.= '
1641 <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>';
1642 } else {
1643 $options.='
1644 <td width="'.$width.'%" class="'.$class.'"><a href="'.$url.'" '.$params.'>'.$label.'</a></td>';
1645 }
1646 $first=false;
1647 }
1648
1649 if ($options) {
1650 $content .= '
1651 <!-- Tab menu -->
1652 <table cellpadding="0" cellspacing="0" border="0" width="100%" id="typo3-tabmenu">
1653 <tr>
1654 <td width="'.$widthLeft.'%">&nbsp;</td>
1655 '.$options.'
1656 <td width="'.$widthRight.'%">&nbsp;</td>
1657 </tr>
1658 </table>
1659 <div class="hr" style="margin:0px"></div>';
1660 }
1661
1662 }
1663 return $content;
1664 }
1665
1666 /**
1667 * Creates a DYNAMIC tab-menu where the tabs are switched between with DHTML.
1668 * 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!
1669 *
1670 * @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.
1671 * @param string Identification string. This should be unique for every instance of a dynamic menu!
1672 * @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.
1673 * @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.
1674 * @param integer Character limit for a new row.
1675 * @param boolean If set, tab table cells are not allowed to wrap their content
1676 * @param boolean If set, the tabs will span the full width of their position
1677 * @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.
1678 * @return string JavaScript section for the HTML header.
1679 */
1680 function getDynTabMenu($menuItems,$identString,$toggle=0,$foldout=FALSE,$newRowCharLimit=50,$noWrap=1,$fullWidth=FALSE,$defaultTabIndex=1) {
1681 $content = '';
1682
1683 if (is_array($menuItems)) {
1684
1685 // Init:
1686 $options = array(array());
1687 $divs = array();
1688 $JSinit = array();
1689 $id = $this->getDynTabMenuId($identString);
1690 $noWrap = $noWrap ? ' nowrap="nowrap"' : '';
1691
1692 // Traverse menu items
1693 $c=0;
1694 $tabRows=0;
1695 $titleLenCount = 0;
1696 foreach($menuItems as $index => $def) {
1697 $index+=1; // Need to add one so checking for first index in JavaScript is different than if it is not set at all.
1698
1699 // Switch to next tab row if needed
1700 if (!$foldout && $titleLenCount>$newRowCharLimit) { // 50 characters is probably a reasonable count of characters before switching to next row of tabs.
1701 $titleLenCount=0;
1702 $tabRows++;
1703 $options[$tabRows] = array();
1704 }
1705
1706 if ($toggle==1) {
1707 $onclick = 'this.blur(); DTM_toggle("'.$id.'","'.$index.'"); return false;';
1708 } else {
1709 $onclick = 'this.blur(); DTM_activate("'.$id.'","'.$index.'", '.($toggle<0?1:0).'); return false;';
1710 }
1711
1712 $isActive = strcmp(trim($def['content']),'');
1713
1714 if ($isActive) {
1715
1716 $mouseOverOut = ' onmouseover="DTM_mouseOver(this);" onmouseout="DTM_mouseOut(this);"';
1717
1718 if (!$foldout) {
1719 // Create TAB cell:
1720 $options[$tabRows][] = '
1721 <td class="'.($isActive ? 'tab' : 'disabled').'" id="'.$id.'-'.$index.'-MENU"'.$noWrap.$mouseOverOut.'>'.
1722 ($isActive ? '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ? ' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>' : '').
1723 $def['icon'].
1724 ($def['label'] ? htmlspecialchars($def['label']) : '&nbsp;').
1725 $this->icons($def['stateIcon'],'margin-left: 10px;').
1726 ($isActive ? '</a>' :'').
1727 '</td>';
1728 $titleLenCount+= strlen($def['label']);
1729 } else {
1730 // Create DIV layer for content:
1731 $divs[] = '
1732 <div class="'.($isActive ? 'tab' : 'disabled').'" id="'.$id.'-'.$index.'-MENU"'.$mouseOverOut.'>'.
1733 ($isActive ? '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ? ' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>' : '').
1734 $def['icon'].
1735 ($def['label'] ? htmlspecialchars($def['label']) : '&nbsp;').
1736 ($isActive ? '</a>' : '').
1737 '</div>';
1738 }
1739
1740 // Create DIV layer for content:
1741 $divs[] = '
1742 <div style="display: none;" id="'.$id.'-'.$index.'-DIV" class="c-tablayer">'.
1743 ($def['description'] ? '<p class="c-descr">'.nl2br(htmlspecialchars($def['description'])).'</p>' : '').
1744 $def['content'].
1745 '</div>';
1746 // Create initialization string:
1747 $JSinit[] = '
1748 DTM_array["'.$id.'"]['.$c.'] = "'.$id.'-'.$index.'";
1749 ';
1750 if ($toggle==1) {
1751 $JSinit[] = '
1752 if (top.DTM_currentTabs["'.$id.'-'.$index.'"]) { DTM_toggle("'.$id.'","'.$index.'",1); }
1753 ';
1754 }
1755
1756 $c++;
1757 }
1758 }
1759
1760 // Render menu:
1761 if (count($options)) {
1762
1763 // Tab menu is compiled:
1764 if (!$foldout) {
1765 $tabContent = '';
1766 for($a=0;$a<=$tabRows;$a++) {
1767 $tabContent.= '
1768
1769 <!-- Tab menu -->
1770 <table cellpadding="0" cellspacing="0" border="0"'.($fullWidth ? ' width="100%"' : '').' class="typo3-dyntabmenu">
1771 <tr>
1772 '.implode('',$options[$a]).'
1773 </tr>
1774 </table>';
1775 }
1776 $content.= '<div class="typo3-dyntabmenu-tabs">'.$tabContent.'</div>';
1777 }
1778
1779 // Div layers are added:
1780 $content.= '
1781 <!-- Div layers for tab menu: -->
1782 <div class="typo3-dyntabmenu-divs'.($foldout?'-foldout':'').'">
1783 '.implode('',$divs).'</div>';
1784
1785 // Java Script section added:
1786 $content.= '
1787 <!-- Initialization JavaScript for the menu -->
1788 <script type="text/javascript">
1789 DTM_array["'.$id.'"] = new Array();
1790 '.implode('',$JSinit).'
1791 '.($toggle<=0 ? 'DTM_activate("'.$id.'", top.DTM_currentTabs["'.$id.'"]?top.DTM_currentTabs["'.$id.'"]:'.intval($defaultTabIndex).', 0);' : '').'
1792 </script>
1793
1794 ';
1795 }
1796
1797 }
1798 return $content;
1799 }
1800
1801 /**
1802 * Creates the id for dynTabMenus.
1803 *
1804 * @param string $identString: Identification string. This should be unique for every instance of a dynamic menu!
1805 * @return string The id with a short MD5 of $identString and prefixed "DTM-", like "DTM-2e8791854a"
1806 */
1807 function getDynTabMenuId($identString) {
1808 $id = 'DTM-'.t3lib_div::shortMD5($identString);
1809 return $id;
1810 }
1811
1812 /**
1813 * Returns dynamic tab menu header JS code.
1814 *
1815 * @return string JavaScript section for the HTML header.
1816 */
1817 function getDynTabMenuJScode() {
1818 return '
1819 <script type="text/javascript">
1820 /*<![CDATA[*/
1821 var DTM_array = new Array();
1822 var DTM_origClass = new String();
1823
1824 // if tabs are used in a popup window the array might not exists
1825 if(!top.DTM_currentTabs) {
1826 top.DTM_currentTabs = new Array();
1827 }
1828
1829 function DTM_activate(idBase,index,doToogle) { //
1830 // Hiding all:
1831 if (DTM_array[idBase]) {
1832 for(cnt = 0; cnt < DTM_array[idBase].length ; cnt++) {
1833 if (DTM_array[idBase][cnt] != idBase+"-"+index) {
1834 document.getElementById(DTM_array[idBase][cnt]+"-DIV").style.display = "none";
1835 document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
1836 }
1837 }
1838 }
1839
1840 // Showing one:
1841 if (document.getElementById(idBase+"-"+index+"-DIV")) {
1842 if (doToogle && document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
1843 document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
1844 if(DTM_origClass=="") {
1845 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
1846 } else {
1847 DTM_origClass = "tab";
1848 }
1849 top.DTM_currentTabs[idBase] = -1;
1850 } else {
1851 document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
1852 if(DTM_origClass=="") {
1853 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
1854 } else {
1855 DTM_origClass = "tabact";
1856 }
1857 top.DTM_currentTabs[idBase] = index;
1858 }
1859 }
1860 }
1861 function DTM_toggle(idBase,index,isInit) { //
1862 // Showing one:
1863 if (document.getElementById(idBase+"-"+index+"-DIV")) {
1864 if (document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
1865 document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
1866 if(isInit) {
1867 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
1868 } else {
1869 DTM_origClass = "tab";
1870 }
1871 top.DTM_currentTabs[idBase+"-"+index] = 0;
1872 } else {
1873 document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
1874 if(isInit) {
1875 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
1876 } else {
1877 DTM_origClass = "tabact";
1878 }
1879 top.DTM_currentTabs[idBase+"-"+index] = 1;
1880 }
1881 }
1882 }
1883
1884 function DTM_mouseOver(obj) { //
1885 DTM_origClass = obj.attributes.getNamedItem(\'class\').nodeValue;
1886 obj.attributes.getNamedItem(\'class\').nodeValue += "_over";
1887 }
1888
1889 function DTM_mouseOut(obj) { //
1890 obj.attributes.getNamedItem(\'class\').nodeValue = DTM_origClass;
1891 DTM_origClass = "";
1892 }
1893
1894
1895 /*]]>*/
1896 </script>
1897 ';
1898 }
1899
1900 /**
1901 * Creates the version selector for the page id inputted.
1902 * Requires the core version management extension, "version" to be loaded.
1903 *
1904 * @param integer Page id to create selector for.
1905 * @param boolean If set, there will be no button for swapping page.
1906 * @return void
1907 */
1908 function getVersionSelector($id,$noAction=FALSE) {
1909
1910 if ($id>0) {
1911 if (t3lib_extMgm::isLoaded('version') && $GLOBALS['BE_USER']->workspace==0) {
1912
1913 // Get Current page record:
1914 $curPage = t3lib_BEfunc::getRecord('pages',$id);
1915 // If the selected page is not online, find the right ID
1916 $onlineId = ($curPage['pid']==-1 ? $curPage['t3ver_oid'] : $id);
1917 // Select all versions of online version:
1918 $versions = t3lib_BEfunc::selectVersionsOfRecord('pages', $onlineId, 'uid,pid,t3ver_label,t3ver_oid,t3ver_wsid,t3ver_id');
1919
1920 // If more than one was found...:
1921 if (count($versions)>1) {
1922
1923 // Create selector box entries:
1924 $opt = array();
1925 foreach($versions as $vRow) {
1926 $opt[] = '<option value="'.htmlspecialchars(t3lib_div::linkThisScript(array('id'=>$vRow['uid']))).'"'.($id==$vRow['uid']?' selected="selected"':'').'>'.
1927 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').'<=':'')).
1928 '</option>';
1929 }
1930
1931 // Add management link:
1932 $opt[] = '<option value="'.htmlspecialchars(t3lib_div::linkThisScript(array('id'=>$id))).'">---</option>';
1933 $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>';
1934
1935 // Create onchange handler:
1936 $onChange = "window.location.href=this.options[this.selectedIndex].value;";
1937
1938 // Controls:
1939 if ($id==$onlineId) {
1940 $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>';
1941 } elseif (!$noAction) {
1942 $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">'.
1943 '<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).'" />'.
1944 '<b>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.swap',1).'</b></a>';
1945 }
1946
1947 // Write out HTML code:
1948 return '
1949
1950 <!--
1951 Version selector:
1952 -->
1953 <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
1954 <tr>
1955 <td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.selVer',1).'</td>
1956 <td>
1957 <select onchange="'.htmlspecialchars($onChange).'">
1958 '.implode('',$opt).'
1959 </select></td>
1960 <td>'.$controls.'</td>
1961 </tr>
1962 </table>
1963 ';
1964 }
1965 } elseif ($GLOBALS['BE_USER']->workspace!==0) {
1966
1967 // Write out HTML code:
1968 switch($GLOBALS['BE_USER']->workspace) {
1969 case 0:
1970 $wsTitle = 'LIVE';
1971 break;
1972 case -1:
1973 $wsTitle = 'Draft';
1974 break;
1975 default:
1976 $wsTitle = $GLOBALS['BE_USER']->workspaceRec['title'];
1977 break;
1978 }
1979
1980 if (t3lib_BEfunc::isPidInVersionizedBranch($id)=='branchpoint') {
1981 return '
1982
1983 <!--
1984 Version selector:
1985 -->
1986 <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
1987 <tr>
1988 <td>Workspace: "'.htmlspecialchars($wsTitle).'"</td>
1989 <td><em>Inside branch, no further versioning possible</em></td>
1990 </tr>
1991 </table>
1992 ';
1993 } else {
1994 // Get Current page record:
1995 $curPage = t3lib_BEfunc::getRecord('pages',$id);
1996 // If the selected page is not online, find the right ID
1997 $onlineId = ($curPage['pid']==-1 ? $curPage['t3ver_oid'] : $id);
1998 // The version of page:
1999 $verPage = t3lib_BEfunc::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, 'pages', $onlineId);
2000
2001 if (!$verPage) {
2002
2003 if (!count(t3lib_BEfunc::countVersionsOfRecordsOnPage($GLOBALS['BE_USER']->workspace, $onlineId))) {
2004 if ($GLOBALS['BE_USER']->workspaceVersioningTypeAccess(0)) {
2005
2006 $onClick = $this->issueCommand('&cmd[pages]['.$onlineId.'][version][action]=new&cmd[pages]['.$onlineId.'][version][treeLevels]=0',t3lib_div::linkThisScript(array('id'=>$onlineId)));
2007 $onClick = 'window.location.href=\''.$onClick.'\'; return false;';
2008 // Write out HTML code:
2009 return '
2010
2011 <!--
2012 No version yet, create one?
2013 -->
2014 <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
2015 <tr>
2016 <td>Workspace: "'.htmlspecialchars($wsTitle).'"</td>
2017 <td>
2018 <input type="submit" value="New version of page" name="_" onclick="'.htmlspecialchars($onClick).'" /></td>
2019 </tr>
2020 </table>
2021 ';
2022 }
2023 } else {
2024 return '
2025
2026 <!--
2027 Version selector:
2028 -->
2029 <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
2030 <tr>
2031 <td>Workspace: "'.htmlspecialchars($wsTitle).'"</td>
2032 <td><em>Versions found on page, no "Page" versioning possible</em></td>
2033 </tr>
2034 </table>
2035 ';
2036 }
2037 } elseif ($verPage['t3ver_swapmode']==0) {
2038 $onClick = $this->issueCommand('&cmd[pages]['.$onlineId.'][version][action]=swap&cmd[pages]['.$onlineId.'][version][swapWith]='.$verPage['uid'],t3lib_div::linkThisScript(array('id'=>$onlineId)));
2039 $onClick = 'window.location.href=\''.$onClick.'\'; return false;';
2040
2041 // Write out HTML code:
2042 return '
2043
2044 <!--
2045 Version selector:
2046 -->
2047 <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
2048 <tr>
2049 <td>Workspace: "'.htmlspecialchars($wsTitle).'"</td>
2050 <td>
2051 <input type="submit" value="Publish page" name="_" onclick="'.htmlspecialchars($onClick).'" /></td>
2052 </tr>
2053 </table>
2054 ';
2055 }
2056 }
2057 }
2058 }
2059 }
2060 }
2061
2062
2063
2064 // ******************************
2065 // Extension classes of the template class.
2066 // These are meant to provide backend screens with different widths.
2067 // They still do because of the different class-prefixes used for the <div>-sections
2068 // but obviously the final width is determined by the stylesheet used.
2069 // ******************************
2070
2071 /**
2072 * 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
2073 * The class were more significant in the past than today.
2074 *
2075 */
2076 class bigDoc extends template {
2077 var $divClass = 'typo3-bigDoc';
2078 }
2079
2080 /**
2081 * Extension class for "template" - used for backend pages without the "document" background image
2082 * The class were more significant in the past than today.
2083 *
2084 */
2085 class noDoc extends template {
2086 var $divClass = 'typo3-noDoc';
2087 }
2088
2089 /**
2090 * 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)
2091 * The class were more significant in the past than today.
2092 *
2093 */
2094 class smallDoc extends template {
2095 var $divClass = 'typo3-smallDoc';
2096 }
2097
2098 /**
2099 * 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.
2100 * The class were more significant in the past than today. But probably you should use this one for most modules you make.
2101 *
2102 */
2103 class mediumDoc extends template {
2104 var $divClass = 'typo3-mediumDoc';
2105 }
2106
2107
2108
2109 // Include extension to the template class?
2110 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/template.php']) {
2111 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/template.php']);
2112 }
2113
2114
2115
2116 // ******************************************************
2117 // The backend language engine is started (ext: "lang")
2118 // ******************************************************
2119 require_once(PATH_typo3.'sysext/lang/lang.php');
2120 $LANG = t3lib_div::makeInstance('language');
2121 $LANG->init($BE_USER->uc['lang']);
2122
2123
2124
2125 // ******************************
2126 // The template is loaded
2127 // ******************************
2128 $TBE_TEMPLATE = t3lib_div::makeInstance('template');
2129 ?>