2 /***************************************************************
5 * (c) 1999-2004 Kasper Skaarhoj (kasperYYYY@typo3.com)
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.
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.
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.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Contains class with layout/output function for TYPO3 Backend Scripts
31 * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj
32 * XHTML-trans compliant
34 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
37 * [CLASS/FUNCTION INDEX of SCRIPT]
39 * 137: function fw($str)
43 * 216: function template()
45 * SECTION: EVALUATION FUNCTIONS
46 * 290: function wrapClickMenuOnIcon($str,$table,$uid='',$listFr=1,$addParams='',$enDisItems='', $returnOnClick=FALSE)
47 * 307: function viewPageIcon($id,$backPath,$addParams='hspace="3"')
48 * 333: function issueCommand($params,$rUrl='')
49 * 348: function isCMlayers()
50 * 358: function thisBlur()
51 * 368: function helpStyle()
52 * 385: function getHeader($table,$row,$path,$noViewPageIcon=0,$tWrap=array('',''))
53 * 411: function getFileheader($title,$path,$iconfile)
54 * 426: function makeShortcutIcon($gvList,$setList,$modName,$motherModName="")
55 * 459: function makeShortcutUrl($gvList,$setList)
56 * 480: function formWidth($size=48,$textarea=0,$styleOverride='')
57 * 505: function formWidthText($size=48,$styleOverride='',$wrap='')
58 * 522: function redirectUrls($thisLocation='')
59 * 546: function formatTime($tstamp,$type)
60 * 559: function parseTime()
62 * SECTION: PAGE BUILDING FUNCTIONS.
63 * 592: function startPage($title)
64 * 667: function endPage()
65 * 696: function header($text)
66 * 717: function section($label,$text,$nostrtoupper=FALSE,$sH=FALSE,$type=0,$allowHTMLinHeader=FALSE)
67 * 741: function divider($dist)
68 * 757: function spacer($dist)
69 * 776: function sectionHeader($label,$sH=FALSE,$addAttrib='')
70 * 793: function sectionBegin()
71 * 814: function sectionEnd()
72 * 834: function middle()
73 * 843: function endPageJS()
74 * 860: function docBodyTagBegin()
75 * 870: function docStyle()
76 * 912: function insertStylesAndJS($content)
77 * 932: function initCharset()
78 * 944: function generator()
80 * SECTION: OTHER ELEMENTS
81 * 977: function icons($type, $styleAttribValue='')
82 * 1006: function t3Button($onClick,$label)
83 * 1017: function dfw($string)
84 * 1027: function rfw($string)
85 * 1037: function wrapInCData($string)
86 * 1054: function wrapScriptTags($string, $linebreak=TRUE)
87 * 1092: function table($arr, $layout='')
88 * 1134: function menuTable($arr1,$arr2=array(), $arr3=array())
89 * 1167: function funcMenu($content,$menu)
90 * 1185: function clearCacheMenu($id,$addSaveOptions=0)
91 * 1221: function getContextMenuCode()
92 * 1408: function getTabMenu($mainParams,$elementName,$currentValue,$menuItems,$script='',$addparams='')
93 * 1438: function getTabMenuRaw($menuItems)
94 * 1507: function getDynTabMenu($menuItems,$identString,$toggle=0,$foldout=FALSE,$newRowCharLimit=50,$noWrap=1,$fullWidth=FALSE,$defaultTabIndex=1)
95 * 1630: function getDynTabMenuJScode()
96 * 1687: function getVersionSelector($id,$noAction=FALSE)
99 * 1761: class bigDoc extends template
102 * 1770: class noDoc extends template
105 * 1779: class smallDoc extends template
108 * 1788: class mediumDoc extends template
110 * TOTAL FUNCTIONS: 49
111 * (This index is automatically created/updated by the extension "extdeveval")
117 if (!defined('TYPO3_MODE')) die("Can't include this file directly.");
131 * Depreciated fontwrap function. Is just transparent now.
133 * @param string Input string
134 * @return string Output string (in the old days this was wrapped in <font> tags)
143 * TYPO3 Backend Template Class
145 * This class contains functions for starting and ending the HTML of backend modules
146 * It also contains methods for outputting sections of content.
147 * Further there are functions for making icons, links, setting form-field widths etc.
148 * Color scheme and stylesheet definitions are also available here.
149 * Finally this file includes the language class for TYPO3's backend.
151 * After this file $LANG and $TBE_TEMPLATE are global variables / instances of their respective classes.
152 * This file is typically included right after the init.php file,
153 * if language and layout is needed.
155 * Please refer to Inside TYPO3 for a discussion of how to use this API.
157 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
163 // Vars you typically might want to/should set from outside after making instance of this class:
164 var $backPath = ''; // 'backPath' pointing back to the PATH_typo3
165 var $form=''; // This can be set to the HTML-code for a formtag. Useful when you need a form to span the whole page; Inserted exactly after the body-tag.
166 var $JScode=''; // Additional header code (eg. a JavaScript section) could be accommulated in this var. It will be directly outputted in the header.
167 var $JScodeArray = array(); // Similar to $JScode but for use as array with associative keys to prevent double inclusion of JS code. a <script> tag is automatically wrapped around.
168 var $postCode=''; // Additional 'page-end' code could be accommulated in this var. It will be outputted at the end of page before </body> and some other internal page-end code.
169 var $docType = ''; // Doc-type used in the header. Default is HTML 4. You can also set it to 'strict', 'xhtml_trans', or 'xhtml_frames'.
171 // Other vars you can change, but less frequently used:
172 var $scriptID=''; // Script ID.
173 var $bodyTagId=''; // Id which can be set for the body tag. Default value is based on script ID
174 var $bodyTagAdditions=''; // You can add additional attributes to the body-tag through this variable.
175 var $inDocStyles=''; // Additional CSS styles which will be added to the <style> section in the header
176 var $inDocStylesArray=array(); // Like $inDocStyles but for use as array with associative keys to prevent double inclusion of css code
177 var $form_rowsToStylewidth = 9.58; // Multiplication factor for formWidth() input size (default is 48* this value).
178 var $form_largeComp = 1.33; // Compensation for large documents (used in class.t3lib_tceforms.php)
179 var $endJS=1; // If set, then a JavaScript section will be outputted in the bottom of page which will try and update the top.busy session expiry object.
181 // TYPO3 Colorscheme.
182 // If you want to change this, please do so through a skin using the global var $TBE_STYLES
183 var $bgColor = '#F7F3EF'; // Light background color
184 var $bgColor2 = '#9BA1A8'; // Steel-blue
185 var $bgColor3 = '#F6F2E6'; // dok.color
186 var $bgColor4 = '#D9D5C9'; // light tablerow background, brownish
187 var $bgColor5 = '#ABBBB4'; // light tablerow background, greenish
188 var $bgColor6 = '#E7DBA8'; // light tablerow background, yellowish, for section headers. Light.
189 var $hoverColor = '#254D7B';
190 var $styleSheetFile = 'stylesheet.css'; // Filename of stylesheet (relative to PATH_typo3)
191 var $styleSheetFile2 = ''; // Filename of stylesheet #2 - linked to right after the $this->styleSheetFile script (relative to PATH_typo3)
192 var $styleSheetFile_post = ''; // Filename of a post-stylesheet - included right after all inline styles.
193 var $backGroundImage = ''; // Background image of page (relative to PATH_typo3)
194 var $inDocStyles_TBEstyle = ''; // Inline css styling set from TBE_STYLES array
197 var $parseTimeFlag = 0; // Will output the parsetime of the scripts in milliseconds (for admin-users). Set this to false when releasing TYPO3. Only for dev.
200 var $charset = 'iso-8859-1'; // Default charset. see function initCharset()
202 var $sectionFlag=0; // Internal: Indicates if a <div>-output section is open
203 var $divClass = ''; // (Default) Class for wrapping <DIV>-tag of page. Is set in class extensions.
212 * Imports relevant parts from global $TBE_STYLES (colorscheme)
216 function template() {
219 // Setting default scriptID:
220 $this->scriptID
= ereg_replace('^.*\/(sysext|ext)\/','ext/',substr(PATH_thisScript
,strlen(PATH_site
)));
221 if (TYPO3_mainDir
!='typo3/' && substr($this->scriptID
,0,strlen(TYPO3_mainDir
)) == TYPO3_mainDir
) {
222 $this->scriptID
= 'typo3/'.substr($this->scriptID
,strlen(TYPO3_mainDir
)); // This fixes if TYPO3_mainDir has been changed so the script ids are STILL "typo3/..."
225 $this->bodyTagId
= ereg_replace('[^[:alnum:]-]','-',$this->scriptID
);
227 // Individual configuration per script? If so, make a recursive merge of the arrays:
228 if (is_array($TBE_STYLES['scriptIDindex'][$this->scriptID
])) {
229 $ovr = $TBE_STYLES['scriptIDindex'][$this->scriptID
]; // Make copy
230 $TBE_STYLES = t3lib_div
::array_merge_recursive_overrule($TBE_STYLES,$ovr); // merge styles.
231 unset($TBE_STYLES['scriptIDindex'][$this->scriptID
]); // Have to unset - otherwise the second instantiation will do it again!
235 if ($TBE_STYLES['mainColors']['bgColor']) $this->bgColor
=$TBE_STYLES['mainColors']['bgColor'];
236 if ($TBE_STYLES['mainColors']['bgColor1']) $this->bgColor1
=$TBE_STYLES['mainColors']['bgColor1'];
237 if ($TBE_STYLES['mainColors']['bgColor2']) $this->bgColor2
=$TBE_STYLES['mainColors']['bgColor2'];
238 if ($TBE_STYLES['mainColors']['bgColor3']) $this->bgColor3
=$TBE_STYLES['mainColors']['bgColor3'];
239 if ($TBE_STYLES['mainColors']['bgColor4']) $this->bgColor4
=$TBE_STYLES['mainColors']['bgColor4'];
240 if ($TBE_STYLES['mainColors']['bgColor5']) $this->bgColor5
=$TBE_STYLES['mainColors']['bgColor5'];
241 if ($TBE_STYLES['mainColors']['bgColor6']) $this->bgColor6
=$TBE_STYLES['mainColors']['bgColor6'];
242 if ($TBE_STYLES['mainColors']['hoverColor']) $this->hoverColor
=$TBE_STYLES['mainColors']['hoverColor'];
245 if ($TBE_STYLES['stylesheet']) $this->styleSheetFile
= $TBE_STYLES['stylesheet'];
246 if ($TBE_STYLES['stylesheet2']) $this->styleSheetFile2
= $TBE_STYLES['stylesheet2'];
247 if ($TBE_STYLES['styleSheetFile_post']) $this->styleSheetFile_post
= $TBE_STYLES['styleSheetFile_post'];
248 if ($TBE_STYLES['inDocStyles_TBEstyle']) $this->inDocStyles_TBEstyle
= $TBE_STYLES['inDocStyles_TBEstyle'];
251 if ($TBE_STYLES['background']) $this->backGroundImage
= $TBE_STYLES['background'];
269 /*****************************************
271 * EVALUATION FUNCTIONS
272 * Various centralized processing
274 *****************************************/
277 * Makes click menu link (context sensitive menu)
278 * Returns $str (possibly an <|img> tag/icon) wrapped in a link which will activate the context sensitive menu for the record ($table/$uid) or file ($table = file)
279 * The link will load the top frame with the parameter "&item" which is the table,uid and listFr arguments imploded by "|": rawurlencode($table.'|'.$uid.'|'.$listFr)
281 * @param string String to be wrapped in link, typ. image tag.
282 * @param string Table name/File path. If the icon is for a database record, enter the tablename from $TCA. If a file then enter the absolute filepath
283 * @param integer If icon is for database record this is the UID for the record from $table
284 * @param boolean Tells the top frame script that the link is coming from a "list" frame which means a frame from within the backend content frame.
285 * @param string Additional GET parameters for the link to alt_clickmenu.php
286 * @param string Enable / Disable click menu items. Example: "+new,view" will display ONLY these two items (and any spacers in between), "new,view" will display all BUT these two items.
287 * @param boolean If set, will return only the onclick JavaScript, not the whole link.
288 * @return string The link-wrapped input string.
290 function wrapClickMenuOnIcon($str,$table,$uid='',$listFr=1,$addParams='',$enDisItems='', $returnOnClick=FALSE) {
291 $backPath = '&backPath='.rawurlencode($this->backPath
).'|'.t3lib_div
::shortMD5($this->backPath
.'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']);
292 $onClick = 'top.loadTopMenu(\''.$this->backPath
.'alt_clickmenu.php?item='.rawurlencode($table.'|'.$uid.'|'.$listFr.'|'.$enDisItems).$backPath.$addParams.'\');'.$this->thisBlur().'return false;';
293 return $returnOnClick ?
$onClick : '<a href="#" onclick="'.htmlspecialchars($onClick).'"'.($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler'] ?
' oncontextmenu="'.htmlspecialchars($onClick).'"' : '').'>'.$str.'</a>';
297 * Makes link to page $id in frontend (view page)
298 * Returns an magnifier-glass icon which links to the frontend index.php document for viewing the page with id $id
299 * $id must be a page-uid
300 * If the BE_USER has access to Web>List then a link to that module is shown as well (with return-url)
302 * @param integer The page id
303 * @param string The current "BACK_PATH" (the back relative to the typo3/ directory)
304 * @param string Additional parameters for the image tag(s)
305 * @return string HTML string with linked icon(s)
307 function viewPageIcon($id,$backPath,$addParams='hspace="3"') {
310 // If access to Web>List for user, then link to that module.
311 if ($BE_USER->check('modules','web_list')) {
312 $href=$backPath.'db_list.php?id='.$id.'&returnUrl='.rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI'));
313 $str.= '<a href="'.htmlspecialchars($href).'">'.
314 '<img'.t3lib_iconWorks
::skinImg($backPath,'gfx/list.gif','width="11" height="11"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showList',1).'"'.($addParams?
' '.trim($addParams):'').' alt="" />'.
317 // Make link to view page
318 $str.= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc
::viewOnClick($id,$backPath,t3lib_BEfunc
::BEgetRootLine($id))).'">'.
319 '<img'.t3lib_iconWorks
::skinImg($backPath,'gfx/zoom.gif','width="12" height="12"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPage',1).'"'.($addParams?
' '.trim($addParams):"").' hspace="3" alt="" />'.
325 * Returns a URL with a command to TYPO3 Core Engine (tce_db.php)
326 * See description of the API elsewhere.
328 * @param string $params is a set of GET params to send to tce_db.php. Example: "&cmd[tt_content][123][move]=456" or "&data[tt_content][123][hidden]=1&data[tt_content][123][title]=Hello%20World"
329 * @param string Redirect URL if any other that t3lib_div::getIndpEnv('REQUEST_URI') is wished
330 * @return string URL to tce_db.php + parameters (backpath is taken from $this->backPath)
331 * @see t3lib_BEfunc::editOnClick()
333 function issueCommand($params,$rUrl='') {
334 $rUrl = $rUrl ?
$rUrl : t3lib_div
::getIndpEnv('REQUEST_URI');
335 return $this->backPath
.'tce_db.php?'.
337 '&redirect='.($rUrl==-1?
"'+T3_THIS_LOCATION+'":rawurlencode($rUrl)).
338 '&vC='.rawurlencode($GLOBALS['BE_USER']->veriCode()).
343 * Returns true if click-menu layers can be displayed for the current user/browser
344 * Use this to test if click-menus (context sensitive menus) can and should be displayed in the backend.
348 function isCMlayers() {
349 return !$GLOBALS['BE_USER']->uc
['disableCMlayers'] && $GLOBALS['CLIENT']['FORMSTYLE'] && !($GLOBALS['CLIENT']['SYSTEM']=='mac' && $GLOBALS['CLIENT']['BROWSER']=='Opera');
353 * Returns 'this.blur();' if the client supports CSS styles
354 * Use this in links to remove the underlining after being clicked
358 function thisBlur() {
359 return ($GLOBALS['CLIENT']['FORMSTYLE']?
'this.blur();':'');
363 * Returns ' style='cursor:help;'' if the client supports CSS styles
364 * Use for <a>-links to help texts
368 function helpStyle() {
369 return $GLOBALS['CLIENT']['FORMSTYLE'] ?
' style="cursor:help;"':'';
373 * Makes the header (icon+title) for a page (or other record). Used in most modules under Web>*
374 * $table and $row must be a tablename/record from that table
375 * $path will be shown as alt-text for the icon.
376 * The title will be truncated to 45 chars.
378 * @param string Table name
379 * @param array Record row
380 * @param string Alt text
381 * @param boolean Set $noViewPageIcon true if you don't want a magnifier-icon for viewing the page in the frontend
382 * @param array $tWrap is an array with indexes 0 and 1 each representing HTML-tags (start/end) which will wrap the title
383 * @return string HTML content
385 function getHeader($table,$row,$path,$noViewPageIcon=0,$tWrap=array('','')) {
387 if (is_array($row) && $row['uid']) {
388 $iconImgTag=t3lib_iconWorks
::getIconImage($table,$row,$this->backPath
,'title="'.htmlspecialchars($path).'"');
389 $title= strip_tags($row[$TCA[$table]['ctrl']['label']]);
390 $viewPage = $noViewPageIcon ?
'' : $this->viewPageIcon($row['uid'],$this->backPath
,'');
391 if ($table=='pages') $path.=' - '.t3lib_BEfunc
::titleAttribForPages($row,'',0);
393 $iconImgTag='<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/i/_icon_website.gif',$wHattribs='width="18" height="16"').' title="'.htmlspecialchars($path).'" alt="" />';
394 $title=$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
397 return '<span class="typo3-moduleHeader">'.$this->wrapClickMenuOnIcon($iconImgTag,$table,$row['uid']).
399 $tWrap[0].htmlspecialchars(t3lib_div
::fixed_lgd_cs($title,45)).$tWrap[1].'</span>';
403 * Like ->getHeader() but for files in the File>* main module/submodules
404 * Returns the file-icon with the path of the file set in the alt/title attribute. Shows the file-name after the icon.
406 * @param string Title string, expected to be the filepath
407 * @param string Alt text
408 * @param string The icon file (relative to TYPO3 dir)
409 * @return string HTML content
411 function getFileheader($title,$path,$iconfile) {
412 $fileInfo = t3lib_div
::split_fileref($title);
413 $title = htmlspecialchars(t3lib_div
::fixed_lgd_cs($fileInfo['path'],-35)).'<b>'.htmlspecialchars($fileInfo['file']).'</b>';
414 return '<span class="typo3-moduleHeader"><img'.t3lib_iconWorks
::skinImg($this->backPath
,$iconfile,'width="18" height="16"').' title="'.htmlspecialchars($path).'" alt="" />'.$title.'</span>';
418 * Returns a linked shortcut-icon which will call the shortcut frame and set a shortcut there back to the calling page/module
420 * @param string Is the list of GET variables to store (if any)
421 * @param string Is the list of SET[] variables to store (if any) - SET[] variables a stored in $GLOBALS["SOBE"]->MOD_SETTINGS for backend modules
422 * @param string Module name string
423 * @param string Is used to enter the "parent module name" if the module is a submodule under eg. Web>* or File>*. You can also set this value to "1" in which case the currentLoadedModule is sent to the shortcut script (so - not a fixed value!) - that is used in file_edit.php and wizard_rte.php scripts where those scripts are really running as a part of another module.
424 * @return string HTML content
426 function makeShortcutIcon($gvList,$setList,$modName,$motherModName="") {
427 $backPath=$this->backPath
;
428 $storeUrl=$this->makeShortcutUrl($gvList,$setList);
429 $pathInfo = parse_url(t3lib_div
::getIndpEnv('REQUEST_URI'));
431 if (!strcmp($motherModName,'1')) {
432 $mMN="&motherModName='+top.currentModuleLoaded+'";
433 } elseif ($motherModName) {
434 $mMN='&motherModName='.rawurlencode($motherModName);
437 $onClick = 'if (top.shortcutFrame && confirm('.
438 $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.makeShortcut')).
439 ')){top.shortcutFrame.document.location=\''.$backPath.'alt_shortcut.php?modName='.rawurlencode($modName).
440 '&URL='.rawurlencode($pathInfo['path']."?".$storeUrl).
444 $sIcon = '<a href="#" onclick="'.htmlspecialchars($onClick).'">
445 <img'.t3lib_iconWorks
::skinImg($backPath,'gfx/shortcut.gif','width="14" height="14"').' title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.makeShortcut',1).'" alt="" /></a>';
450 * MAKE url for storing
453 * @param string Is the list of GET variables to store (if any)
454 * @param string Is the list of SET[] variables to store (if any) - SET[] variables a stored in $GLOBALS["SOBE"]->MOD_SETTINGS for backend modules
457 * @see makeShortcutIcon()
459 function makeShortcutUrl($gvList,$setList) {
460 $GET = t3lib_div
::_GET();
461 $storeArray = array_merge(
462 t3lib_div
::compileSelectedGetVarsFromArray($gvList,$GET),
463 array('SET'=>t3lib_div
::compileSelectedGetVarsFromArray($setList,$GLOBALS['SOBE']->MOD_SETTINGS
))
465 $storeUrl = t3lib_div
::implodeArrayForUrl('',$storeArray);
470 * Returns <input> attributes to set the width of an text-type input field.
471 * For client browsers with no CSS support the cols/size attribute is returned.
472 * For CSS compliant browsers (recommended) a ' style="width: ...px;"' is returned.
474 * @param integer A relative number which multiplied with approx. 10 will lead to the width in pixels
475 * @param boolean A flag you can set for textareas - DEPRECIATED, use ->formWidthText() for textareas!!!
476 * @param string A string which will be returned as attribute-value for style="" instead of the calculated width (if CSS is enabled)
477 * @return string Tag attributes for an <input> tag (regarding width)
478 * @see formWidthText()
480 function formWidth($size=48,$textarea=0,$styleOverride='') {
481 $wAttrib = $textarea?
'cols':'size';
482 if (!$GLOBALS['CLIENT']['FORMSTYLE']) { // If not setting the width by style-attribute
484 $retVal = ' '.$wAttrib.'="'.$size.'"';
485 } else { // Setting width by style-attribute. 'cols' MUST be avoided with NN6+
486 $pixels = ceil($size*$this->form_rowsToStylewidth
);
487 $retVal = $styleOverride ?
' style="'.$styleOverride.'"' : ' style="width:'.$pixels.'px;"';
493 * This function is dedicated to textareas, which has the wrapping on/off option to observe.
495 * <textarea rows="10" wrap="off" '.$GLOBALS["TBE_TEMPLATE"]->formWidthText(48,"","off").'>
497 * <textarea rows="10" wrap="virtual" '.$GLOBALS["TBE_TEMPLATE"]->formWidthText(48,"","virtual").'>
499 * @param integer A relative number which multiplied with approx. 10 will lead to the width in pixels
500 * @param string A string which will be returned as attribute-value for style="" instead of the calculated width (if CSS is enabled)
501 * @param string Pass on the wrap-attribute value you use in your <textarea>! This will be used to make sure that some browsers will detect wrapping alright.
502 * @return string Tag attributes for an <input> tag (regarding width)
505 function formWidthText($size=48,$styleOverride='',$wrap='') {
506 $wTags = $this->formWidth($size,1,$styleOverride);
507 // Netscape 6+/Mozilla seems to have this ODD problem where there WILL ALWAYS be wrapping with the cols-attribute set and NEVER without the col-attribute...
508 if (strtolower(trim($wrap))!='off' && $GLOBALS['CLIENT']['BROWSER']=='net' && $GLOBALS['CLIENT']['VERSION']>=5) {
509 $wTags.=' cols="'.$size.'"';
515 * Returns JavaScript variables setting the returnUrl and thisScript location for use by JavaScript on the page.
516 * Used in fx. db_list.php (Web>List)
518 * @param string URL to "this location" / current script
520 * @see typo3/db_list.php
522 function redirectUrls($thisLocation='') {
523 $thisLocation = $thisLocation?
$thisLocation:t3lib_div
::linkThisScript(
532 var T3_RETURN_URL = '".str_replace('%20','',rawurlencode(t3lib_div
::_GP('returnUrl')))."';
533 var T3_THIS_LOCATION = '".str_replace('%20','',rawurlencode($thisLocation))."';
539 * Returns a formatted string of $tstamp
540 * Uses $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] and $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] to format date and time
542 * @param integer UNIX timestamp, seconds since 1970
543 * @param integer How much data to show: $type = 1: hhmm, $type = 10: ddmmmyy
544 * @return string Formatted timestamp
546 function formatTime($tstamp,$type) {
548 case 1: return date($GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'],$tstamp); break;
549 case 10: return date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'],$tstamp); break;
554 * Returns script parsetime IF ->parseTimeFlag is set and user is "admin"
555 * Automatically outputted in page end
559 function parseTime() {
560 if ($this->parseTimeFlag
&& $GLOBALS['BE_USER']->isAdmin()) {
561 return '<p>(ParseTime: '.(t3lib_div
::milliseconds()-$GLOBALS['PARSETIME_START']).' ms</p>
562 <p>REQUEST_URI-length: '.strlen(t3lib_div
::getIndpEnv('REQUEST_URI')).')</p>';
577 /*****************************************
579 * PAGE BUILDING FUNCTIONS.
580 * Use this to build the HTML of your backend modules
582 *****************************************/
586 * This includes the proper header with charset, title, meta tag and beginning body-tag.
588 * @param string HTML Page title for the header
589 * @return string Returns the whole header section of a HTML-document based on settings in internal variables (like styles, javascript code, charset, generator and docType)
592 function startPage($title) {
593 // Get META tag containing the currently selected charset for backend output. The function sets $this->charSet.
594 $charSet = $this->initCharset();
595 $generator = $this->generator();
597 // For debugging: If this outputs "QuirksMode"/"BackCompat" (IE) the browser runs in quirks-mode. Otherwise the value is "CSS1Compat"
598 # $this->JScodeArray[]='alert(document.compatMode);';
600 // Send HTTP header for selected charset. Added by Robert Lemke 23.10.2003
601 header ('Content-Type:text/html;charset='.$this->charset
);
603 switch($this->docType
) {
605 $headerStart= '<!DOCTYPE html
606 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
607 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
608 <?xml version="1.0" encoding="'.$this->charset
.'"?>
609 <?xml-stylesheet href="#internalStyle" type="text/css"?>
613 $headerStart= '<!DOCTYPE html
614 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
615 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
616 <?xml version="1.0" encoding="'.$this->charset
.'"?>
617 <?xml-stylesheet href="#internalStyle" type="text/css"?>
621 $headerStart= '<!DOCTYPE html
622 PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
623 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
624 <?xml version="1.0" encoding="'.$this->charset
.'"?>
628 $headerStart='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">';
632 // Construct page header.
633 $str = $headerStart.'
636 <!-- TYPO3 Script ID: '.htmlspecialchars($this->scriptID
).' -->
639 <title>'.htmlspecialchars($title).'</title>
640 '.$this->docStyle().'
642 '.$this->wrapScriptTags(implode("\n", $this->JScodeArray
)).'
643 <!--###POSTJSMARKER###-->
647 $this->JScodeArray
=array();
649 if ($this->docType
=='xhtml_frames') {
652 $str.=$this->docBodyTagBegin().
655 <!-- Wrapping DIV-section for whole page BEGIN -->
656 <div class="'.$this->divClass
.'">
657 ':'').trim($this->form
);
662 * Returns page end; This includes finishing form, div, body and html tags.
664 * @return string The HTML end of a page
668 $str = $this->sectionEnd().
671 t3lib_BEfunc
::getSetUpdateSignal().
677 <!-- Wrapping DIV-section for whole page END -->
683 // Logging: Can't find better place to put it:
684 if (TYPO3_DLOG
) t3lib_div
::devLog('END of BACKEND session','',0,array('_FLUSH'=>TRUE));
690 * Returns the header-bar in the top of most backend modules
691 * Closes section if open.
693 * @param string The text string for the header
694 * @return string HTML content
696 function header($text) {
699 <!-- MAIN Header in page top -->
700 <h2>'.htmlspecialchars($text).'</h2>
702 return $this->sectionEnd().$str;
706 * Begins an output section and sets header and content
708 * @param string The header
709 * @param string The HTML-content
710 * @param boolean A flag that will prevent the header from being converted to uppercase
711 * @param boolean Defines the type of header (if set, "<h3>" rather than the default "h4")
712 * @param integer The number of an icon to show with the header (see the icon-function). -1,1,2,3
713 * @param boolean If set, HTML tags are allowed in $label (otherwise this value is by default htmlspecialchars()'ed)
714 * @return string HTML content
715 * @see icons(), sectionHeader()
717 function section($label,$text,$nostrtoupper=FALSE,$sH=FALSE,$type=0,$allowHTMLinHeader=FALSE) {
722 if (!$allowHTMLinHeader) $label = htmlspecialchars($label);
723 $str.=$this->sectionHeader($this->icons($type).$label, $sH, $nostrtoupper ?
'' : ' class="uppercase"');
728 <!-- Section content -->
731 return $this->sectionBegin().$str;
735 * Inserts a divider image
736 * Ends a section (if open) before inserting the image
738 * @param integer The margin-top/-bottom of the <hr> ruler.
739 * @return string HTML content
741 function divider($dist) {
742 $dist = intval($dist);
746 <hr style="margin-top: '.$dist.'px; margin-bottom: '.$dist.'px;" />
748 return $this->sectionEnd().$str;
752 * Returns a blank <div>-section with a height
754 * @param integer Padding-top for the div-section (should be margin-top but konquorer (3.1) don't like it :-(
755 * @return string HTML content
757 function spacer($dist) {
761 <!-- Spacer element -->
762 <div style="padding-top: '.intval($dist).'px;"></div>
768 * Make a section header.
769 * Begins a section if not already open.
771 * @param string The label between the <h3> or <h4> tags. (Allows HTML)
772 * @param boolean If set, <h3> is used, otherwise <h4>
773 * @param string Additional attributes to h-tag, eg. ' class=""'
774 * @return string HTML content
776 function sectionHeader($label,$sH=FALSE,$addAttrib='') {
777 $tag = ($sH?
'h3':'h4');
780 <!-- Section header -->
781 <'.$tag.$addAttrib.'>'.$label.'</'.$tag.'>
783 return $this->sectionBegin().$str;
787 * Begins an output section.
788 * Returns the <div>-begin tag AND sets the ->sectionFlag true (if the ->sectionFlag is not already set!)
789 * You can call this function even if a section is already begun since the function will only return something if the sectionFlag is not already set!
791 * @return string HTML content
793 function sectionBegin() {
794 if (!$this->sectionFlag
) {
795 $this->sectionFlag
=1;
798 <!-- ***********************
799 Begin output section.
800 *********************** -->
808 * Ends and output section
809 * Returns the </div>-end tag AND clears the ->sectionFlag (but does so only IF the sectionFlag is set - that is a section is 'open')
810 * See sectionBegin() also.
812 * @return string HTML content
814 function sectionEnd() {
815 if ($this->sectionFlag
) {
816 $this->sectionFlag
=0;
819 <!-- *********************
821 ********************* -->
827 * Originally it printed a kind of divider.
828 * Depreciated. Just remove function calls to it or call the divider() function instead.
838 * If a form-tag is defined in ->form then and end-tag for that <form> element is outputted
839 * Further a JavaScript section is outputted which will update the top.busy session-expiry object (unless $this->endJS is set to false)
841 * @return string HTML content (<script> tag section)
843 function endPageJS() {
844 return ($this->endJS?
'
845 <script type="text/javascript">
847 if (top.busy && top.busy.loginRefreshed) {
848 top.busy.loginRefreshed();
855 * Creates the bodyTag.
856 * You can add to the bodyTag by $this->bodyTagAdditions
858 * @return string HTML body tag
860 function docBodyTagBegin() {
861 $bodyContent = 'body '.trim($this->bodyTagAdditions
.($this->bodyTagId ?
' id="'.$this->bodyTagId
.'"' : ''));
862 return '<'.trim($bodyContent).'>';
866 * Outputting document style
868 * @return string HTML style section/link tags
870 function docStyle() {
872 // Request background image:
873 if ($this->backGroundImage
) {
874 $this->inDocStylesArray
[]=' BODY { background-image: url('.$this->backPath
.$this->backGroundImage
.'); }';
877 // Add inDoc styles variables as well:
878 $this->inDocStylesArray
[] = $this->inDocStyles
;
879 $this->inDocStylesArray
[] = $this->inDocStyles_TBEstyle
;
882 $inDocStyles = implode('
883 ',$this->inDocStylesArray
);
885 // The default color scheme should also in full be represented in the stylesheet.
887 '.($this->styleSheetFile?
'<link rel="stylesheet" type="text/css" href="'.$this->backPath
.$this->styleSheetFile
.'" />':'').'
888 '.($this->styleSheetFile2?
'<link rel="stylesheet" type="text/css" href="'.$this->backPath
.$this->styleSheetFile2
.'" />':'').'
889 <style type="text/css" id="internalStyle">
891 '.trim($inDocStyles).'
892 /*###POSTCSSMARKER###*/
895 '.($this->styleSheetFile_post?
'<link rel="stylesheet" type="text/css" href="'.$this->backPath
.$this->styleSheetFile_post
.'" />':'')
898 $this->inDocStyles
='';
899 $this->inDocStylesArray
=array();
906 * Insert post rendering document style into already rendered content
907 * This is needed for extobjbase
909 * @param string style-content to insert.
910 * @return string content with inserted styles
912 function insertStylesAndJS($content) {
913 // insert accumulated CSS
914 $this->inDocStylesArray
[] = $this->inDocStyles
;
915 $styles = "\n".implode("\n", $this->inDocStylesArray
);
916 $content = str_replace('/*###POSTCSSMARKER###*/',$styles,$content);
918 // insert accumulated JS
919 $jscode = $this->JScode
."\n".$this->wrapScriptTags(implode("\n", $this->JScodeArray
));
920 $content = str_replace('<!--###POSTJSMARKER###-->',$jscode,$content);
926 * Initialize the charset.
927 * Sets the internal $this->charset variable to the charset defined in $GLOBALS["LANG"] (or the default as set in this class)
928 * Returns the meta-tag for the document header
930 * @return string <meta> tag with charset from $this->charset or $GLOBALS['LANG']->charSet
932 function initCharset() {
933 // Set charset to the charset provided by the current backend users language selection:
934 $this->charset
= $GLOBALS['LANG']->charSet ?
$GLOBALS['LANG']->charSet
: $this->charset
;
936 return '<meta http-equiv="Content-Type" content="text/html; charset='.$this->charset
.'" />';
940 * Returns generator meta tag
942 * @return string <meta> tag with name "GENERATOR"
944 function generator() {
945 $str = 'TYPO3 '.TYPO3_branch
.', http://typo3.com, © Kasper Skårhøj 1998-2005, extensions are copyright of their respective owners.';
946 return '<meta name="GENERATOR" content="'.$str .'" />';
956 /*****************************************
959 * Tables, buttons, formatting dimmed/red strings
961 ******************************************/
965 * Returns an image-tag with an 18x16 icon of the following types:
968 * -1: OK icon (Check-mark)
969 * 1: Notice (Speach-bubble)
970 * 2: Warning (Yellow triangle)
971 * 3: Fatal error (Red stop sign)
973 * @param integer See description
974 * @param string Value for style attribute
975 * @return string HTML image tag (if applicable)
977 function icons($type, $styleAttribValue='') {
980 $icon = 'gfx/icon_fatalerror.gif';
983 $icon = 'gfx/icon_warning.gif';
986 $icon = 'gfx/icon_note.gif';
989 $icon = 'gfx/icon_ok.gif';
995 return '<img'.t3lib_iconWorks
::skinImg($this->backPath
,$icon,'width="18" height="16"').' class="absmiddle"'.($styleAttribValue ?
' style="'.htmlspecialchars($styleAttribValue).'"' : '').' alt="" />';
1000 * Returns an <input> button with the $onClick action and $label
1002 * @param string The value of the onclick attribute of the input tag (submit type)
1003 * @param string The label for the button (which will be htmlspecialchar'ed)
1004 * @return string A <input> tag of the type "submit"
1006 function t3Button($onClick,$label) {
1007 $button = '<input type="submit" onclick="'.htmlspecialchars($onClick).'; return false;" value="'.htmlspecialchars($label).'" />';
1012 * dimmed-fontwrap. Returns the string wrapped in a <span>-tag defining the color to be gray/dimmed
1014 * @param string Input string
1015 * @return string Output string
1017 function dfw($string) {
1018 return '<span class="typo3-dimmed">'.$string.'</span>';
1022 * red-fontwrap. Returns the string wrapped in a <span>-tag defining the color to be red
1024 * @param string Input string
1025 * @return string Output string
1027 function rfw($string) {
1028 return '<span class="typo3-red">'.$string.'</span>';
1032 * Returns string wrapped in CDATA "tags" for XML / XHTML (wrap content of <script> and <style> sections in those!)
1034 * @param string Input string
1035 * @return string Output string
1037 function wrapInCData($string) {
1038 $string = '/*<![CDATA[*/'.
1046 * Wraps the input string in script tags.
1047 * Automatic re-identing of the JS code is done by using the first line as ident reference.
1048 * This is nice for identing JS code with PHP code on the same level.
1050 * @param string Input string
1051 * @param boolean Wrap script element in linebreaks? Default is TRUE.
1052 * @return string Output string
1054 function wrapScriptTags($string, $linebreak=TRUE) {
1056 // <script wrapped in nl?
1057 $cr = $linebreak?
"\n" : '';
1059 // remove nl from the beginning
1060 $string = preg_replace ('/^\n+/', '', $string);
1061 // re-ident to one tab using the first line as reference
1062 if(preg_match('/^(\t+)/',$string,$match)) {
1063 $string = str_replace($match[1],"\t", $string);
1065 $string = $cr.'<script type="text/javascript">
1071 return trim($string);
1074 // These vars defines the layout for the table produced by the table() function.
1075 // You can override these values from outside if you like.
1076 var $tableLayout = Array (
1078 'defCol' => Array('<td valign="top">','</td>')
1081 var $table_TR = '<tr>';
1082 var $table_TABLE = '<table border="0" cellspacing="0" cellpadding="0" id="typo3-tmpltable">';
1085 * Returns a table based on the input $arr
1087 * @param array Multidim array with first levels = rows, second levels = cells
1088 * @param array If set, then this provides an alternative layout array instead of $this->tableLayout
1089 * @return string The HTML table.
1092 function table($arr, $layout='') {
1093 if (is_array($arr)) {
1094 $tableLayout = (is_array($layout)) ?
$layout : $this->tableLayout
;
1099 while(list(,$val)=each($arr)) {
1101 $layout = is_array($tableLayout['defRowOdd']) ?
$tableLayout['defRowOdd'] : $tableLayout['defRow'];
1103 $layout = is_array($tableLayout['defRowEven']) ?
$tableLayout['defRowEven'] : $tableLayout['defRow'];
1105 $layoutRow = is_array($tableLayout[$rc]) ?
$tableLayout[$rc] : $layout;
1107 if (is_array($val)) {
1109 while(list(,$content)=each($val)) {
1110 $wrap= is_array($layoutRow[$cc]) ?
$layoutRow[$cc] : (is_array($layoutRow['defCol']) ?
$layoutRow['defCol'] : (is_array($layout[$cc]) ?
$layout[$cc] : $layout['defCol']));
1111 $code_td.=$wrap[0].$content.$wrap[1];
1115 $trWrap = is_array($layoutRow['tr']) ?
$layoutRow['tr'] : (is_array($layout['tr']) ?
$layout['tr'] : array($this->table_TR
, '</tr>'));
1116 $code.=$trWrap[0].$code_td.$trWrap[1];
1119 $tableWrap = is_array($tableLayout['table']) ?
$tableLayout['table'] : array($this->table_TABLE
, '</table>');
1120 $code=$tableWrap[0].$code.$tableWrap[1];
1126 * Constructs a table with content from the $arr1, $arr2 and $arr3.
1127 * Used in eg. ext/belog/mod/index.php - refer to that for examples
1129 * @param array Menu elements on first level
1130 * @param array Secondary items
1131 * @param array Third-level items
1132 * @return string HTML content, <table>...</table>
1134 function menuTable($arr1,$arr2=array(), $arr3=array()) {
1135 $rows = max(array(count($arr1),count($arr2),count($arr3)));
1138 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tablemenu">';
1139 for($a=0;$a<$rows;$a++
) {
1143 $cls[]='<td valign="'.$valign.'">'.$arr1[$a][0].'</td><td>'.$arr1[$a][1].'</td>';
1145 $cls[]='<td valign="'.$valign.'">'.$arr2[$a][0].'</td><td>'.$arr2[$a][1].'</td>';
1147 $cls[]='<td valign="'.$valign.'">'.$arr3[$a][0].'</td><td>'.$arr3[$a][1].'</td>';
1150 $menu.=implode($cls,'<td> </td>');
1160 * Returns a one-row/two-celled table with $content and $menu side by side.
1161 * The table is a 100% width table and each cell is aligned left / right
1163 * @param string Content cell content (left)
1164 * @param string Menu cell content (right)
1165 * @return string HTML output
1167 function funcMenu($content,$menu) {
1169 <table border="0" cellpadding="0" cellspacing="0" width="100%" id="typo3-funcmenu">
1171 <td valign="top" nowrap="nowrap">'.$content.'</td>
1172 <td valign="top" align="right" nowrap="nowrap">'.$menu.'</td>
1178 * Creates a selector box with clear-cache items.
1179 * Rather specialized functions - at least don't use it with $addSaveOptions unless you know what you do...
1181 * @param integer The page uid of the "current page" - the one that will be cleared as "clear cache for this page".
1182 * @param boolean If $addSaveOptions is set, then also the array of save-options for TCE_FORMS will appear.
1183 * @return string <select> tag with content - a selector box for clearing the cache
1185 function clearCacheMenu($id,$addSaveOptions=0) {
1188 if ($addSaveOptions) {
1189 $opt[]='<option value="">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.menu',1).'</option>';
1190 $opt[]='<option value="TBE_EDITOR_checkAndDoSubmit(1);">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc',1).'</option>';
1191 $opt[]='<option value="document.editform.closeDoc.value=-2; TBE_EDITOR_checkAndDoSubmit(1);">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseDoc',1).'</option>';
1192 if ($BE_USER->uc
['allSaveFunctions']) $opt[]='<option value="document.editform.closeDoc.value=-3; TBE_EDITOR_checkAndDoSubmit(1);">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseAllDocs',1).'</option>';
1193 $opt[]='<option value="document.editform.closeDoc.value=2; document.editform.submit();">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc',1).'</option>';
1194 $opt[]='<option value="document.editform.closeDoc.value=3; document.editform.submit();">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeAllDocs',1).'</option>';
1195 $opt[]='<option value=""></option>';
1197 $opt[]='<option value="">[ '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_clearCache',1).' ]</option>';
1198 if ($id) $opt[]='<option value="'.$id.'">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_thisPage',1).'</option>';
1199 if ($BE_USER->isAdmin() ||
$BE_USER->getTSConfigVal('options.clearCache.pages')) $opt[]='<option value="pages">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_pages',1).'</option>';
1200 if ($BE_USER->isAdmin() ||
$BE_USER->getTSConfigVal('options.clearCache.all')) $opt[]='<option value="all">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_all',1).'</option>';
1202 $onChange = 'if (!this.options[this.selectedIndex].value) {
1203 this.selectedIndex=0;
1204 } else if (this.options[this.selectedIndex].value.indexOf(\';\')!=-1) {
1205 eval(this.options[this.selectedIndex].value);
1207 document.location=\''.$this->backPath
.'tce_db.php?vC='.$BE_USER->veriCode().'&redirect='.rawurlencode(t3lib_div
::getIndpEnv('REQUEST_URI')).'&cacheCmd=\'+this.options[this.selectedIndex].value;
1209 $af_content = '<select name="cacheCmd" onchange="'.htmlspecialchars($onChange).'">'.implode('',$opt).'</select>';
1211 if (count($opt)>2) {
1217 * Returns an array with parts (JavaScript, init-functions, <div>-layers) for use on pages which displays the clickmenu layers (context sensitive menus)
1219 * @return array If values are present: [0] = A <script> section for the HTML page header, [1] = onmousemove/onload handler for HTML tag or alike, [2] = Two empty <div> layers for the context menu
1221 function getContextMenuCode() {
1222 if ($this->isCMlayers()) {
1224 <script type="text/javascript">
1227 var GLV_curLayerX=new Array(0,0);
1228 var GLV_curLayerY=new Array(0,0);
1229 var GLV_curLayerWidth=new Array(0,0);
1230 var GLV_curLayerHeight=new Array(0,0);
1231 var GLV_isVisible=new Array(0,0);
1236 var layerObj=new Array();
1237 var layerObjCss=new Array();
1240 function GL_checkBrowser(){ //
1241 this.dom= (document.getElementById);
1242 this.op= (navigator.userAgent.indexOf("Opera")>-1);
1243 this.op7= this.op && (navigator.appVersion.indexOf("7")>-1); // check for Opera version 7
1244 this.konq= (navigator.userAgent.indexOf("Konq")>-1);
1245 this.ie4= (document.all && !this.dom && !this.op && !this.konq);
1246 this.ie5= (document.all && this.dom && !this.op && !this.konq);
1247 this.ns4= (document.layers && !this.dom && !this.konq);
1248 this.ns5= (!document.all && this.dom && !this.op && !this.konq);
1249 this.ns6= (this.ns5);
1250 this.bw= (this.ie4 || this.ie5 || this.ns4 || this.ns6 || this.op || this.konq);
1253 bw= new GL_checkBrowser();
1256 function GL_getObj(obj){ //
1258 this.el= (bw.ie4||bw.op7)?document.all[obj]:bw.ns4?eval(nest+"document."+obj):document.getElementById(obj);
1259 this.css= bw.ns4?this.el:this.el.style;
1260 this.ref= bw.ns4?this.el.document:document;
1261 this.x= (bw.ns4||bw.op)?this.css.left:this.el.offsetLeft;
1262 this.y= (bw.ns4||bw.op)?this.css.top:this.el.offsetTop;
1263 this.height= (bw.ie4||bw.ie5||bw.ns6||this.konq||bw.op7)?this.el.offsetHeight:bw.ns4?this.ref.height:bw.op?this.css.pixelHeight:0;
1264 this.width= (bw.ie4||bw.ie5||bw.ns6||this.konq||bw.op7)?this.el.offsetWidth:bw.ns4?this.ref.width:bw.op?this.css.pixelWidth:0;
1267 // GL_getObjCss(obj)
1268 function GL_getObjCss(obj){ //
1269 return bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?document.layers[obj]:0;
1271 // GL_getMouse(event)
1272 function GL_getMouse(event) { //
1274 // GLV_x= (bw.ns4||bw.ns5)?event.pageX:(bw.ie4||bw.op)?event.clientX:(event.clientX-2)+document.body.scrollLeft;
1275 // GLV_y= (bw.ns4||bw.ns5)?event.pageY:(bw.ie4||bw.op)?event.clientY:(event.clientY-2)+document.body.scrollTop;
1276 // 17/12 2003: When documents run in XHTML standard compliance mode, the old scrollLeft/Top properties of document.body is gone - and for Opera/MSIE we have to use document.documentElement:
1278 GLV_xRel = event.clientX-2;
1279 GLV_yRel = event.clientY-2;
1280 GLV_x = GLV_xRel + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
1281 GLV_y = GLV_yRel + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
1283 // status = (GLV_x+GLV_gap-GLV_curLayerX[0]) + " | " + (GLV_y+GLV_gap-GLV_curLayerY[0]);
1284 if (GLV_isVisible[1]) {
1285 if (outsideLayer(1)) hideSpecific(1);
1286 } else if (GLV_isVisible[0]) {
1287 if (outsideLayer(0)) hideSpecific(0);
1291 // outsideLayer(level)
1292 function outsideLayer(level) { //
1293 return GLV_x+GLV_gap-GLV_curLayerX[level] <0 ||
1294 GLV_y+GLV_gap-GLV_curLayerY[level] <0 ||
1295 GLV_curLayerX[level]+GLV_curLayerWidth[level]+GLV_gap-GLV_x <0 ||
1296 GLV_curLayerY[level]+GLV_curLayerHeight[level]+GLV_gap-GLV_y <0;
1298 // setLayerObj(html,level)
1299 function setLayerObj(html,level) { //
1300 var winHeight = document.documentElement.clientHeight && !bw.op7 ? document.documentElement.clientHeight : document.body.clientHeight;
1301 var winWidth = document.documentElement.clientWidth && !bw.op7 ? document.documentElement.clientWidth : document.body.clientWidth;
1302 var tempLayerObj = GL_getObj("contentMenu"+level);
1303 var tempLayerObjCss = GL_getObjCss("contentMenu"+level);
1305 if (tempLayerObj && (level==0 || GLV_isVisible[level-1])) {
1306 tempLayerObj.el.innerHTML = html;
1307 tempLayerObj.width= (bw.ie4||bw.ie5||bw.ns6||bw.konq||bw.op7)?this.el.offsetWidth:bw.ns4?this.ref.width:bw.op?this.css.pixelWidth:0;
1308 tempLayerObj.height= (bw.ie4||bw.ie5||bw.ns6||bw.konq||bw.op7)?this.el.offsetHeight:bw.ns4?this.ref.height:bw.op?this.css.pixelHeight:0;
1310 // konqueror (3.2.2) workaround
1311 winHeight = (bw.konq)?window.innerHeight:winHeight;
1312 winWidth = (bw.konq)?window.innerWidth:winWidth;
1314 // Adjusting the Y-height of the layer to fit it into the window frame if it goes under the window frame in the bottom:
1315 if (winHeight-tempLayerObj.height < GLV_yRel) {
1316 if (GLV_yRel < tempLayerObj.height) {
1317 GLV_y+= (winHeight-tempLayerObj.height-GLV_yRel); // Setting it so bottom is just above window height.
1319 GLV_y-= tempLayerObj.height-8; // Showing the menu upwards
1322 // Adjusting the X position like Y above
1323 if (winWidth-tempLayerObj.width < GLV_xRel) {
1324 if (GLV_xRel < tempLayerObj.width) {
1325 GLV_x+= (winWidth-tempLayerObj.width-GLV_xRel);
1327 GLV_x-= tempLayerObj.width-8;
1330 GLV_x = Math.max(GLV_x,1);
1331 GLV_y = Math.max(GLV_y,1);
1333 GLV_curLayerX[level] = GLV_x;
1334 GLV_curLayerY[level] = GLV_y;
1335 tempLayerObjCss.left = GLV_x+"px";
1336 tempLayerObjCss.top = GLV_y+"px";
1337 tempLayerObjCss.visibility = "visible";
1338 if (bw.ie5) showHideSelectorBoxes("hidden");
1340 GLV_isVisible[level]=1;
1341 GLV_curLayerWidth[level] = tempLayerObj.width;
1342 GLV_curLayerHeight[level] = tempLayerObj.height;
1346 function hideEmpty() { //
1351 // hideSpecific(level)
1352 function hideSpecific(level) { //
1353 GL_getObjCss("contentMenu"+level).visibility = "hidden";
1354 GL_getObj("contentMenu"+level).el.innerHTML = "";
1355 GLV_isVisible[level]=0;
1357 if (bw.ie5 && level==0) showHideSelectorBoxes("visible");
1359 // debugObj(obj,name)
1360 function debugObj(obj,name) { //
1362 for (i in obj) {if (obj[i]) {acc+=i+": "+obj[i]+"\n";}}
1363 alert("Object: "+name+"\n\n"+acc);
1366 function initLayer(){ //
1368 window.onmousemove=GL_getMouse;
1370 layerObj = GL_getObj("contentMenu1");
1371 layerObjCss = GL_getObjCss("contentMenu1");
1373 function showHideSelectorBoxes(action) { // This function by Michiel van Leening
1374 for (i=0;i<document.forms.length;i++) {
1375 for (j=0;j<document.forms[i].elements.length;j++) {
1376 if(document.forms[i].elements[j].type=="select-one") {
1377 document.forms[i].elements[j].style.visibility=action;
1387 ' onmousemove="GL_getMouse(event);" onload="initLayer();"',
1388 '<div id="contentMenu0" style="z-index:1; position:absolute;visibility:hidden"></div><div id="contentMenu1" style="z-index:2; position:absolute;visibility:hidden"></div>'
1390 } else return array('','','');
1394 * Creates a tab menu from an array definition
1396 * Returns a tab menu for a module
1397 * Requires the JS function jumpToUrl() to be available
1399 * @param mixed $id is the "&id=" parameter value to be sent to the module, but it can be also a parameter array which will be passed instead of the &id=...
1400 * @param string $elementName it the form elements name, probably something like "SET[...]"
1401 * @param string $currentValue is the value to be selected currently.
1402 * @param array $menuItems is an array with the menu items for the selector box
1403 * @param string $script is the script to send the &id to, if empty it's automatically found
1404 * @param string $addParams is additional parameters to pass to the script.
1405 * @return string HTML code for tab menu
1406 * @author René Fritz <r.fritz@colorcube.de>
1408 function getTabMenu($mainParams,$elementName,$currentValue,$menuItems,$script='',$addparams='') {
1411 if (is_array($menuItems)) {
1412 if (!is_array($mainParams)) {
1413 $mainParams = array('id' => $mainParams);
1415 $mainParams = t3lib_div
::implodeArrayForUrl('',$mainParams);
1417 if (!$script) {$script=basename(PATH_thisScript
);}
1420 foreach($menuItems as $value => $label) {
1421 $menuDef[$value]['isActive'] = !strcmp($currentValue,$value);
1422 $menuDef[$value]['label'] = t3lib_div
::deHSCentities(htmlspecialchars($label));
1423 $menuDef[$value]['url'] = htmlspecialchars($script.'?'.$mainParams.$addparams.'&'.$elementName.'='.$value);
1425 $content = $this->getTabMenuRaw($menuDef);
1432 * Creates the HTML content for the tab menu
1434 * @param array Menu items for tabs
1435 * @return string Table HTML
1438 function getTabMenuRaw($menuItems) {
1441 if (is_array($menuItems)) {
1444 $count = count($menuItems);
1448 $widthRight = max (1,floor(30-pow($count,1.72)));
1449 $widthTabs = 100 - $widthRight - $widthLeft;
1450 $widthNo = floor(($widthTabs - $addToAct)/$count);
1451 $addToAct = max ($addToAct,$widthTabs-($widthNo*$count));
1452 $widthAct = $widthNo +
$addToAct;
1453 $widthRight = 100 - ($widthLeft +
($count*$widthNo) +
$addToAct);
1456 foreach($menuItems as $id => $def) {
1457 $isActive = $def['isActive'];
1458 $class = $isActive ?
'tabact' : 'tab';
1459 $width = $isActive ?
$widthAct : $widthNo;
1461 // @rene: Here you should probably wrap $label and $url in htmlspecialchars() in order to make sure its XHTML compatible! I did it for $url already since that is VERY likely to break.
1462 $label = $def['label'];
1463 $url = htmlspecialchars($def['url']);
1464 $params = $def['addParams'];
1468 <td width="'.$width.'%" class="'.$class.'" style="border-left: solid #000 1px;"><a href="'.$url.'" style="padding-left:5px;padding-right:2px;" '.$params.'>'.$label.'</a></td>';
1471 <td width="'.$width.'%" class="'.$class.'"><a href="'.$url.'" '.$params.'>'.$label.'</a></td>';
1479 <table cellpadding="0" cellspacing="0" border="0" width="100%" id="typo3-tabmenu">
1481 <td width="'.$widthLeft.'%"> </td>
1483 <td width="'.$widthRight.'%"> </td>
1486 <div class="hr" style="margin:0px"></div>';
1494 * Creates a DYNAMIC tab-menu where the tabs are switched between with DHTML.
1495 * Should work in MSIE, Mozilla, Opera and Konqueror. On Konqueror I did find a serious problem: <textarea> fields loose their content when you switch tabs!
1497 * @param array Numeric array where each entry is an array in itself with associative keys: "label" contains the label for the TAB, "content" contains the HTML content that goes into the div-layer of the tabs content. "description" contains description text to be shown in the layer. "linkTitle" is short text for the title attribute of the tab-menu link (mouse-over text of tab). "stateIcon" indicates a standard status icon (see ->icon(), values: -1, 1, 2, 3). "icon" is an image tag placed before the text.
1498 * @param string Identification string. This should be unique for every instance of a dynamic menu!
1499 * @param integer If "1", then enabling one tab does not hide the others - they simply toggles each sheet on/off. This makes most sense together with the $foldout option. If "-1" then it acts normally where only one tab can be active at a time BUT you can click a tab and it will close so you have no active tabs.
1500 * @param boolean If set, the tabs are rendered as headers instead over each sheet. Effectively this means there is no tab menu, but rather a foldout/foldin menu. Make sure to set $toggle as well for this option.
1501 * @param integer Character limit for a new row.
1502 * @param boolean If set, tab table cells are not allowed to wrap their content
1503 * @param boolean If set, the tabs will span the full width of their position
1504 * @param integer Default tab to open (for toggle <=0). Value corresponds to integer-array index + 1 (index zero is "1", index "1" is 2 etc.). A value of zero (or something non-existing) will result in no default tab open.
1505 * @return string JavaScript section for the HTML header.
1507 function getDynTabMenu($menuItems,$identString,$toggle=0,$foldout=FALSE,$newRowCharLimit=50,$noWrap=1,$fullWidth=FALSE,$defaultTabIndex=1) {
1510 if (is_array($menuItems)) {
1513 $options = array(array());
1516 $id = 'DTM-'.t3lib_div
::shortMD5($identString);
1517 $noWrap = $noWrap ?
' nowrap="nowrap"' : '';
1519 // Traverse menu items
1523 foreach($menuItems as $index => $def) {
1524 $index+
=1; // Need to add one so checking for first index in JavaScript is different than if it is not set at all.
1526 // Switch to next tab row if needed
1527 if (!$foldout && $titleLenCount>$newRowCharLimit) { // 50 characters is probably a reasonable count of characters before switching to next row of tabs.
1530 $options[$tabRows] = array();
1534 $onclick = 'this.blur(); DTM_toggle("'.$id.'","'.$index.'"); return false;';
1536 $onclick = 'this.blur(); DTM_activate("'.$id.'","'.$index.'", '.($toggle<0?
1:0).'); return false;';
1539 $isActive = strcmp($def['content'],'');
1541 $mouseOverOut = 'onmouseover="DTM_mouseOver(this);" onmouseout="DTM_mouseOut(this);"';
1545 $options[$tabRows][] = '
1546 <td class="'.($isActive ?
'tab' : 'disabled').'" id="'.$id.'-'.$index.'-MENU"'.$noWrap.$mouseOverOut.'>'.
1547 ($isActive ?
'<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ?
' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>' : '').
1549 ($def['label'] ?
htmlspecialchars($def['label']) : ' ').
1550 $this->icons($def['stateIcon'],'margin-left: 10px;').
1551 ($isActive ?
'</a>' :'').
1553 $titleLenCount+
= strlen($def['label']);
1555 // Create DIV layer for content:
1557 <div class="'.($isActive ?
'tab' : 'disabled').'" id="'.$id.'-'.$index.'-MENU"'.$mouseOverOut.'>'.
1558 ($isActive ?
'<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ?
' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>' : '').
1560 ($def['label'] ?
htmlspecialchars($def['label']) : ' ').
1561 ($isActive ?
'</a>' : '').
1566 // Create DIV layer for content:
1568 <div style="display: none;" id="'.$id.'-'.$index.'-DIV" class="c-tablayer">'.
1569 ($def['description'] ?
'<p class="c-descr">'.nl2br(htmlspecialchars($def['description'])).'</p>' : '').
1572 // Create initialization string:
1574 DTM_array["'.$id.'"]['.$c.'] = "'.$id.'-'.$index.'";
1578 if (top.DTM_currentTabs["'.$id.'-'.$index.'"]) { DTM_toggle("'.$id.'","'.$index.'",1); }
1587 if (count($options)) {
1589 // Tab menu is compiled:
1592 for($a=0;$a<=$tabRows;$a++
) {
1596 <table cellpadding="0" cellspacing="0" border="0"'.($fullWidth ?
' width="100%"' : '').' class="typo3-dyntabmenu">
1598 '.implode('',$options[$a]).'
1602 $content.= '<div class="typo3-dyntabmenu-tabs">'.$tabContent.'</div>';
1605 // Div layers are added:
1607 <!-- Div layers for tab menu: -->
1608 <div class="typo3-dyntabmenu-divs'.($foldout?
'-foldout':'').'">
1609 '.implode('',$divs).'</div>';
1611 // Java Script section added:
1613 <!-- Initialization JavaScript for the menu -->
1614 <script type="text/javascript">
1615 DTM_array["'.$id.'"] = new Array();
1616 '.implode('',$JSinit).'
1617 '.($toggle<=0 ?
'DTM_activate("'.$id.'", top.DTM_currentTabs["'.$id.'"]?top.DTM_currentTabs["'.$id.'"]:'.intval($defaultTabIndex).', 0);' : '').'
1628 * Returns dynamic tab menu header JS code.
1630 * @return string JavaScript section for the HTML header.
1632 function getDynTabMenuJScode() {
1634 <script type="text/javascript">
1636 var DTM_array = new Array();
1637 var DTM_origClass = new String();
1639 function DTM_activate(idBase,index,doToogle) { //
1641 if (DTM_array[idBase]) {
1642 for(cnt = 0; cnt < DTM_array[idBase].length ; cnt++) {
1643 if (DTM_array[idBase][cnt] != idBase+"-"+index) {
1644 document.getElementById(DTM_array[idBase][cnt]+"-DIV").style.display = "none";
1645 document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
1651 if (document.getElementById(idBase+"-"+index+"-DIV")) {
1652 if (doToogle && document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
1653 document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
1654 if(DTM_origClass=="") {
1655 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
1657 DTM_origClass = "tab";
1659 top.DTM_currentTabs[idBase] = -1;
1661 document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
1662 if(DTM_origClass=="") {
1663 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
1665 DTM_origClass = "tabact";
1667 top.DTM_currentTabs[idBase] = index;
1671 function DTM_toggle(idBase,index,isInit) { //
1673 if (document.getElementById(idBase+"-"+index+"-DIV")) {
1674 if (document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") {
1675 document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
1677 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
1679 DTM_origClass = "tab";
1681 top.DTM_currentTabs[idBase+"-"+index] = 0;
1683 document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
1685 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
1687 DTM_origClass = "tabact";
1689 top.DTM_currentTabs[idBase+"-"+index] = 1;
1694 function DTM_mouseOver(obj) {
1695 DTM_origClass = obj.attributes.getNamedItem(\'class\').nodeValue;
1696 obj.attributes.getNamedItem(\'class\').nodeValue += "_over";
1699 function DTM_mouseOut(obj) {
1700 obj.attributes.getNamedItem(\'class\').nodeValue = DTM_origClass;
1711 * Creates the version selector for the page id inputted.
1712 * Requires the core version management extension, "version" to be loaded.
1714 * @param integer Page id to create selector for.
1715 * @param boolean If set, there will be no button for swapping page.
1718 function getVersionSelector($id,$noAction=FALSE) {
1720 if ($id>0 && t3lib_extMgm
::isLoaded('version')) {
1722 // Get Current page record:
1723 $curPage = t3lib_BEfunc
::getRecord('pages',$id);
1724 // If the selected page is not online, find the right ID
1725 $onlineId = ($curPage['pid']==-1 ?
$curPage['t3ver_oid'] : $id);
1726 // Select all versions of online version:
1727 $versions = t3lib_BEfunc
::selectVersionsOfRecord('pages', $onlineId, 'uid,pid,t3ver_label,t3ver_oid,t3ver_id');
1729 // If more than one was found...:
1730 if (count($versions)>1) {
1732 // Create selector box entries:
1734 foreach($versions as $vRow) {
1735 $opt[] = '<option value="'.htmlspecialchars(t3lib_div
::linkThisScript(array('id'=>$vRow['uid']))).'"'.($id==$vRow['uid']?
' selected="selected"':'').'>'.
1736 htmlspecialchars($vRow['t3ver_label'].' [v#'.$vRow['t3ver_id'].']'.($vRow['uid']==$onlineId ?
' =>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.online').'<=':'')).
1740 // Add management link:
1741 $opt[] = '<option value="'.htmlspecialchars(t3lib_div
::linkThisScript(array('id'=>$id))).'">---</option>';
1742 $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>';
1744 // Create onchange handler:
1745 $onChange = "document.location=this.options[this.selectedIndex].value;";
1748 if ($id==$onlineId) {
1749 $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>';
1750 } elseif (!$noAction) {
1751 $controls = '<a href="'.$this->issueCommand('&cmd[pages]['.$onlineId.'][version][swapWith]='.$id.'&cmd[pages]['.$onlineId.'][version][action]=swap&cmd[pages]['.$onlineId.'][version][swapContent]=1',t3lib_div
::linkThisScript(array('id'=>$onlineId))).'">'.
1752 '<img'.t3lib_iconWorks
::skinImg($this->backPath
,'gfx/insert2.gif','width="14" height="14"').' style="margin-right: 2px;" class="absmiddle" alt="" title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.swapPage',1).'" />'.
1753 '<b>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.swap',1).'</b></a>';
1756 // Write out HTML code:
1762 <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
1764 <td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.selVer',1).'</td>
1766 <select onchange="'.htmlspecialchars($onChange).'">
1767 '.implode('',$opt).'
1769 <td>'.$controls.'</td>
1780 // ******************************
1781 // Extension classes of the template class.
1782 // These are meant to provide backend screens with different widths.
1783 // They still do because of the different class-prefixes used for the <div>-sections
1784 // but obviously the final width is determined by the stylesheet used.
1785 // ******************************
1788 * 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
1789 * The class were more significant in the past than today.
1792 class bigDoc
extends template
{
1793 var $divClass = 'typo3-bigDoc';
1797 * Extension class for "template" - used for backend pages without the "document" background image
1798 * The class were more significant in the past than today.
1801 class noDoc
extends template
{
1802 var $divClass = 'typo3-noDoc';
1806 * 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)
1807 * The class were more significant in the past than today.
1810 class smallDoc
extends template
{
1811 var $divClass = 'typo3-smallDoc';
1815 * 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.
1816 * The class were more significant in the past than today. But probably you should use this one for most modules you make.
1819 class mediumDoc
extends template
{
1820 var $divClass = 'typo3-mediumDoc';
1825 // Include extension to the template class?
1826 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/template.php']) {
1827 include_once($TYPO3_CONF_VARS[TYPO3_MODE
]['XCLASS']['typo3/template.php']);
1832 // ******************************************************
1833 // The backend language engine is started (ext: "lang")
1834 // ******************************************************
1835 require_once(PATH_typo3
.'sysext/lang/lang.php');
1836 $LANG = t3lib_div
::makeInstance('language');
1837 $LANG->init($BE_USER->uc
['lang']);
1841 // ******************************
1842 // The template is loaded
1843 // ******************************
1844 $TBE_TEMPLATE = t3lib_div
::makeInstance('template');