url=$u; $this->text=$t; } } function LB_LeftHeader($hdr) { printf('

%s

',$hdr); } function LB_TopLink($url,$txt) { printf('',$url,$txt); } function LB_SubLink($url,$txt) { printf('
  • %s
  • ',$url,$txt); } function LB_OpenLink(&$is_open) { if (!$is_open) { $is_open = TRUE; echo ''; echo ''; } } function LeftBar($file, $context = '') { $fp = fopen($file,'r'); if (!$fp) { printf('

    Missing leftbar config %s!

    ',$file); return; } $links = array(); $curcontext = ''; $in_link = FALSE; $in_sub = FALSE; while (!feof($fp)) { $line = fgets($fp,1024); $line = rtrim($line); if (strlen($line)>0 && substr($line,0,1)!='#') { $tok = explode("\t",$line); switch($tok[0]) { case 'def': if (count($tok)==4) { $links[$tok[1]] = new LB_LinkDef($tok[3],$tok[2]); } else { printf('

    WARNING: Bad "def"

    '); } break; case 'set': if (count($tok)==2) { LB_CloseSub($in_sub); LB_CloseLink($in_link); LB_LeftHeader($tok[1]); } else { printf('

    WARNING: Bad "set"

    '); } break; case 'link': if (count($tok)==3) { LB_CloseSub($in_sub); LB_OpenLink($in_link); $ldef = $links[$tok[1]]; $curcontext = $tok[2]; LB_TopLink($ldef->url,$ldef->text); } else { printf('

    WARNING: Bad "link"

    '); } break; case 'sub': if (count($tok)==2) { if ($curcontext == $context) { LB_OpenSub($in_sub); $ldef = $links[$tok[1]]; LB_SubLink($ldef->url,$ldef->text); } } else { printf('

    WARNING: Bad "sub"

    '); } break; default: printf('

    WARNING: Bad line "%s"

    ',$line); break; } } } LB_CloseSub($in_sub); LB_CloseLink($in_link); fclose($fp); } ?>