*/ 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.= ' '.$label.''; } else { $options.=' '.$label.''; } $first=false; } if ($options) { $content .= ' '.$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: