Documentation TYPO3 par Ameos

template.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00117 if (!defined('TYPO3_MODE'))     die("Can't include this file directly.");
00118 
00119 
00120 
00121 
00122 
00123 
00124 
00125 
00126 
00127 
00128 
00129 
00137 function fw($str)       {
00138         return $str;
00139 }
00140 
00141 
00161 class template {
00162 
00163                 // Vars you typically might want to/should set from outside after making instance of this class:
00164         var $backPath = '';                             // 'backPath' pointing back to the PATH_typo3
00165         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.
00166         var $JScode='';                                 // Additional header code (eg. a JavaScript section) could be accommulated in this var. It will be directly outputted in the header.
00167         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.
00168         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.
00169         var $docType = '';                              // Doc-type used in the header. Default is HTML 4. You can also set it to 'strict', 'xhtml_trans', or 'xhtml_frames'.
00170 
00171                 // Other vars you can change, but less frequently used:
00172         var $scriptID='';                               // Script ID.
00173         var $bodyTagId='';                              // Id which can be set for the body tag. Default value is based on script ID
00174         var $bodyTagAdditions='';               // You can add additional attributes to the body-tag through this variable.
00175         var $inDocStyles='';                    // Additional CSS styles which will be added to the <style> section in the header
00176         var $inDocStylesArray=array();          // Like $inDocStyles but for use as array with associative keys to prevent double inclusion of css code
00177         var $form_rowsToStylewidth = 9.58;      // Multiplication factor for formWidth() input size (default is 48* this value).
00178         var $form_largeComp = 1.33;             // Compensation for large documents (used in class.t3lib_tceforms.php)
00179         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.
00180 
00181                 // TYPO3 Colorscheme.
00182                 // If you want to change this, please do so through a skin using the global var $TBE_STYLES
00183         var $bgColor = '#F7F3EF';               // Light background color
00184         var $bgColor2 = '#9BA1A8';              // Steel-blue
00185         var $bgColor3 = '#F6F2E6';              // dok.color
00186         var $bgColor4 = '#D9D5C9';              // light tablerow background, brownish
00187         var $bgColor5 = '#ABBBB4';              // light tablerow background, greenish
00188         var $bgColor6 = '#E7DBA8';              // light tablerow background, yellowish, for section headers. Light.
00189         var $hoverColor = '#254D7B';
00190         var $styleSheetFile = 'stylesheet.css'; // Filename of stylesheet (relative to PATH_typo3)
00191         var $styleSheetFile2 = '';              // Filename of stylesheet #2 - linked to right after the $this->styleSheetFile script (relative to PATH_typo3)
00192         var $styleSheetFile_post = '';  // Filename of a post-stylesheet - included right after all inline styles.
00193         var $backGroundImage = '';              // Background image of page (relative to PATH_typo3)
00194         var $inDocStyles_TBEstyle = ''; // Inline css styling set from TBE_STYLES array
00195 
00196                 // DEV:
00197         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.
00198 
00199                 // INTERNAL
00200         var $charset = 'iso-8859-1';    // Default charset. see function initCharset()
00201 
00202         var $sectionFlag=0;                             // Internal: Indicates if a <div>-output section is open
00203         var $divClass = '';                             // (Default) Class for wrapping <DIV>-tag of page. Is set in class extensions.
00204 
00205 
00206 
00207 
00208 
00209 
00216         function template()     {
00217                 global $TBE_STYLES;
00218 
00219                         // Setting default scriptID:
00220                 $this->scriptID = ereg_replace('^.*\/(sysext|ext)\/','ext/',substr(PATH_thisScript,strlen(PATH_site)));
00221                 if (TYPO3_mainDir!='typo3/' && substr($this->scriptID,0,strlen(TYPO3_mainDir)) == TYPO3_mainDir)        {
00222                         $this->scriptID = 'typo3/'.substr($this->scriptID,strlen(TYPO3_mainDir));       // This fixes if TYPO3_mainDir has been changed so the script ids are STILL "typo3/..."
00223                 }
00224 
00225                 $this->bodyTagId = ereg_replace('[^[:alnum:]-]','-',$this->scriptID);
00226 
00227                         // Individual configuration per script? If so, make a recursive merge of the arrays:
00228                 if (is_array($TBE_STYLES['scriptIDindex'][$this->scriptID]))    {
00229                         $ovr = $TBE_STYLES['scriptIDindex'][$this->scriptID];           // Make copy
00230                         $TBE_STYLES = t3lib_div::array_merge_recursive_overrule($TBE_STYLES,$ovr);              // merge styles.
00231                         unset($TBE_STYLES['scriptIDindex'][$this->scriptID]);   // Have to unset - otherwise the second instantiation will do it again!
00232                 }
00233 
00234                         // Color scheme:
00235                 if ($TBE_STYLES['mainColors']['bgColor'])       $this->bgColor=$TBE_STYLES['mainColors']['bgColor'];
00236                 if ($TBE_STYLES['mainColors']['bgColor1'])      $this->bgColor1=$TBE_STYLES['mainColors']['bgColor1'];
00237                 if ($TBE_STYLES['mainColors']['bgColor2'])      $this->bgColor2=$TBE_STYLES['mainColors']['bgColor2'];
00238                 if ($TBE_STYLES['mainColors']['bgColor3'])      $this->bgColor3=$TBE_STYLES['mainColors']['bgColor3'];
00239                 if ($TBE_STYLES['mainColors']['bgColor4'])      $this->bgColor4=$TBE_STYLES['mainColors']['bgColor4'];
00240                 if ($TBE_STYLES['mainColors']['bgColor5'])      $this->bgColor5=$TBE_STYLES['mainColors']['bgColor5'];
00241                 if ($TBE_STYLES['mainColors']['bgColor6'])      $this->bgColor6=$TBE_STYLES['mainColors']['bgColor6'];
00242                 if ($TBE_STYLES['mainColors']['hoverColor'])    $this->hoverColor=$TBE_STYLES['mainColors']['hoverColor'];
00243 
00244                         // Main Stylesheets:
00245                 if ($TBE_STYLES['stylesheet'])  $this->styleSheetFile = $TBE_STYLES['stylesheet'];
00246                 if ($TBE_STYLES['stylesheet2']) $this->styleSheetFile2 = $TBE_STYLES['stylesheet2'];
00247                 if ($TBE_STYLES['styleSheetFile_post']) $this->styleSheetFile_post = $TBE_STYLES['styleSheetFile_post'];
00248                 if ($TBE_STYLES['inDocStyles_TBEstyle'])        $this->inDocStyles_TBEstyle = $TBE_STYLES['inDocStyles_TBEstyle'];
00249 
00250                         // Background image
00251                 if ($TBE_STYLES['background'])  $this->backGroundImage = $TBE_STYLES['background'];
00252         }
00253 
00254 
00255 
00256 
00257 
00258 
00259 
00260 
00261 
00262 
00263 
00264 
00265 
00266 
00267 
00268 
00269         /*****************************************
00270          *
00271          * EVALUATION FUNCTIONS
00272          * Various centralized processing
00273          *
00274          *****************************************/
00275 
00290         function wrapClickMenuOnIcon($str,$table,$uid='',$listFr=1,$addParams='',$enDisItems='', $returnOnClick=FALSE)  {
00291                 $backPath = '&backPath='.rawurlencode($this->backPath).'|'.t3lib_div::shortMD5($this->backPath.'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']);
00292                 $onClick = 'top.loadTopMenu(\''.$this->backPath.'alt_clickmenu.php?item='.rawurlencode($table.'|'.$uid.'|'.$listFr.'|'.$enDisItems).$backPath.$addParams.'\');'.$this->thisBlur().'return false;';
00293                 return $returnOnClick ? $onClick : '<a href="#" onclick="'.htmlspecialchars($onClick).'"'.($GLOBALS['TYPO3_CONF_VARS']['BE']['useOnContextMenuHandler'] ? ' oncontextmenu="'.htmlspecialchars($onClick).'"' : '').'>'.$str.'</a>';
00294         }
00295 
00307         function viewPageIcon($id,$backPath,$addParams='hspace="3"')    {
00308                 global $BE_USER;
00309                 $str = '';
00310                         // If access to Web>List for user, then link to that module.
00311                 if ($BE_USER->check('modules','web_list'))      {
00312                         $href=$backPath.'db_list.php?id='.$id.'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI'));
00313                         $str.= '<a href="'.htmlspecialchars($href).'">'.
00314                                         '<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="" />'.
00315                                         '</a>';
00316                 }
00317                         // Make link to view page
00318                 $str.= '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::viewOnClick($id,$backPath,t3lib_BEfunc::BEgetRootLine($id))).'">'.
00319                                 '<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="" />'.
00320                                 '</a>';
00321                 return $str;
00322         }
00323 
00333         function issueCommand($params,$rUrl='') {
00334                 $rUrl = $rUrl ? $rUrl : t3lib_div::getIndpEnv('REQUEST_URI');
00335                 return $this->backPath.'tce_db.php?'.
00336                                 $params.
00337                                 '&redirect='.($rUrl==-1?"'+T3_THIS_LOCATION+'":rawurlencode($rUrl)).
00338                                 '&vC='.rawurlencode($GLOBALS['BE_USER']->veriCode()).
00339                                 '&prErr=1&uPT=1';
00340         }
00341 
00348         function isCMlayers()   {
00349                 return !$GLOBALS['BE_USER']->uc['disableCMlayers'] && $GLOBALS['CLIENT']['FORMSTYLE'] && !($GLOBALS['CLIENT']['SYSTEM']=='mac' && $GLOBALS['CLIENT']['BROWSER']=='Opera');
00350         }
00351 
00358         function thisBlur()     {
00359                 return ($GLOBALS['CLIENT']['FORMSTYLE']?'this.blur();':'');
00360         }
00361 
00368         function helpStyle()    {
00369                 return $GLOBALS['CLIENT']['FORMSTYLE'] ? ' style="cursor:help;"':'';
00370         }
00371 
00385         function getHeader($table,$row,$path,$noViewPageIcon=0,$tWrap=array('',''))     {
00386                 global $TCA;
00387                 if (is_array($row) && $row['uid'])      {
00388                         $iconImgTag=t3lib_iconWorks::getIconImage($table,$row,$this->backPath,'title="'.htmlspecialchars($path).'"');
00389                         $title= strip_tags($row[$TCA[$table]['ctrl']['label']]);
00390                         $viewPage = $noViewPageIcon ? '' : $this->viewPageIcon($row['uid'],$this->backPath,'');
00391                         if ($table=='pages')    $path.=' - '.t3lib_BEfunc::titleAttribForPages($row,'',0);
00392                 } else {
00393                         $iconImgTag='<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/i/_icon_website.gif',$wHattribs='width="18" height="16"').' title="'.htmlspecialchars($path).'" alt="" />';
00394                         $title=$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'];
00395                 }
00396 
00397                 return '<span class="typo3-moduleHeader">'.$this->wrapClickMenuOnIcon($iconImgTag,$table,$row['uid']).
00398                                 $viewPage.
00399                                 $tWrap[0].htmlspecialchars(t3lib_div::fixed_lgd_cs($title,45)).$tWrap[1].'</span>';
00400         }
00401 
00411         function getFileheader($title,$path,$iconfile)  {
00412                 $fileInfo = t3lib_div::split_fileref($title);
00413                 $title = htmlspecialchars(t3lib_div::fixed_lgd_cs($fileInfo['path'],-35)).'<b>'.htmlspecialchars($fileInfo['file']).'</b>';
00414                 return '<span class="typo3-moduleHeader"><img'.t3lib_iconWorks::skinImg($this->backPath,$iconfile,'width="18" height="16"').' title="'.htmlspecialchars($path).'" alt="" />'.$title.'</span>';
00415         }
00416 
00426         function makeShortcutIcon($gvList,$setList,$modName,$motherModName="")  {
00427                 $backPath=$this->backPath;
00428                 $storeUrl=$this->makeShortcutUrl($gvList,$setList);
00429                 $pathInfo = parse_url(t3lib_div::getIndpEnv('REQUEST_URI'));
00430 
00431                 if (!strcmp($motherModName,'1'))        {
00432                         $mMN="&motherModName='+top.currentModuleLoaded+'";
00433                 } elseif ($motherModName)       {
00434                         $mMN='&motherModName='.rawurlencode($motherModName);
00435                 } else $mMN="";
00436 
00437                 $onClick = 'if (top.shortcutFrame && confirm('.
00438                                         $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.makeShortcut')).
00439                                         ')){top.shortcutFrame.document.location=\''.$backPath.'alt_shortcut.php?modName='.rawurlencode($modName).
00440                                         '&URL='.rawurlencode($pathInfo['path']."?".$storeUrl).
00441                                         $mMN.
00442                                         '\';}return false;';
00443 
00444                 $sIcon = '<a href="#" onclick="'.htmlspecialchars($onClick).'">
00445                                 <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>';
00446                 return $sIcon;
00447         }
00448 
00459         function makeShortcutUrl($gvList,$setList)      {
00460                 $GET = t3lib_div::_GET();
00461                 $storeArray = array_merge(
00462                         t3lib_div::compileSelectedGetVarsFromArray($gvList,$GET),
00463                         array('SET'=>t3lib_div::compileSelectedGetVarsFromArray($setList,$GLOBALS['SOBE']->MOD_SETTINGS))
00464                 );
00465                 $storeUrl = t3lib_div::implodeArrayForUrl('',$storeArray);
00466                 return $storeUrl;
00467         }
00468 
00480         function formWidth($size=48,$textarea=0,$styleOverride='') {
00481                 $wAttrib = $textarea?'cols':'size';
00482                 if (!$GLOBALS['CLIENT']['FORMSTYLE'])   {       // If not setting the width by style-attribute
00483                         $size = $size;
00484                         $retVal = ' '.$wAttrib.'="'.$size.'"';
00485                 } else {        // Setting width by style-attribute. 'cols' MUST be avoided with NN6+
00486                         $pixels = ceil($size*$this->form_rowsToStylewidth);
00487                         $retVal = $styleOverride ? ' style="'.$styleOverride.'"' : ' style="width:'.$pixels.'px;"';
00488                 }
00489                 return $retVal;
00490         }
00491 
00505         function formWidthText($size=48,$styleOverride='',$wrap='') {
00506                 $wTags = $this->formWidth($size,1,$styleOverride);
00507                         // 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...
00508                 if (strtolower(trim($wrap))!='off' && $GLOBALS['CLIENT']['BROWSER']=='net' && $GLOBALS['CLIENT']['VERSION']>=5) {
00509                         $wTags.=' cols="'.$size.'"';
00510                 }
00511                 return $wTags;
00512         }
00513 
00522         function redirectUrls($thisLocation='') {
00523                 $thisLocation = $thisLocation?$thisLocation:t3lib_div::linkThisScript(
00524                 array(
00525                         'CB'=>'',
00526                         'SET'=>'',
00527                         'cmd' => '',
00528                         'popViewId'=>''
00529                 ));
00530 
00531                 $out ="
00532         var T3_RETURN_URL = '".str_replace('%20','',rawurlencode(t3lib_div::_GP('returnUrl')))."';
00533         var T3_THIS_LOCATION = '".str_replace('%20','',rawurlencode($thisLocation))."';
00534                 ";
00535                 return $out;
00536         }
00537 
00546         function formatTime($tstamp,$type)      {
00547                 switch($type)   {
00548                         case 1: return date($GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'],$tstamp); break;
00549                         case 10: return date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'],$tstamp); break;
00550                 }
00551         }
00552 
00559         function parseTime()    {
00560                 if ($this->parseTimeFlag && $GLOBALS['BE_USER']->isAdmin()) {
00561                         return '<p>(ParseTime: '.(t3lib_div::milliseconds()-$GLOBALS['PARSETIME_START']).' ms</p>
00562                                         <p>REQUEST_URI-length: '.strlen(t3lib_div::getIndpEnv('REQUEST_URI')).')</p>';
00563                 }
00564         }
00565 
00566 
00567 
00568 
00569 
00570 
00571 
00572 
00573 
00574 
00575 
00576 
00577         /*****************************************
00578          *
00579          *      PAGE BUILDING FUNCTIONS.
00580          *      Use this to build the HTML of your backend modules
00581          *
00582          *****************************************/
00583 
00592         function startPage($title)      {
00593                         // Get META tag containing the currently selected charset for backend output. The function sets $this->charSet.
00594                 $charSet = $this->initCharset();
00595                 $generator = $this->generator();
00596 
00597                         // For debugging: If this outputs "QuirksMode"/"BackCompat" (IE) the browser runs in quirks-mode. Otherwise the value is "CSS1Compat"
00598 #               $this->JScodeArray[]='alert(document.compatMode);';
00599 
00600                         // Send HTTP header for selected charset. Added by Robert Lemke 23.10.2003
00601                 header ('Content-Type:text/html;charset='.$this->charset);
00602 
00603                 switch($this->docType)  {
00604                         case 'xhtml_strict':
00605                                 $headerStart= '<!DOCTYPE html
00606         PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
00607         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
00608 <?xml version="1.0" encoding="'.$this->charset.'"?>
00609 <?xml-stylesheet href="#internalStyle" type="text/css"?>
00610 ';
00611                         break;
00612                         case 'xhtml_trans':
00613                                 $headerStart= '<!DOCTYPE html
00614      PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
00615      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
00616 <?xml version="1.0" encoding="'.$this->charset.'"?>
00617 <?xml-stylesheet href="#internalStyle" type="text/css"?>
00618 ';
00619                         break;
00620                         case 'xhtml_frames':
00621                                 $headerStart= '<!DOCTYPE html
00622      PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
00623      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
00624 <?xml version="1.0" encoding="'.$this->charset.'"?>
00625 ';
00626                         break;
00627                         default:
00628                                 $headerStart='<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">';
00629                         break;
00630                 }
00631 
00632                         // Construct page header.
00633                 $str = $headerStart.'
00634 <html>
00635 <head>
00636         <!-- TYPO3 Script ID: '.htmlspecialchars($this->scriptID).' -->
00637         '.$charSet.'
00638         '.$generator.'
00639         <title>'.htmlspecialchars($title).'</title>
00640         '.$this->docStyle().'
00641         '.$this->JScode.'
00642         '.$this->wrapScriptTags(implode("\n", $this->JScodeArray)).'
00643         <!--###POSTJSMARKER###-->
00644 </head>
00645 ';
00646                 $this->JScode='';
00647                 $this->JScodeArray=array();
00648 
00649                 if ($this->docType=='xhtml_frames')     {
00650                         return $str;
00651                 } else
00652 $str.=$this->docBodyTagBegin().
00653 ($this->divClass?'
00654 
00655 <!-- Wrapping DIV-section for whole page BEGIN -->
00656 <div class="'.$this->divClass.'">
00657 ':'').trim($this->form);
00658                 return $str;
00659         }
00660 
00667         function endPage()      {
00668                 $str = $this->sectionEnd().
00669                                 $this->postCode.
00670                                 $this->endPageJS().
00671                                 t3lib_BEfunc::getSetUpdateSignal().
00672                                 $this->parseTime().
00673                                 ($this->form?'
00674 </form>':'');
00675 
00676                 if ($this->docType!='xhtml_frames') {
00677 
00678                         $str .= ($this->divClass?'
00679 
00680 <!-- Wrapping DIV-section for whole page END -->
00681 </div>':'').'
00682 </body> ';
00683 
00684                 }
00685 
00686                 $str .= '</html>';
00687 
00688                         // Logging: Can't find better place to put it:
00689                 if (TYPO3_DLOG) t3lib_div::devLog('END of BACKEND session','',0,array('_FLUSH'=>TRUE));
00690 
00691                 return $str;
00692         }
00693 
00701         function header($text)  {
00702                 $str='
00703 
00704         <!-- MAIN Header in page top -->
00705         <h2>'.htmlspecialchars($text).'</h2>
00706 ';
00707                 return $this->sectionEnd().$str;
00708         }
00709 
00722         function section($label,$text,$nostrtoupper=FALSE,$sH=FALSE,$type=0,$allowHTMLinHeader=FALSE)   {
00723                 $str='';
00724 
00725                         // Setting header
00726                 if ($label)     {
00727                         if (!$allowHTMLinHeader)        $label = htmlspecialchars($label);
00728                         $str.=$this->sectionHeader($this->icons($type).$label, $sH, $nostrtoupper ? '' : ' class="uppercase"');
00729                 }
00730                         // Setting content
00731                 $str.='
00732 
00733         <!-- Section content -->
00734 '.$text;
00735 
00736                 return $this->sectionBegin().$str;
00737         }
00738 
00746         function divider($dist) {
00747                 $dist = intval($dist);
00748                 $str='
00749 
00750         <!-- DIVIDER -->
00751         <hr style="margin-top: '.$dist.'px; margin-bottom: '.$dist.'px;" />
00752 ';
00753                 return $this->sectionEnd().$str;
00754         }
00755 
00762         function spacer($dist)  {
00763                 if ($dist>0)    {
00764                         return '
00765 
00766         <!-- Spacer element -->
00767         <div style="padding-top: '.intval($dist).'px;"></div>
00768 ';
00769                 }
00770         }
00771 
00781         function sectionHeader($label,$sH=FALSE,$addAttrib='')  {
00782                 $tag = ($sH?'h3':'h4');
00783                 $str='
00784 
00785         <!-- Section header -->
00786         <'.$tag.$addAttrib.'>'.$label.'</'.$tag.'>
00787 ';
00788                 return $this->sectionBegin().$str;
00789         }
00790 
00798         function sectionBegin() {
00799                 if (!$this->sectionFlag)        {
00800                         $this->sectionFlag=1;
00801                         $str='
00802 
00803         <!-- ***********************
00804               Begin output section.
00805              *********************** -->
00806         <div>
00807 ';
00808                         return $str;
00809                 } else return '';
00810         }
00811 
00819         function sectionEnd()   {
00820                 if ($this->sectionFlag) {
00821                         $this->sectionFlag=0;
00822                         return '
00823         </div>
00824         <!-- *********************
00825               End output section.
00826              ********************* -->
00827 ';
00828                 } else return '';
00829         }
00830 
00839         function middle()       {
00840         }
00841 
00848         function endPageJS()    {
00849                 return ($this->endJS?'
00850         <script type="text/javascript">
00851                   /*<![CDATA[*/
00852                 if (top.busy && top.busy.loginRefreshed) {
00853                         top.busy.loginRefreshed();
00854                 }
00855                  /*]]>*/
00856         </script>':'');
00857         }
00858 
00865         function docBodyTagBegin()      {
00866                 $bodyContent = 'body '.trim($this->bodyTagAdditions.($this->bodyTagId ? ' id="'.$this->bodyTagId.'"' : ''));
00867                 return '<'.trim($bodyContent).'>';
00868         }
00869 
00875         function docStyle()     {
00876 
00877                         // Request background image:
00878                 if ($this->backGroundImage)     {
00879                         $this->inDocStylesArray[]=' BODY { background-image: url('.$this->backPath.$this->backGroundImage.'); }';
00880                 }
00881 
00882                         // Add inDoc styles variables as well:
00883                 $this->inDocStylesArray[] = $this->inDocStyles;
00884                 $this->inDocStylesArray[] = $this->inDocStyles_TBEstyle;
00885 
00886                         // Implode it all:
00887                 $inDocStyles = implode('
00888                                         ',$this->inDocStylesArray);
00889 
00890                         // The default color scheme should also in full be represented in the stylesheet.
00891                 $style=trim('
00892                         '.($this->styleSheetFile?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile.'" />':'').'
00893                         '.($this->styleSheetFile2?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile2.'" />':'').'
00894                         <style type="text/css" id="internalStyle">
00895                                 /*<![CDATA[*/
00896                                         '.trim($inDocStyles).'
00897                                         /*###POSTCSSMARKER###*/
00898                                 /*]]>*/
00899                         </style>
00900                         '.($this->styleSheetFile_post?'<link rel="stylesheet" type="text/css" href="'.$this->backPath.$this->styleSheetFile_post.'" />':'')
00901                 )
00902                 ;
00903                 $this->inDocStyles='';
00904                 $this->inDocStylesArray=array();
00905 
00906                 return '
00907                         '.$style;
00908         }
00909 
00917         function insertStylesAndJS($content)    {
00918                         // insert accumulated CSS
00919                 $this->inDocStylesArray[] = $this->inDocStyles;
00920                 $styles = "\n".implode("\n", $this->inDocStylesArray);
00921                 $content = str_replace('/*###POSTCSSMARKER###*/',$styles,$content);
00922 
00923                         // insert accumulated JS
00924                 $jscode = $this->JScode."\n".$this->wrapScriptTags(implode("\n", $this->JScodeArray));
00925                 $content = str_replace('<!--###POSTJSMARKER###-->',$jscode,$content);
00926 
00927                 return $content;
00928         }
00929 
00937         function initCharset()  {
00938                         // Set charset to the charset provided by the current backend users language selection:
00939                 $this->charset = $GLOBALS['LANG']->charSet ? $GLOBALS['LANG']->charSet : $this->charset;
00940                         // Return meta tag:
00941                 return '<meta http-equiv="Content-Type" content="text/html; charset='.$this->charset.'" />';
00942         }
00943 
00949         function generator()    {
00950                 $str = 'TYPO3 '.TYPO3_branch.', http://typo3.com, &#169; Kasper Sk&#229;rh&#248;j 1998-2005, extensions are copyright of their respective owners.';
00951                 return '<meta name="GENERATOR" content="'.$str .'" />';
00952         }
00953 
00954 
00955 
00956 
00957 
00958 
00959 
00960 
00961         /*****************************************
00962          *
00963          * OTHER ELEMENTS
00964          * Tables, buttons, formatting dimmed/red strings
00965          *
00966          ******************************************/
00967 
00968 
00982         function icons($type, $styleAttribValue='')     {
00983                 switch($type)   {
00984                         case '3':
00985                                 $icon = 'gfx/icon_fatalerror.gif';
00986                         break;
00987                         case '2':
00988                                 $icon = 'gfx/icon_warning.gif';
00989                         break;
00990                         case '1':
00991                                 $icon = 'gfx/icon_note.gif';
00992                         break;
00993                         case '-1':
00994                                 $icon = 'gfx/icon_ok.gif';
00995                         break;
00996                         default:
00997                         break;
00998                 }
00999                 if ($icon)      {
01000                         return '<img'.t3lib_iconWorks::skinImg($this->backPath,$icon,'width="18" height="16"').' class="absmiddle"'.($styleAttribValue ? ' style="'.htmlspecialchars($styleAttribValue).'"' : '').' alt="" />';
01001                 }
01002         }
01003 
01011         function t3Button($onClick,$label)      {
01012                 $button = '<input type="submit" onclick="'.htmlspecialchars($onClick).'; return false;" value="'.htmlspecialchars($label).'" />';
01013                 return $button;
01014         }
01015 
01022         function dfw($string)   {
01023                 return '<span class="typo3-dimmed">'.$string.'</span>';
01024         }
01025 
01032         function rfw($string)   {
01033                 return '<span class="typo3-red">'.$string.'</span>';
01034         }
01035 
01042         function wrapInCData($string)   {
01043                 $string = '/*<![CDATA[*/'.
01044                         $string.
01045                         '/*]]>*/';
01046 
01047                 return $string;
01048         }
01049 
01059         function wrapScriptTags($string, $linebreak=TRUE)       {
01060                 if(trim($string)) {
01061                                 // <script wrapped in nl?
01062                         $cr = $linebreak? "\n" : '';
01063 
01064                                 // remove nl from the beginning
01065                         $string = preg_replace ('/^\n+/', '', $string);
01066                                 // re-ident to one tab using the first line as reference
01067                         if(preg_match('/^(\t+)/',$string,$match)) {
01068                                 $string = str_replace($match[1],"\t", $string);
01069                         }
01070                         $string = $cr.'<script type="text/javascript">
01071 /*<![CDATA[*/
01072 '.$string.'
01073 /*]]>*/
01074 </script>'.$cr;
01075                 }
01076                 return trim($string);
01077         }
01078 
01079                 // These vars defines the layout for the table produced by the table() function.
01080                 // You can override these values from outside if you like.
01081         var $tableLayout = Array (
01082                 'defRow' => Array (
01083                         'defCol' => Array('<td valign="top">','</td>')
01084                 )
01085         );
01086         var $table_TR = '<tr>';
01087         var $table_TABLE = '<table border="0" cellspacing="0" cellpadding="0" id="typo3-tmpltable">';
01088 
01097         function table($arr, $layout='')        {
01098                 if (is_array($arr))     {
01099                         $tableLayout = (is_array($layout)) ? $layout : $this->tableLayout;
01100 
01101                         reset($arr);
01102                         $code='';
01103                         $rc=0;
01104                         while(list(,$val)=each($arr))   {
01105                                 if ($rc % 2) {
01106                                         $layout = is_array($tableLayout['defRowOdd']) ? $tableLayout['defRowOdd'] : $tableLayout['defRow'];
01107                                 } else {
01108                                         $layout = is_array($tableLayout['defRowEven']) ? $tableLayout['defRowEven'] : $tableLayout['defRow'];
01109                                 }
01110                                 $layoutRow = is_array($tableLayout[$rc]) ? $tableLayout[$rc] : $layout;
01111                                 $code_td='';
01112                                 if (is_array($val))     {
01113                                         $cc=0;
01114                                         while(list(,$content)=each($val))       {
01115                                                 $wrap= is_array($layoutRow[$cc]) ? $layoutRow[$cc] : (is_array($layoutRow['defCol']) ? $layoutRow['defCol'] : (is_array($layout[$cc]) ? $layout[$cc] : $layout['defCol']));
01116                                                 $code_td.=$wrap[0].$content.$wrap[1];
01117                                                 $cc++;
01118                                         }
01119                                 }
01120                                 $trWrap = is_array($layoutRow['tr']) ? $layoutRow['tr'] : (is_array($layout['tr']) ? $layout['tr'] : array($this->table_TR, '</tr>'));
01121                                 $code.=$trWrap[0].$code_td.$trWrap[1];
01122                                 $rc++;
01123                         }
01124                         $tableWrap = is_array($tableLayout['table']) ? $tableLayout['table'] : array($this->table_TABLE, '</table>');
01125                         $code=$tableWrap[0].$code.$tableWrap[1];
01126                 }
01127                 return $code;
01128         }
01129 
01139         function menuTable($arr1,$arr2=array(), $arr3=array())  {
01140                 $rows = max(array(count($arr1),count($arr2),count($arr3)));
01141 
01142                 $menu='
01143                 <table border="0" cellpadding="0" cellspacing="0" id="typo3-tablemenu">';
01144                 for($a=0;$a<$rows;$a++) {
01145                         $menu.='<tr>';
01146                         $cls=array();
01147                         $valign='middle';
01148                         $cls[]='<td valign="'.$valign.'">'.$arr1[$a][0].'</td><td>'.$arr1[$a][1].'</td>';
01149                         if (count($arr2))       {
01150                                 $cls[]='<td valign="'.$valign.'">'.$arr2[$a][0].'</td><td>'.$arr2[$a][1].'</td>';
01151                                 if (count($arr3))       {
01152                                         $cls[]='<td valign="'.$valign.'">'.$arr3[$a][0].'</td><td>'.$arr3[$a][1].'</td>';
01153                                 }
01154                         }
01155                         $menu.=implode($cls,'<td>&nbsp;&nbsp;</td>');
01156                         $menu.='</tr>';
01157                 }
01158                 $menu.='
01159                 </table>
01160                 ';
01161                 return $menu;
01162         }
01163 
01172         function funcMenu($content,$menu)       {
01173                 return '
01174                         <table border="0" cellpadding="0" cellspacing="0" width="100%" id="typo3-funcmenu">
01175                                 <tr>
01176                                         <td valign="top" nowrap="nowrap">'.$content.'</td>
01177                                         <td valign="top" align="right" nowrap="nowrap">'.$menu.'</td>
01178                                 </tr>
01179                         </table>';
01180         }
01181 
01190         function clearCacheMenu($id,$addSaveOptions=0)  {
01191                 global $BE_USER;
01192                 $opt=$addOptions;
01193                 if ($addSaveOptions)    {
01194                         $opt[]='<option value="">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.menu',1).'</option>';
01195                         $opt[]='<option value="TBE_EDITOR_checkAndDoSubmit(1);">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc',1).'</option>';
01196                         $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>';
01197                         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>';
01198                         $opt[]='<option value="document.editform.closeDoc.value=2; document.editform.submit();">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc',1).'</option>';
01199                         $opt[]='<option value="document.editform.closeDoc.value=3; document.editform.submit();">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeAllDocs',1).'</option>';
01200                         $opt[]='<option value=""></option>';
01201                 }
01202                 $opt[]='<option value="">[ '.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_clearCache',1).' ]</option>';
01203                 if ($id) $opt[]='<option value="'.$id.'">'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_thisPage',1).'</option>';
01204                 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>';
01205                 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>';
01206 
01207                 $onChange = 'if (!this.options[this.selectedIndex].value) {
01208                                 this.selectedIndex=0;
01209                         } else if (this.options[this.selectedIndex].value.indexOf(\';\')!=-1) {
01210                                 eval(this.options[this.selectedIndex].value);
01211                         }else{
01212                                 document.location=\''.$this->backPath.'tce_db.php?vC='.$BE_USER->veriCode().'&redirect='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')).'&cacheCmd=\'+this.options[this.selectedIndex].value;
01213                         }';
01214                 $af_content = '<select name="cacheCmd" onchange="'.htmlspecialchars($onChange).'">'.implode('',$opt).'</select>';
01215 
01216                 if (count($opt)>2)      {
01217                         return $af_content;
01218                 }
01219         }
01220 
01226         function getContextMenuCode()   {
01227                 if ($this->isCMlayers())        {
01228                         $content='
01229                         <script type="text/javascript">
01230                         /*<![CDATA[*/
01231                                 var GLV_gap=10;
01232                                 var GLV_curLayerX=new Array(0,0);
01233                                 var GLV_curLayerY=new Array(0,0);
01234                                 var GLV_curLayerWidth=new Array(0,0);
01235                                 var GLV_curLayerHeight=new Array(0,0);
01236                                 var GLV_isVisible=new Array(0,0);
01237                                 var GLV_x=0;
01238                                 var GLV_y=0;
01239                                 var GLV_xRel=0;
01240                                 var GLV_yRel=0;
01241                                 var layerObj=new Array();
01242                                 var layerObjCss=new Array();
01243 
01244                                         //browsercheck...
01245                                 function GL_checkBrowser(){     //
01246                                         this.dom= (document.getElementById);
01247                                         this.op=  (navigator.userAgent.indexOf("Opera")>-1);
01248                                         this.op7=  this.op && (navigator.appVersion.indexOf("7")>-1);  // check for Opera version 7
01249                                         this.konq=  (navigator.userAgent.indexOf("Konq")>-1);
01250                                         this.ie4= (document.all && !this.dom && !this.op && !this.konq);
01251                                         this.ie5= (document.all && this.dom && !this.op && !this.konq);
01252                                         this.ns4= (document.layers && !this.dom && !this.konq);
01253                                         this.ns5= (!document.all && this.dom && !this.op && !this.konq);
01254                                         this.ns6= (this.ns5);
01255                                         this.bw=  (this.ie4 || this.ie5 || this.ns4 || this.ns6 || this.op || this.konq);
01256                                         return this;
01257                                 }
01258                                 bw= new GL_checkBrowser();
01259 
01260                                         // GL_getObj(obj)
01261                                 function GL_getObj(obj){        //
01262                                         nest="";
01263                                         this.el= (bw.ie4||bw.op7)?document.all[obj]:bw.ns4?eval(nest+"document."+obj):document.getElementById(obj);
01264                                         this.css= bw.ns4?this.el:this.el.style;
01265                                         this.ref= bw.ns4?this.el.document:document;
01266                                         this.x= (bw.ns4||bw.op)?this.css.left:this.el.offsetLeft;
01267                                         this.y= (bw.ns4||bw.op)?this.css.top:this.el.offsetTop;
01268                                         this.height= (bw.ie4||bw.dom)?this.el.offsetHeight:bw.ns4?this.ref.height:0;
01269                                         this.width= (bw.ie4||bw.dom)?this.el.offsetWidth:bw.ns4?this.ref.width:0;
01270                                         return this;
01271                                 }
01272                                         // GL_getObjCss(obj)
01273                                 function GL_getObjCss(obj){     //
01274                                         return bw.dom? document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?document.layers[obj]:0;
01275                                 }
01276                                         // GL_getMouse(event)
01277                                 function GL_getMouse(event) {   //
01278                                         if (layerObj)   {
01279 //                                              GLV_x= (bw.ns4||bw.ns5)?event.pageX:(bw.ie4||bw.op)?event.clientX:(event.clientX-2)+document.body.scrollLeft;
01280 //                                              GLV_y= (bw.ns4||bw.ns5)?event.pageY:(bw.ie4||bw.op)?event.clientY:(event.clientY-2)+document.body.scrollTop;
01281                                                         // 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:
01282 
01283                                                 GLV_xRel = event.clientX-2;
01284                                                 GLV_yRel = event.clientY-2;
01285                                                 GLV_x = GLV_xRel + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
01286                                                 GLV_y = GLV_yRel + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
01287 
01288                                         //      status = (GLV_x+GLV_gap-GLV_curLayerX[0]) + " | " + (GLV_y+GLV_gap-GLV_curLayerY[0]);
01289                                                 if (GLV_isVisible[1])   {
01290                                                         if (outsideLayer(1))    hideSpecific(1);
01291                                                 } else if (GLV_isVisible[0])    {
01292                                                         if (outsideLayer(0))    hideSpecific(0);
01293                                                 }
01294                                         }
01295                                 }
01296                                         // outsideLayer(level)
01297                                 function outsideLayer(level)    {       //
01298                                         return GLV_x+GLV_gap-GLV_curLayerX[level] <0 ||
01299                                                         GLV_y+GLV_gap-GLV_curLayerY[level] <0 ||
01300                                                         GLV_curLayerX[level]+GLV_curLayerWidth[level]+GLV_gap-GLV_x <0 ||
01301                                                         GLV_curLayerY[level]+GLV_curLayerHeight[level]+GLV_gap-GLV_y <0;
01302                                 }
01303                                         // setLayerObj(html,level)
01304                                 function setLayerObj(html,level)        {       //
01305                                         var winHeight = document.documentElement.clientHeight && !bw.op7 ? document.documentElement.clientHeight : document.body.clientHeight;
01306                                         var winWidth = document.documentElement.clientWidth && !bw.op7 ? document.documentElement.clientWidth : document.body.clientWidth;
01307                                         var tempLayerObj = GL_getObj("contentMenu"+level);
01308                                         var tempLayerObjCss = GL_getObjCss("contentMenu"+level);
01309 
01310                                         if (tempLayerObj && (level==0 || GLV_isVisible[level-1]))       {
01311                                                 tempLayerObj.el.innerHTML = html;
01312                                                 tempLayerObj.width= (bw.ie4||bw.dom)?this.el.offsetWidth:bw.ns4?this.ref.width:0;
01313                                                 tempLayerObj.height= (bw.ie4||bw.dom)?this.el.offsetHeight:bw.ns4?this.ref.height:0;
01314 
01315                                                         // konqueror (3.2.2) workaround
01316                                                 winHeight = (bw.konq)?window.innerHeight:winHeight;
01317                                                 winWidth = (bw.konq)?window.innerWidth:winWidth;
01318 
01319                                                         // Adjusting the Y-height of the layer to fit it into the window frame if it goes under the window frame in the bottom:
01320                                                 if (winHeight-tempLayerObj.height < GLV_yRel)   {
01321                                                         if (GLV_yRel < tempLayerObj.height) {
01322                                                                 GLV_y+= (winHeight-tempLayerObj.height-GLV_yRel);               // Setting it so bottom is just above window height.
01323                                                         } else {
01324                                                                 GLV_y-= tempLayerObj.height-8;          // Showing the menu upwards
01325                                                         }
01326                                                 }
01327                                                         // Adjusting the X position like Y above
01328                                                 if (winWidth-tempLayerObj.width < GLV_xRel)     {
01329                                                         if (GLV_xRel < tempLayerObj.width) {
01330                                                                 GLV_x+= (winWidth-tempLayerObj.width-GLV_xRel);
01331                                                         } else {
01332                                                                 GLV_x-= tempLayerObj.width-8;
01333                                                         }
01334                                                 }
01335                                                 GLV_x = Math.max(GLV_x,1);
01336                                                 GLV_y = Math.max(GLV_y,1);
01337 
01338                                                 GLV_curLayerX[level] = GLV_x;
01339                                                 GLV_curLayerY[level] = GLV_y;
01340                                                 tempLayerObjCss.left = GLV_x+"px";
01341                                                 tempLayerObjCss.top = GLV_y+"px";
01342                                                 tempLayerObjCss.visibility = "visible";
01343                                                 if (bw.ie5)     showHideSelectorBoxes("hidden");
01344 
01345                                                 GLV_isVisible[level]=1;
01346                                                 GLV_curLayerWidth[level] = tempLayerObj.width;
01347                                                 GLV_curLayerHeight[level] = tempLayerObj.height;
01348                                         }
01349                                 }
01350                                         // hideEmpty()
01351                                 function hideEmpty()    {       //
01352                                         hideSpecific(0);
01353                                         hideSpecific(1);
01354                                         return false;
01355                                 }
01356                                         // hideSpecific(level)
01357                                 function hideSpecific(level)    {       //
01358                                         GL_getObjCss("contentMenu"+level).visibility = "hidden";
01359                                         GL_getObj("contentMenu"+level).el.innerHTML = "";
01360                                         GLV_isVisible[level]=0;
01361 
01362                                         if (bw.ie5 && level==0) showHideSelectorBoxes("visible");
01363                                 }
01364                                         // debugObj(obj,name)
01365                                 function debugObj(obj,name)     {       //
01366                                         var acc;
01367                                         for (i in obj) {if (obj[i])     {acc+=i+":  "+obj[i]+"\n";}}
01368                                         alert("Object: "+name+"\n\n"+acc);
01369                                 }
01370                                         // initLayer()
01371                                 function initLayer(){   //
01372                                         if (document.all)   {
01373                                                 window.onmousemove=GL_getMouse;
01374                                         }
01375                                         layerObj = GL_getObj("contentMenu1");
01376                                         layerObjCss = GL_getObjCss("contentMenu1");
01377                                 }
01378                                 function showHideSelectorBoxes(action)  {       // This function by Michiel van Leening
01379                                         for (i=0;i<document.forms.length;i++) {
01380                                                 for (j=0;j<document.forms[i].elements.length;j++) {
01381                                                         if(document.forms[i].elements[j].type=="select-one") {
01382                                                                 document.forms[i].elements[j].style.visibility=action;
01383                                                         }
01384                                                 }
01385                                         }
01386                                 }
01387                         /*]]>*/
01388                         </script>
01389                         ';
01390                         return array(
01391                                 $content,
01392                                 ' onmousemove="GL_getMouse(event);" onload="initLayer();"',
01393                                 '<div id="contentMenu0" style="z-index:1; position:absolute;visibility:hidden"></div><div id="contentMenu1" style="z-index:2; position:absolute;visibility:hidden"></div>'
01394                         );
01395                 } else return array('','','');
01396         }
01397 
01413         function getTabMenu($mainParams,$elementName,$currentValue,$menuItems,$script='',$addparams='') {
01414                 $content='';
01415 
01416                 if (is_array($menuItems))       {
01417                         if (!is_array($mainParams)) {
01418                                 $mainParams = array('id' => $mainParams);
01419                         }
01420                         $mainParams = t3lib_div::implodeArrayForUrl('',$mainParams);
01421 
01422                         if (!$script) {$script=basename(PATH_thisScript);}
01423 
01424                         $menuDef = array();
01425                         foreach($menuItems as $value => $label) {
01426                                 $menuDef[$value]['isActive'] = !strcmp($currentValue,$value);
01427                                 $menuDef[$value]['label'] = t3lib_div::deHSCentities(htmlspecialchars($label));
01428                                 $menuDef[$value]['url'] = htmlspecialchars($script.'?'.$mainParams.$addparams.'&'.$elementName.'='.$value);
01429                         }
01430                         $content = $this->getTabMenuRaw($menuDef);
01431 
01432                 }
01433                 return $content;
01434         }
01435 
01443         function getTabMenuRaw($menuItems)      {
01444                 $content='';
01445 
01446                 if (is_array($menuItems))       {
01447                         $options='';
01448 
01449                         $count = count($menuItems);
01450                         $widthLeft = 1;
01451                         $addToAct = 5;
01452 
01453                         $widthRight = max (1,floor(30-pow($count,1.72)));
01454                         $widthTabs = 100 - $widthRight - $widthLeft;
01455                         $widthNo = floor(($widthTabs - $addToAct)/$count);
01456                         $addToAct = max ($addToAct,$widthTabs-($widthNo*$count));
01457                         $widthAct = $widthNo + $addToAct;
01458                         $widthRight = 100 - ($widthLeft + ($count*$widthNo) + $addToAct);
01459 
01460                         $first=true;
01461                         foreach($menuItems as $id => $def) {
01462                                 $isActive = $def['isActive'];
01463                                 $class = $isActive ? 'tabact' : 'tab';
01464                                 $width = $isActive ? $widthAct : $widthNo;
01465 
01466                                         // @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.
01467                                 $label = $def['label'];
01468                                 $url = htmlspecialchars($def['url']);
01469                                 $params = $def['addParams'];
01470 
01471                                 if($first) {
01472                                         $options.= '
01473                                                         <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>';
01474                                 } else {
01475                                         $options.='
01476                                                         <td width="'.$width.'%" class="'.$class.'"><a href="'.$url.'" '.$params.'>'.$label.'</a></td>';
01477                                 }
01478                                 $first=false;
01479                         }
01480 
01481                         if ($options)   {
01482                                 $content .= '
01483                                 <!-- Tab menu -->
01484                                 <table cellpadding="0" cellspacing="0" border="0" width="100%" id="typo3-tabmenu">
01485                                         <tr>
01486                                                         <td width="'.$widthLeft.'%">&nbsp;</td>
01487                                                         '.$options.'
01488                                                 <td width="'.$widthRight.'%">&nbsp;</td>
01489                                         </tr>
01490                                 </table>
01491                                 <div class="hr" style="margin:0px"></div>';
01492                         }
01493 
01494                 }
01495                 return $content;
01496         }
01497 
01512         function getDynTabMenu($menuItems,$identString,$toggle=0,$foldout=FALSE,$newRowCharLimit=50,$noWrap=1,$fullWidth=FALSE,$defaultTabIndex=1)      {
01513                 $content = '';
01514 
01515                 if (is_array($menuItems))       {
01516 
01517                                 // Init:
01518                         $options = array(array());
01519                         $divs = array();
01520                         $JSinit = array();
01521                         $id = 'DTM-'.t3lib_div::shortMD5($identString);
01522                         $noWrap = $noWrap ? ' nowrap="nowrap"' : '';
01523 
01524                                 // Traverse menu items
01525                         $c=0;
01526                         $tabRows=0;
01527                         $titleLenCount = 0;
01528                         foreach($menuItems as $index => $def) {
01529                                 $index+=1;      // Need to add one so checking for first index in JavaScript is different than if it is not set at all.
01530 
01531                                         // Switch to next tab row if needed
01532                                 if (!$foldout && $titleLenCount>$newRowCharLimit)       {       // 50 characters is probably a reasonable count of characters before switching to next row of tabs.
01533                                         $titleLenCount=0;
01534                                         $tabRows++;
01535                                         $options[$tabRows] = array();
01536                                 }
01537 
01538                                 if ($toggle==1) {
01539                                         $onclick = 'this.blur(); DTM_toggle("'.$id.'","'.$index.'"); return false;';
01540                                 } else {
01541                                         $onclick = 'this.blur(); DTM_activate("'.$id.'","'.$index.'", '.($toggle<0?1:0).'); return false;';
01542                                 }
01543 
01544                                 $isActive = strcmp($def['content'],'');
01545 
01546                                 $mouseOverOut = 'onmouseover="DTM_mouseOver(this);" onmouseout="DTM_mouseOut(this);"';
01547 
01548                                 if (!$foldout)  {
01549                                                 // Create TAB cell:
01550                                         $options[$tabRows][] = '
01551                                                         <td class="'.($isActive ? 'tab' : 'disabled').'" id="'.$id.'-'.$index.'-MENU"'.$noWrap.$mouseOverOut.'>'.
01552                                                         ($isActive ? '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ? ' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>' : '').
01553                                                         $def['icon'].
01554                                                         ($def['label'] ? htmlspecialchars($def['label']) : '&nbsp;').
01555                                                         $this->icons($def['stateIcon'],'margin-left: 10px;').
01556                                                         ($isActive ? '</a>' :'').
01557                                                         '</td>';
01558                                         $titleLenCount+= strlen($def['label']);
01559                                 } else {
01560                                                 // Create DIV layer for content:
01561                                         $divs[] = '
01562                                                 <div class="'.($isActive ? 'tab' : 'disabled').'" id="'.$id.'-'.$index.'-MENU"'.$mouseOverOut.'>'.
01563                                                         ($isActive ? '<a href="#" onclick="'.htmlspecialchars($onclick).'"'.($def['linkTitle'] ? ' title="'.htmlspecialchars($def['linkTitle']).'"':'').'>' : '').
01564                                                         $def['icon'].
01565                                                         ($def['label'] ? htmlspecialchars($def['label']) : '&nbsp;').
01566                                                         ($isActive ? '</a>' : '').
01567                                                         '</div>';
01568                                 }
01569 
01570                                 if ($isActive)  {
01571                                                 // Create DIV layer for content:
01572                                         $divs[] = '
01573                                                         <div style="display: none;" id="'.$id.'-'.$index.'-DIV" class="c-tablayer">'.
01574                                                                 ($def['description'] ? '<p class="c-descr">'.nl2br(htmlspecialchars($def['description'])).'</p>' : '').
01575                                                                 $def['content'].
01576                                                                 '</div>';
01577                                                 // Create initialization string:
01578                                         $JSinit[] = '
01579                                                         DTM_array["'.$id.'"]['.$c.'] = "'.$id.'-'.$index.'";
01580                                         ';
01581                                         if ($toggle==1) {
01582                                                 $JSinit[] = '
01583                                                         if (top.DTM_currentTabs["'.$id.'-'.$index.'"]) { DTM_toggle("'.$id.'","'.$index.'",1); }
01584                                                 ';
01585                                         }
01586 
01587                                         $c++;
01588                                 }
01589                         }
01590 
01591                                 // Render menu:
01592                         if (count($options))    {
01593 
01594                                         // Tab menu is compiled:
01595                                 if (!$foldout)  {
01596                                         $tabContent = '';
01597                                         for($a=0;$a<=$tabRows;$a++)     {
01598                                                 $tabContent.= '
01599 
01600                                         <!-- Tab menu -->
01601                                         <table cellpadding="0" cellspacing="0" border="0"'.($fullWidth ? ' width="100%"' : '').' class="typo3-dyntabmenu">
01602                                                 <tr>
01603                                                                 '.implode('',$options[$a]).'
01604                                                 </tr>
01605                                         </table>';
01606                                         }
01607                                         $content.= '<div class="typo3-dyntabmenu-tabs">'.$tabContent.'</div>';
01608                                 }
01609 
01610                                         // Div layers are added:
01611                                 $content.= '
01612                                 <!-- Div layers for tab menu: -->
01613                                 <div class="typo3-dyntabmenu-divs'.($foldout?'-foldout':'').'">
01614                                 '.implode('',$divs).'</div>';
01615 
01616                                         // Java Script section added:
01617                                 $content.= '
01618                                 <!-- Initialization JavaScript for the menu -->
01619                                 <script type="text/javascript">
01620                                         DTM_array["'.$id.'"] = new Array();
01621                                         '.implode('',$JSinit).'
01622                                         '.($toggle<=0 ? 'DTM_activate("'.$id.'", top.DTM_currentTabs["'.$id.'"]?top.DTM_currentTabs["'.$id.'"]:'.intval($defaultTabIndex).', 0);' : '').'
01623                                 </script>
01624 
01625                                 ';
01626                         }
01627 
01628                 }
01629                 return $content;
01630         }
01631 
01637         function getDynTabMenuJScode()  {
01638                 return '
01639                         <script type="text/javascript">
01640                         /*<![CDATA[*/
01641                                 var DTM_array = new Array();
01642                                 var DTM_origClass = new String();
01643 
01644                                 function DTM_activate(idBase,index,doToogle)    {       //
01645                                                 // Hiding all:
01646                                         if (DTM_array[idBase])  {
01647                                                 for(cnt = 0; cnt < DTM_array[idBase].length ; cnt++)    {
01648                                                         if (DTM_array[idBase][cnt] != idBase+"-"+index) {
01649                                                                 document.getElementById(DTM_array[idBase][cnt]+"-DIV").style.display = "none";
01650                                                                 document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
01651                                                         }
01652                                                 }
01653                                         }
01654 
01655                                                 // Showing one:
01656                                         if (document.getElementById(idBase+"-"+index+"-DIV"))   {
01657                                                 if (doToogle && document.getElementById(idBase+"-"+index+"-DIV").style.display == "block")      {
01658                                                         document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
01659                                                         if(DTM_origClass=="") {
01660                                                                 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
01661                                                         } else {
01662                                                                 DTM_origClass = "tab";
01663                                                         }
01664                                                         top.DTM_currentTabs[idBase] = -1;
01665                                                 } else {
01666                                                         document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
01667                                                         if(DTM_origClass=="") {
01668                                                                 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
01669                                                         } else {
01670                                                                 DTM_origClass = "tabact";
01671                                                         }
01672                                                         top.DTM_currentTabs[idBase] = index;
01673                                                 }
01674                                         }
01675                                 }
01676                                 function DTM_toggle(idBase,index,isInit)        {       //
01677                                                 // Showing one:
01678                                         if (document.getElementById(idBase+"-"+index+"-DIV"))   {
01679                                                 if (document.getElementById(idBase+"-"+index+"-DIV").style.display == "block")  {
01680                                                         document.getElementById(idBase+"-"+index+"-DIV").style.display = "none";
01681                                                         if(isInit) {
01682                                                                 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab";
01683                                                         } else {
01684                                                                 DTM_origClass = "tab";
01685                                                         }
01686                                                         top.DTM_currentTabs[idBase+"-"+index] = 0;
01687                                                 } else {
01688                                                         document.getElementById(idBase+"-"+index+"-DIV").style.display = "block";
01689                                                         if(isInit) {
01690                                                                 document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact";
01691                                                         } else {
01692                                                                 DTM_origClass = "tabact";
01693                                                         }
01694                                                         top.DTM_currentTabs[idBase+"-"+index] = 1;
01695                                                 }
01696                                         }
01697                                 }
01698 
01699                                 function DTM_mouseOver(obj) {   //
01700                                                 DTM_origClass = obj.attributes.getNamedItem(\'class\').nodeValue;
01701                                                 obj.attributes.getNamedItem(\'class\').nodeValue += "_over";
01702                                 }
01703 
01704                                 function DTM_mouseOut(obj) {    //
01705                                                 obj.attributes.getNamedItem(\'class\').nodeValue = DTM_origClass;
01706                                                 DTM_origClass = "";
01707                                 }
01708 
01709 
01710                         /*]]>*/
01711                         </script>
01712                 ';
01713         }
01714 
01723         function getVersionSelector($id,$noAction=FALSE)        {
01724 
01725                 if ($id>0 && t3lib_extMgm::isLoaded('version')) {
01726 
01727                                 // Get Current page record:
01728                         $curPage = t3lib_BEfunc::getRecord('pages',$id);
01729                                 // If the selected page is not online, find the right ID
01730                         $onlineId = ($curPage['pid']==-1 ? $curPage['t3ver_oid'] : $id);
01731                                 // Select all versions of online version:
01732                         $versions = t3lib_BEfunc::selectVersionsOfRecord('pages', $onlineId, 'uid,pid,t3ver_label,t3ver_oid,t3ver_id');
01733 
01734                                 // If more than one was found...:
01735                         if (count($versions)>1) {
01736 
01737                                         // Create selector box entries:
01738                                 $opt = array();
01739                                 foreach($versions as $vRow)     {
01740                                         $opt[] = '<option value="'.htmlspecialchars(t3lib_div::linkThisScript(array('id'=>$vRow['uid']))).'"'.($id==$vRow['uid']?' selected="selected"':'').'>'.
01741                                                         htmlspecialchars($vRow['t3ver_label'].' [v#'.$vRow['t3ver_id'].']'.($vRow['uid']==$onlineId ? ' =>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.online').'<=':'')).
01742                                                         '</option>';
01743                                 }
01744 
01745                                         // Add management link:
01746                                 $opt[] = '<option value="'.htmlspecialchars(t3lib_div::linkThisScript(array('id'=>$id))).'">---</option>';
01747                                 $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>';
01748 
01749                                         // Create onchange handler:
01750                                 $onChange = "document.location=this.options[this.selectedIndex].value;";
01751 
01752                                         // Controls:
01753                                 if ($id==$onlineId)     {
01754                                         $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>';
01755                                 } elseif (!$noAction) {
01756                                         $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))).'">'.
01757                                                         '<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).'" />'.
01758                                                         '<b>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.swap',1).'</b></a>';
01759                                 }
01760 
01761                                         // Write out HTML code:
01762                                 return '
01763 
01764                                         <!--
01765                                                 Version selector:
01766                                         -->
01767                                         <table border="0" cellpadding="0" cellspacing="0" id="typo3-versionSelector">
01768                                                 <tr>
01769                                                         <td>'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:ver.selVer',1).'</td>
01770                                                         <td>
01771                                                                 <select onchange="'.htmlspecialchars($onChange).'">
01772                                                                         '.implode('',$opt).'
01773                                                                 </select></td>
01774                                                         <td>'.$controls.'</td>
01775                                                 </tr>
01776                                         </table>
01777                                 ';
01778                         }
01779                 }
01780         }
01781 }
01782 
01783 
01784 
01785 // ******************************
01786 // Extension classes of the template class.
01787 // These are meant to provide backend screens with different widths.
01788 // They still do because of the different class-prefixes used for the <div>-sections
01789 // but obviously the final width is determined by the stylesheet used.
01790 // ******************************
01791 
01797 class bigDoc extends template {
01798         var $divClass = 'typo3-bigDoc';
01799 }
01800 
01806 class noDoc extends template {
01807         var $divClass = 'typo3-noDoc';
01808 }
01809 
01815 class smallDoc extends template {
01816         var $divClass = 'typo3-smallDoc';
01817 }
01818 
01824 class mediumDoc extends template {
01825         var $divClass = 'typo3-mediumDoc';
01826 }
01827 
01828 
01829 
01830 // Include extension to the template class?
01831 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/template.php'])      {
01832         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/template.php']);
01833 }
01834 
01835 
01836 
01837 // ******************************************************
01838 // The backend language engine is started (ext: "lang")
01839 // ******************************************************
01840 require_once(PATH_typo3.'sysext/lang/lang.php');
01841 $LANG = t3lib_div::makeInstance('language');
01842 $LANG->init($BE_USER->uc['lang']);
01843 
01844 
01845 
01846 // ******************************
01847 // The template is loaded
01848 // ******************************
01849 $TBE_TEMPLATE = t3lib_div::makeInstance('template');
01850 ?>


Généré par Les spécialistes TYPO3 avec  doxygen 1.4.6