--- typo3/template.php (revision 2741) +++ typo3/template.php (working copy) @@ -24,13 +24,13 @@ * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ /** * Contains class with layout/output function for TYPO3 Backend Scripts * - * $Id$ + * $Id: template.php 2592 2007-10-20 18:26:12Z ingmars $ * Revised for TYPO3 3.6 2/2003 by Kasper Skaarhoj * XHTML-trans compliant * * @author Kasper Skaarhoj */ /** @@ -75,13 +75,12 @@ * 894: function docStyle() * 936: function insertStylesAndJS($content) * 956: function initCharset() * 968: function generator() * * SECTION: OTHER ELEMENTS - * 1001: function icons($type, $styleAttribValue='') * 1030: function t3Button($onClick,$label) * 1041: function dfw($string) * 1051: function rfw($string) * 1061: function wrapInCData($string) * 1078: function wrapScriptTags($string, $linebreak=TRUE) * 1117: function table($arr, $layout='') @@ -95,13 +94,12 @@ * 1472: function getDragDropCode($table) * 1483: function cancelDragEvent(event) * 1496: function mouseMoveEvent (event) * 1509: function dragElement(id,elementID) * 1528: function dropElement(id) * 1577: function getTabMenu($mainParams,$elementName,$currentValue,$menuItems,$script='',$addparams='') - * 1607: function getTabMenuRaw($menuItems) * 1676: function getDynTabMenu($menuItems,$identString,$toggle=0,$foldout=FALSE,$newRowCharLimit=50,$noWrap=1,$fullWidth=FALSE,$defaultTabIndex=1) * 1801: function getDynTabMenuJScode() * 1892: function getVersionSelector($id,$noAction=FALSE) * * * 2060: class bigDoc extends template @@ -112,22 +110,24 @@ * * 2078: class smallDoc extends template * * * 2087: class mediumDoc extends template * - * TOTAL FUNCTIONS: 57 + * TOTAL FUNCTIONS: 55 * (This index is automatically created/updated by the extension "extdeveval") * */ if (!defined('TYPO3_MODE')) die("Can't include this file directly."); require_once(PATH_t3lib.'class.t3lib_ajax.php'); +require_once(PATH_t3lib.'class.t3lib_iconworks.php'); +require_once(PATH_t3lib.'class.t3lib_tabmenus.php'); @@ -167,13 +167,13 @@ * @subpackage core */ class template { // Vars you typically might want to/should set from outside after making instance of this class: var $backPath = ''; // 'backPath' pointing back to the PATH_typo3 - 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. + 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. var $JScodeLibArray = array(); // Similar to $JScode (see below) but used as an associative array to prevent double inclusion of JS code. This is used to include certain external Javascript libraries before the inline JS code. - '; - } - } - return $content; - } /** * Returns dynamic tab menu header JS code. * * @return string JavaScript section for the HTML header. */ function getDynTabMenuJScode() { - return ' - '; - // if tabs are used in a popup window the array might not exists - if(!top.DTM_currentTabs) { - top.DTM_currentTabs = new Array(); - } - function DTM_activate(idBase,index,doToogle) { // - // Hiding all: - if (DTM_array[idBase]) { - for(cnt = 0; cnt < DTM_array[idBase].length ; cnt++) { - if (DTM_array[idBase][cnt] != idBase+"-"+index) { - document.getElementById(DTM_array[idBase][cnt]+"-DIV").style.display = "none"; - // Only Overriding when Tab not disabled - if (document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue != "disabled") { - document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue = "tab"; - } - } - } - } - // Showing one: - if (document.getElementById(idBase+"-"+index+"-DIV")) { - if (doToogle && document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") { - document.getElementById(idBase+"-"+index+"-DIV").style.display = "none"; - if(DTM_origClass=="") { - document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab"; - } else { - DTM_origClass = "tab"; - } - top.DTM_currentTabs[idBase] = -1; - } else { - document.getElementById(idBase+"-"+index+"-DIV").style.display = "block"; - if(DTM_origClass=="") { - document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact"; - } else { - DTM_origClass = "tabact"; - } - top.DTM_currentTabs[idBase] = index; - } - } - } - function DTM_toggle(idBase,index,isInit) { // - // Showing one: - if (document.getElementById(idBase+"-"+index+"-DIV")) { - if (document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") { - document.getElementById(idBase+"-"+index+"-DIV").style.display = "none"; - if(isInit) { - document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab"; - } else { - DTM_origClass = "tab"; - } - top.DTM_currentTabs[idBase+"-"+index] = 0; - } else { - document.getElementById(idBase+"-"+index+"-DIV").style.display = "block"; - if(isInit) { - document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact"; - } else { - DTM_origClass = "tabact"; - } - top.DTM_currentTabs[idBase+"-"+index] = 1; - } - } - } - function DTM_mouseOver(obj) { // - DTM_origClass = obj.attributes.getNamedItem(\'class\').nodeValue; - obj.attributes.getNamedItem(\'class\').nodeValue += "_over"; - } - function DTM_mouseOut(obj) { // - obj.attributes.getNamedItem(\'class\').nodeValue = DTM_origClass; - DTM_origClass = ""; - } - /*]]>*/ - - '; - } + } /** * Creates the version selector for the page id inputted. * Requires the core version management extension, "version" to be loaded. * * @param integer Page id to create selector for. --- t3lib/class.t3lib_iconworks.php (revision 2698) +++ t3lib/class.t3lib_iconworks.php (working copy) @@ -45,12 +45,13 @@ * * SECTION: Other functions * 353: function makeIcon($iconfile,$mode, $user, $protectSection,$absFile,$iconFileName_stateTagged) * 475: function imagecopyresized(&$im, $cpImg, $Xstart, $Ystart, $cpImgCutX, $cpImgCutY, $w, $h, $w, $h) * 505: function imagecreatefrom($file) * 522: function imagemake($im, $path) + function icons($type, $styleAttribValue='',$backPath='',$skinImage=true) * * TOTAL FUNCTIONS: 7 * (This index is automatically created/updated by the extension "extdeveval") * */ @@ -515,8 +516,46 @@ if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png']) { @ImagePng($im, $path); } else { @ImageGif($im, $path); } } + + /** + * Returns an image-tag with an 18x16 icon of the following types: + * + * $type: + * -1: OK icon (Check-mark) + * 1: Notice (Speach-bubble) + * 2: Warning (Yellow triangle) + * 3: Fatal error (Red stop sign) + * + * @param integer See description + * @param string Value for style attribute + * @return string HTML image tag (if applicable) + */ + function icons($type, $styleAttribValue='',$backPath='',$skinImage=true) { + switch($type) { + case '3': + $icon = 'gfx/icon_fatalerror.gif'; + break; + case '2': + $icon = 'gfx/icon_warning.gif'; + break; + case '1': + $icon = 'gfx/icon_note.gif'; + break; + case '-1': + $icon = 'gfx/icon_ok.gif'; + break; + default: + break; + } + if ($icon) { + if($skinImage) // backend modules can use skinimages but they are not available for frontend + return ''; + else return ''; + + } + } } ?> --- t3lib/class.t3lib_tceforms.php (revision 2741) +++ t3lib/class.t3lib_tceforms.php (working copy) @@ -24,13 +24,13 @@ * * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ /** * Contains TYPO3 Core Form generator - AKA "TCEforms" * - * $Id$ + * $Id: class.t3lib_tceforms.php 2607 2007-10-22 19:33:53Z ingmars $ * Revised for TYPO3 3.6 August/2003 by Kasper Skaarhoj * XHTML compliant * * @author Kasper Skaarhoj */ /** @@ -107,13 +107,12 @@ * 3549: function formWidth($size=48,$textarea=0) * 3576: function formWidthText($size=48,$wrap='') * 3592: function formElStyle($type) * 3603: function formElClass($type) * 3614: function formElStyleClassValue($type, $class=FALSE) * 3638: function insertDefStyle($type) - * 3657: function getDynTabMenu($parts, $idString) * * SECTION: Item-array manipulation functions (check/select/radio) * 3696: function initItemArray($fieldValue) * 3714: function addItems($items,$iArray) * 3736: function procItems($items,$iArray,$config,$table,$row,$field) * 3760: function addSelectOptionsToItemArray($items,$fieldValue,$TSconfig,$field) @@ -179,12 +178,13 @@ require_once(PATH_t3lib.'class.t3lib_diff.php'); require_once(PATH_t3lib.'class.t3lib_tceforms_inline.php'); +require_once(PATH_t3lib.'class.t3lib_tabmenus.php'); /** * 'TCEforms' - Class for creating the backend editing forms. * @@ -223,13 +223,12 @@ var $backPath=''; // Set this to the 'backPath' pointing back to the typo3 admin directory from the script where this form is displayed. var $returnUrl=''; // Alternative return URL path (default is t3lib_div::linkThisScript()) var $doSaveFieldName=''; // Can be set to point to a field name in the form which will be set to '1' when the form is submitted with a *save* button. This way the recipient script can determine that the form was submitted for save and not "close" for example. var $palettesCollapsed=0; // Can be set true/false to whether palettes (secondary options) are in the topframe or in form. True means they are NOT IN-form. So a collapsed palette is one, which is shown in the top frame, not in the page. var $disableRTE=0; // If set, the RTE is disabled (from form display, eg. by checkbox in the bottom of the page!) var $globalShowHelp=1; // If false, then all CSH will be disabled, regardless of settings in $this->edit_showFieldHelp - var $localizationMode=''; // If true, the forms are rendering only localization relevant fields of the records. + var $localizationMode=''; // If true, the forms are rendering only localization relevant fields of the records. var $fieldOrder=''; // Overrule the field order set in TCA[types][showitem], eg for tt_content this value, 'bodytext,image', would make first the 'bodytext' field, then the 'image' field (if set for display)... and then the rest in the old order. var $doPrintPalette=1; // If set to false, palettes will NEVER be rendered. var $dividers2tabs=0; // Will be set to TCA[ctrl][dividers2tabs] /** * Set to initialized clipboard object; Then the element browser will offer a link to paste in records from clipboard. @@ -296,13 +295,13 @@ // Internal, registers for user defined functions etc. var $additionalCode_pre = array(); // Additional HTML code, printed before the form. var $additionalJS_pre = array(); // Additional JavaScript, printed before the form var $additionalJS_post = array(); // Additional JavaScript printed after the form var $additionalJS_submit = array(); // Additional JavaScript executed on submit; If you set "OK" variable it will raise an error about RTEs not being loaded and offer to block further submission. - + /** * Instance of t3lib_tceforms_inline * * @var t3lib_TCEforms_inline */ var $inline; @@ -490,16 +489,16 @@ } if ($TCA[$table]) { // Load the full TCA for the table. t3lib_div::loadTCA($table); - + // Loads the dividers2tabs from the $TCA $this->dividers2tabs = $TCA[$table]['ctrl']['dividers2tabs']; - + // Load the description content for the table. if ($this->edit_showFieldHelp || $this->doLoadTableDescr($table)) { $GLOBALS['LANG']->loadSingleTableDescription($table); } // Get the current "type" value for the record. $typeNum = $this->getRTypeNum($table,$row); @@ -520,13 +519,13 @@ // If TCEforms will render a tab menu in the next step, push the name to the tab stack: $tabIdentString = ''; $tabIdentStringMD5 = ''; if (strstr($itemList, '--div--') !== false && $this->enableTabMenu && $this->dividers2tabs) { $tabIdentString = 'TCEforms:'.$table.':'.$row['uid']; - $tabIdentStringMD5 = $GLOBALS['TBE_TEMPLATE']->getDynTabMenuId($tabIdentString,); + $tabIdentStringMD5 = t3lib_tabMenus::getDynTabMenuId($tabIdentString,'',0, FALSE, 50, 1, FALSE, 1, $this->dividers2tabs); // Remember that were currently working on the general tab: if (isset($fields[0]) && strpos($fields[0], '--div--') !== 0) { $this->pushToDynNestedStack('tab', $tabIdentStringMD5.'-1'); } } @@ -566,14 +565,14 @@ $out_array[$out_sheet][$out_pointer].= $sField; } elseif ($theField=='--div--') { if ($cc>0) { $out_array[$out_sheet][$out_pointer].=$this->getDivider(); - if ($this->enableTabMenu && $this->dividers2tabs) { - $this->wrapBorder($out_array[$out_sheet],$out_pointer); + if ($this->enableTabMenu && $this->dividers2tabs) { + $this->wrapBorder($out_array[$out_sheet],$out_pointer); // Remove last tab entry from the dynNestedStack: $out_sheet++; // Remove the previous sheet from stack (if any): $this->popFromDynNestedStack('tab', $tabIdentStringMD5.'-'.($out_sheet)); // Remember on which sheet we're currently working: $this->pushToDynNestedStack('tab', $tabIdentStringMD5.'-'.($out_sheet+1)); @@ -644,13 +643,13 @@ // Return the imploded $out_array: if ($out_sheet>0) { // There were --div-- dividers around... // Create parts array for the tab menu: $parts = array(); - foreach ($out_array as $idx => $sheetContent) { + foreach ($out_array as $idx => $sheetContent) { $content = implode('', $sheetContent); if ($content) { // Wrap content (row) with table-tag, otherwise tab/sheet will be disabled (see getdynTabMenu() ) $content = ''.$content.'
'; } $parts[$idx] = array( @@ -661,26 +660,26 @@ } if (count($parts) > 1) { // Unset the current level of tab menus: $this->popFromDynNestedStack('tab', $tabIdentStringMD5.'-'.($out_sheet+1)); - $output = $this->getDynTabMenu($parts, $tabIdentString); + $output = t3lib_tabMenus::getDynTabMenu($parts, $tabIdentString,0, FALSE, 50, 1, FALSE, 1, $this->dividers2tabs); } else { // If there is only one tab/part there is no need to wrap it into the dynTab code $output = isset($parts[0]) ? trim($parts[0]['content']) : ''; } $output = ' '.$output.' '; - + } else { // Only one, so just implode: $output = implode('',$out_array[$out_sheet]); } return $output; @@ -895,12 +894,13 @@ // Find item $item=''; $PA['label'] = ($PA['altName'] ? $PA['altName'] : $PA['fieldConf']['label']); $PA['label'] = ($PA['fieldTSConfig']['label'] ? $PA['fieldTSConfig']['label'] : $PA['label']); $PA['label'] = ($PA['fieldTSConfig']['label.'][$GLOBALS['LANG']->lang] ? $PA['fieldTSConfig']['label.'][$GLOBALS['LANG']->lang] : $PA['label']); - $PA['label'] = $this->sL($PA['label']); + $PA['label'] = $this->sL($PA['label']); // JavaScript code for event handlers: $PA['fieldChangeFunc']=array(); $PA['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = "TBE_EDITOR.fieldChanged('".$table."','".$row['uid']."','".$field."','".$PA['itemFormElName']."');"; $PA['fieldChangeFunc']['alert']=$alertMsgOnChange; // if this is the child of an inline type and it is the field creating the label @@ -1085,13 +1086,13 @@ } if (in_array('password',$evalList)) { $itemFormElValue = $itemFormElValue ? '*********' : ''; } return $this->getSingleField_typeNone_render($config, $itemFormElValue); } - + foreach ($evalList as $func) { switch ($func) { case 'required': $this->requiredFields[$table.'_'.$row['uid'].'_'.$field]=$PA['itemFormElName']; break; default: @@ -1511,13 +1512,13 @@ } // Getting style attribute value (for icons): if ($config['iconsInOptionTags']) { $styleAttrValue = $this->optionTagStyle($p[2]); } - + // Compiling the '; } @@ -2300,13 +2300,13 @@ 'linkTitle' => ($dataStruct['ROOT']['TCEforms']['sheetShortDescr'] ? $this->sL($dataStruct['ROOT']['TCEforms']['sheetShortDescr']) : ''), 'content' => $sheetContent ); } if (is_array($dataStructArray['sheets'])) { - $item.= $this->getDynTabMenu($tabParts,'TCEFORMS:flexform:'.$PA['itemFormElName'].$PA['_lang']); + $item.= t3lib_tabMenus::getDynTabMenu($tabParts,'TCEFORMS:flexform:'.$PA['itemFormElName'].$PA['_lang'],0, FALSE, 50, 1, FALSE, 1, $this->dividers2tabs); } else { $item.= $sheetContent; } } } else $item='Data Structure ERROR: '.$dataStructArray; @@ -2358,13 +2358,13 @@ ''; } return ''.implode('',$tCells).'
'; } - /** + /** * Recursive rendering of flexforms * * @param array (part of) Data Structure for which to render. Keys on first level is flex-form fields * @param array (part of) Data array of flexform corresponding to the input DS. Keys on first level is flex-form field names * @param string Table name, eg. tt_content * @param string Field name, eg. tx_templavoila_flex @@ -2941,26 +2941,26 @@ return $this->cachedTSconfig[$mainKey]; } } /** * Overrides the TCA field configuration by TSconfig settings. - * + * * Example TSconfig: TCEform...config.appearance.useSortable = 1 * This overrides the setting in $TCA[
]['columns'][]['config']['appearance']['useSortable']. * * @param array $fieldConfig: TCA field configuration * @param array $TSconfig: TSconfig * @return array Changed TCA field configuration */ function overrideFieldConf($fieldConfig, $TSconfig) { if (is_array($TSconfig)) { $TSconfig = t3lib_div::removeDotsFromTS($TSconfig); $type = $fieldConfig['type']; if (is_array($TSconfig['config']) && is_array($this->allowOverrideMatrix[$type])) { - // Check if the keys in TSconfig['config'] are allowed to override TCA field config: + // Check if the keys in TSconfig['config'] are allowed to override TCA field config: foreach (array_keys($TSconfig['config']) as $key) { if (!in_array($key, $this->allowOverrideMatrix[$type], true)) { unset($TSconfig['config'][$key]); } } // Override TCA field config by remaining TSconfig['config']: @@ -3107,19 +3107,19 @@ $dLVal = t3lib_BEfunc::getProcessedValue($table,$field,$this->defaultLanguageData[$table.':'.$row['uid']][$field],0,1); $fCfg = $GLOBALS['TCA'][$table]['columns'][$field]; if (strcmp($dLVal,'')) { $item.='
'.$this->getLanguageIcon($table,$row,0).$this->previewFieldValue($dLVal,$fCfg).' 
'; } - + $prLang = $this->getAdditionalPreviewLanguages(); foreach($prLang as $prL) { $dlVal = t3lib_BEfunc::getProcessedValue($table,$field,$this->additionalPreviewLanguageData[$table.':'.$row['uid']][$prL['uid']][$field],0,1); $item.= '
'.$this->getLanguageIcon($table,$row,'v'.$prL['ISOcode']).$this->previewFieldValue($dlVal, $fCfg).' 
'; } - + } return $item; } /** @@ -3935,34 +3935,6 @@ $class = $this->formElClass($type); $out.= $class?' class="'.htmlspecialchars($class).'"':''; return $out; } - /** - * Create dynamic tab menu - * - * @param array Parts for the tab menu, fed to template::getDynTabMenu() - * @param string ID string for the tab menu - * @return string HTML for the menu - */ - function getDynTabMenu($parts, $idString) { - if (is_object($GLOBALS['TBE_TEMPLATE'])) { - return $GLOBALS['TBE_TEMPLATE']->getDynTabMenu($parts, $idString, 0, FALSE, 50, 1, FALSE, 1, $this->dividers2tabs); - } else { - $output = ''; - foreach($parts as $singlePad) { - $output.=' -

'.htmlspecialchars($singlePad['label']).'

- '.($singlePad['description'] ? '

'.nl2br(htmlspecialchars($singlePad['description'])).'

' : '').' - '.$singlePad['content']; - } - return '
'.$output.'
'; - } - } @@ -4796,13 +4767,13 @@ * ... and then include the result of this function after the form * * @param string $formname: The identification of the form on the page. * @param boolean $update: Just extend/update existing settings, e.g. for AJAX call * @return string A section with JavaScript - if $update is false, embedded in */ - function JSbottom($formname='forms[0]', $update = false) { + function JSbottom($formname='forms[0]', $update = false) { $jsFile = array(); $elements = array(); // required: foreach ($this->requiredFields as $itemImgName => $itemName) { $match = array(); @@ -5545,19 +5516,19 @@ } if ($onlyIsoCoded && !$output[$row['uid']]['ISOcode']) unset($output[$row['uid']]); } return $output; } - + /** * Initializes language icons etc. * * param string Table name * param array Record - * param string Sys language uid OR ISO language code prefixed with "v", eg. "vDA" + * param string Sys language uid OR ISO language code prefixed with "v", eg. "vDA" * @return void */ function getLanguageIcon($table,$row,$sys_language_uid) { global $TCA,$LANG; $mainKey = $table.':'.$row['uid']; @@ -5655,13 +5626,13 @@ // None: $this->cachedAdditionalPreviewLanguages = array(); } } return $this->cachedAdditionalPreviewLanguages; } - + /** * Push a new element to the dynNestedStack. Thus, every object know, if it's * nested in a tab or IRRE level and in which order this was processed. * * @param string $type: Type of the level, e.g. "tab" or "inline" * @param string $ident: Identifier of the level @@ -5672,13 +5643,13 @@ } /** * Remove an element from the dynNestedStack. If $type and $ident * are set, the last element will only be removed, if it matches * what is expected to be removed. - * + * * @param string $type: Type of the level, e.g. "tab" or "inline" * @param string $ident: Identifier of the level * @return void */ function popFromDynNestedStack($type=null, $ident=null) { if ($type!=null && $ident!=null) { +++ t3lib/js/dyntabmenu.js (working copy) @@ -0,0 +1,75 @@ + var DTM_array = new Array(); + var DTM_origClass = new String(); + + // if tabs are used in a popup window the array might not exists + if(!top.DTM_currentTabs) { + top.DTM_currentTabs = new Array(); + } + + function DTM_activate(idBase,index,doToogle) { // + // Hiding all: + if (DTM_array[idBase]) { + for(cnt = 0; cnt < DTM_array[idBase].length ; cnt++) { + if (DTM_array[idBase][cnt] != idBase+"-"+index) { + document.getElementById(DTM_array[idBase][cnt]+"-DIV").style.display = "none"; + // Only Overriding when Tab not disabled + if (document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue != "disabled") { + document.getElementById(DTM_array[idBase][cnt]+"-MENU").attributes.getNamedItem("class").nodeValue = "tab"; + } + } + } + + // Showing one: + if (document.getElementById(idBase+"-"+index+"-DIV")) { + if (doToogle && document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") { + document.getElementById(idBase+"-"+index+"-DIV").style.display = "none"; + if(DTM_origClass=="") { + document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab"; + } else { + DTM_origClass = "tab"; + } + top.DTM_currentTabs[idBase] = -1; + } else { + document.getElementById(idBase+"-"+index+"-DIV").style.display = "block"; + if(DTM_origClass=="") { + document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact"; + } else { + DTM_origClass = "tabact"; + } + top.DTM_currentTabs[idBase] = index; + } + } + } + } + function DTM_toggle(idBase,index,isInit) { // + // Showing one: + if (document.getElementById(idBase+"-"+index+"-DIV")) { + if (document.getElementById(idBase+"-"+index+"-DIV").style.display == "block") { + document.getElementById(idBase+"-"+index+"-DIV").style.display = "none"; + if(isInit) { + document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tab"; + } else { + DTM_origClass = "tab"; + } + top.DTM_currentTabs[idBase+"-"+index] = 0; + } else { + document.getElementById(idBase+"-"+index+"-DIV").style.display = "block"; + if(isInit) { + document.getElementById(idBase+"-"+index+"-MENU").attributes.getNamedItem("class").nodeValue = "tabact"; + } else { + DTM_origClass = "tabact"; + } + top.DTM_currentTabs[idBase+"-"+index] = 1; + } + } + } + + function DTM_mouseOver(obj) { // + DTM_origClass = obj.attributes.getNamedItem('class').nodeValue; + obj.attributes.getNamedItem('class').nodeValue += "_over"; + } + + function DTM_mouseOut(obj) { // + obj.attributes.getNamedItem('class').nodeValue = DTM_origClass; + DTM_origClass = ""; + } +++ t3lib/class.t3lib_tabmenus.php (working copy) @@ -1 +1,324 @@ + + */ + +require_once(PATH_t3lib.'class.t3lib_iconworks.php'); +class t3lib_tabMenus { + + var $modSharedTSconfig=array(); // mod.SHARED related configurations + var $PageTSConfig=array(); // TS Config for pages + + + /** + * Creates a tab menu from an array definition + * + * Returns a tab menu for a module + * Requires the JS function jumpToUrl() to be available + * + * @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=... + * @param string $elementName it the form elements name, probably something like "SET[...]" + * @param string $currentValue is the value to be selected currently. + * @param array $menuItems is an array with the menu items for the selector box + * @param string $script is the script to send the &id to, if empty it's automatically found + * @param string $addParams is additional parameters to pass to the script. + * @return string HTML code for tab menu + * @author Rene Fritz + */ + function getTabMenu($mainParams,$elementName,$currentValue,$menuItems,$script='',$addparams='') { + $content=''; + if (is_array($menuItems)) { + if (!is_array($mainParams)) { + $mainParams = array('id' => $mainParams); + } + $mainParams = t3lib_div::implodeArrayForUrl('',$mainParams); + if (!$script) {$script=basename(PATH_thisScript);} + $menuDef = array(); + foreach($menuItems as $value => $label) { + $menuDef[$value]['isActive'] = !strcmp($currentValue,$value); + $menuDef[$value]['label'] = t3lib_div::deHSCentities(htmlspecialchars($label)); + $menuDef[$value]['url'] = htmlspecialchars($script.'?'.$mainParams.$addparams.'&'.$elementName.'='.$value); + } + $content = t3lib_tabMenus::getTabMenuRaw($menuDef); + } + return $content; + } + /** + * Creates the HTML content for the tab menu + * + * @param array Menu items for tabs + * @return string Table HTML + * @access private + */ + function getTabMenuRaw($menuItems) { + $content=''; + if (is_array($menuItems)) { + $options=''; + $count = count($menuItems); + $widthLeft = 1; + $addToAct = 5; + $widthRight = max (1,floor(30-pow($count,1.72))); + $widthTabs = 100 - $widthRight - $widthLeft; + $widthNo = floor(($widthTabs - $addToAct)/$count); + $addToAct = max ($addToAct,$widthTabs-($widthNo*$count)); + $widthAct = $widthNo + $addToAct; + $widthRight = 100 - ($widthLeft + ($count*$widthNo) + $addToAct); + $first=true; + foreach($menuItems as $id => $def) { + $isActive = $def['isActive']; + $class = $isActive ? 'tabact' : 'tab'; + $width = $isActive ? $widthAct : $widthNo; + // @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. + $label = $def['label']; + $url = htmlspecialchars($def['url']); + $params = $def['addParams']; + if($first) { + $options.= ' +
'; + } else { + $options.=' + '; + } + $first=false; + } + if ($options) { + $content .= ' + +
'.$label.''.$label.'
+ + + '.$options.' + + +
  
+
'; + } + } + return $content; + } + + /** + * Creates a DYNAMIC tab-menu where the tabs are switched between with DHTML. + * Should work in MSIE, Mozilla, Opera and Konqueror. On Konqueror I did find a serious problem: