// This is just a tiny library which lets you easily manipulate with // tabset controls in your projects. // // This lib is FREEWARE. You can use it in any project. // // *********************************************************************** // ******************** DEFAULT OPTIONS BLOCK : START ******************** // Default image type. JPG won't work out since it has no transparency. // 0-PNG; 1-GIF; $_tab_def_type = 0; // Default style [0|1|2] $_tab_def_style = 2; // ******************** DEFAULT OPTIONS BLOCK : FINISH ******************* // *********************************************************************** // Sample menu array. Everything's just in plain english: /* $_tab_example_ = array( "_bgcolor" => "ffffff", "_fgcolor" => "dddddd", "_curcolor" => "ffffff", "_class" => "topmenu", "_nounder" => 0, "_style" => 2, "item1" => array( "title" => "Item1", "url" => "index.php", "style" => 0 ), "item2" => array( "title" => "Item 2", "url" => "index.php", "desc" => "Description of Item 2 here", "style" => 1 ), "huh, new item" => array( "title" => "Item3", "url" => "index.php?q=1", "fgcolor" => "aaaaaa", "class" => "topmenu" ), "wow!" => array( "title" => "Item4", "url" => "index.php?q=2" ), "Jeez! that's enough!" => array( "title" => "Item5", "url" => "index.php?q=3" ) ); */ //*************************************************************************** function tabUpper($M) { global $_tab_def_style; $out = ""; if(sizeof($M) < 1) return false; $ic = tab_Items($M); $un = (isset($M['_nounder']) && $M['_nounder']<>0) ? 0 : 1; $out .= (""); reset($M); while(list($k,$v) = each($M)) { if(substr($k,0,1) == "_") continue; if(isset($v['style'])) $st = $v['style']; elseif(isset($M['_style'])) $st = $M['_style']; else $st = $_tab_def_style; $bg = (isset($v['bgcolor']) && !empty($v['bgcolor'])) ? $v['bgcolor'] : $M['_bgcolor']; $fg = (isset($v['fgcolor']) && !empty($v['fgcolor'])) ? $v['fgcolor'] : $M['_fgcolor']; if ((isset($v['active']) && $v['active']) && (isset($M['_curcolor']))) $fg = $M['_curcolor']; $rs = (isset($v['active']) && $v['active']) ? (($ic == 1) ? 2 : 3) : 2; $out .= (""); $out .= (""); $out .= (""); } $out .= (""); reset($M); while(list($k,$v) = each($M)) { if(substr($k,0,1) == "_") continue; $fg = (isset($v['fgcolor']) && !empty($v['fgcolor'])) ? $v['fgcolor'] : $M['_fgcolor']; if ((isset($v['active']) && $v['active']) && (isset($M['_curcolor']))) $fg = $M['_curcolor']; $rs = (isset($v['active']) && $v['active']) ? (($ic == 1) ? 1 : 2) : 1; if(isset($M['_class'])) $cl = "class='".((isset($v['active']) && $v['active']) ? "cur":"").$M['_class']."'"; else $cl=""; if(isset($v['class'])) $cl = "class='".((isset($v['active']) && $v['active']) ? "cur":"").$v['class']."'"; $ds = (isset($v['desc'])) ? "title='".$v['desc']."'" : ""; $out .= @(""); } if($un) { if(!(($ic == 1) && (strlen(tab_GetActiveName($M))>0))) $out .= (""); reset($M); while(list($k,$v) = each($M)) { if(substr($k,0,1) == "_") continue; if(isset($v['active']) && $v['active']) continue; $out .= (""); } } $out .= ("
"); $out .= ("

"); $out .= ("
".$v['title'].""); $out .= ("


"); return $out; } //*************************************************************************** function tabLower($M) { global $_tab_def_style; $out = ""; if(sizeof($M) < 1) return false; $out .= (""); $un = (isset($M['_nounder']) && $M['_nounder']) ? 0 : 1; if($un) { reset($M); while(list($k,$v) = each($M)) { if(substr($k,0,1) == "_") continue; if(isset($v['active']) && $v['active']) { $bg = (isset($v['bgcolor'])) ? $v['bgcolor'] : $M['_bgcolor']; $fg = (isset($v['fgcolor'])) ? $v['fgcolor'] : $M['_fgcolor']; if (isset($M['_curcolor'])) $fg = $M['_curcolor']; if(isset($M['_class'])) $cl = "class='".(($v['active']) ? "cur":"").$M['_class']."'"; else $cl=""; if(isset($v['class'])) $cl = "class='".(($v['active']) ? "cur":"").$v['class']."'"; $ds = (isset($v['desc'])) ? "title='".$v['desc']."'" : ""; if(isset($v['style'])) $st = $v['style']; elseif(isset($M['_style'])) $st = $M['_style']; else $st = $_tab_def_style; $out .= (""); $out .= (""); $out .= (""); } else $out .= (""); } $out .= (""); } reset($M); while(list($k,$v) = each($M)) { if(substr($k,0,1) == "_") continue; if((isset($v['active']) && $v['active']) && ($un)) continue; $bg = (isset($v['bgcolor']) && !empty($v['bgcolor'])) ? $v['bgcolor'] : $M['_bgcolor']; $fg = (isset($v['fgcolor']) && !empty($v['fgcolor'])) ? $v['fgcolor'] : $M['_fgcolor']; if ((isset($v['active']) && $v['active']) && (isset($M['_curcolor']))) $fg = $M['_curcolor']; $rs = (isset($v['active']) && $v['active']) ? 2 : 1; if(isset($M['_class'])) $cl = "class='".((isset($v['active']) && $v['active']) ? "cur":"").$M['_class']."'"; else $cl=""; if(isset($v['class'])) $cl = "class='".((isset($v['active']) && $v['active']) ? "cur":"").$v['class']."'"; $ds = (isset($v['desc'])) ? "title='".$v['desc']."'" : ""; if(isset($v['style'])) $st = $v['style']; elseif(isset($M['_style'])) $st = $M['_style']; else $st = $_tab_def_style; $out .= (""); $out .= (""); $out .= (""); } $out .= (""); reset($M); while(list($k,$v) = each($M)) { if(substr($k,0,1) == "_") continue; $out .= (""); } $out .= ("
"); $out .= ("
".$v['title']."
"); $out .= ("
"); $out .= ("

"); $out .= ("
".$v['title']."
"); $out .= ("
"); $out .= ("

"); return $out; } //*************************************************************************** function tab_getActiveName($M) { if(sizeof($M) < 1) return ""; $rst = ""; reset($M); while(list($k,$v) = each($M)) if(substr($k,0,1) == "_") continue; elseif($v['active']) { $rst = $k; break; } return $rst; } //*************************************************************************** function tab_Items($M) { $cnt = 0; reset($M); while(list($k,$v) = each($M)) if(substr($k,0,1) == "_") continue; else $cnt++; return $cnt; } extract($_REQUEST); //*************************************************************************** if(isset($_tab_or)) { if(substr($_tab_bg,0,1)=="#") $_tab_bg = substr($_tab_bg,1); while(strlen($_tab_bg) < 6) $_tab_bg = "0".$_tab_bg; $im = ImageCreate(6, 6); $tbg = ImageColorAllocate($im,253,254,255); $bl = ImageColorAllocate($im,0,0,0); $gr = ImageColorAllocate($im, 128,128,128); $bg = ImageColorAllocate($im, base_convert(substr($_tab_bg,0,2),16,10), base_convert(substr($_tab_bg,2,2),16,10), base_convert(substr($_tab_bg,4,2),16,10)); ImageColorTransparent($im, $tbg); switch($_tab_or) { case 0 : case 16 : { ImageLine($im, 5,0,1,4, $bl); ImageLine($im, 1,4,1,5, $bl); ImageFill($im, 0,0, $bg); break; } case 1 : { ImageLine($im, 0,0,4,4, $bl); ImageLine($im, 4,4,4,5, $bl); ImageFill($im, 5,0, $bg); break; } case 2 : case 18 : { ImageLine($im, 1,0,1,1, $bl); ImageLine($im, 1,1,5,5, $bl); ImageFill($im, 0,5, $bg); break; } case 3 : { ImageLine($im, 0,5,4,1, $bl); ImageLine($im, 4,1,4,0, $bl); ImageFill($im, 5,5, $bg); break; } case 4 : case 6 : case 12 : case 14 : case 20 : case 22 : { ImageLine($im, 0,0,0,5, $bg); ImageLine($im, 1,0,1,5, $bl); break; } case 5 : case 7 : case 13 : case 15 : case 21 : case 23 : { ImageLine($im, 5,0,5,5, $bg); ImageLine($im, 4,0,4,5, $bl); break; } case 8 : { ImageLine($im, 5,0,4,0, $bl); ImageLine($im, 3,1,1,3, $bl); ImageLine($im, 1,4,1,5, $bl); ImageSetPixel($im, 2,1, $bl); ImageFill($im, 0,0, $bg); break; } case 9 : { ImageLine($im, 0,0,1,0, $bl); ImageLine($im, 2,1,4,3, $bl); ImageLine($im, 4,4,4,5, $bl); ImageSetPixel($im, 3,1, $bl); ImageFill($im, 5,0, $bg); break; } case 10 : { ImageLine($im, 1,0,1,1, $bl); ImageLine($im, 1,2,3,4, $bl); ImageLine($im, 4,5,5,5, $bl); ImageSetPixel($im, 2,4, $bl); ImageFill($im, 0,5, $bg); break; } case 11 : { ImageLine($im, 4,0,4,1, $bl); ImageLine($im, 4,2,2,4, $bl); ImageLine($im, 0,5,1,5, $bl); ImageSetPixel($im, 3,4, $bl); ImageFill($im, 5,0, $bg); break; } case 17 : { ImageLine($im, 0,0,4,0, $bl); ImageLine($im, 4,1,4,5, $bl); ImageFill($im, 5,0, $bg); break; } case 19 : { ImageLine($im, 0,5,4,5, $bl); ImageLine($im, 4,4,4,0, $bl); ImageFill($im, 5,5, $bg); break; } } header("Expires: ".date('r', time()+(3600*365))); switch($_tab_def_type) { case 0 : { ImagePNG($im); break; } case 1 : { ImageGIF($im); break; } } ImageDestroy($im); } ?>