<?php
error_reporting
(E_ALL);
ini_set('display_errors'TRUE); // evtl. hilfreich

require_once "./conf.php";
require_once 
"./kategorie_recursiv.php";





$baum = & new kategorie_recursiv(MYSQL_TABLE_PREFIX.'kategoriebaum');


// echo baum($baum);

echo '<br>';

$alle $baum->getAllNodes();

$pfad = array();
if(isset(
$_REQUEST['katid']))
{
  
$id $_REQUEST['katid'];
  do
  {
    
$pfad[] = $id;
    
$id $alle['byId'][$id]['parent'];
  }while(isset(
$alle['byId'][$id]));
}
$pfad array_reverse($pfad);


// var_export($temp);
//$alle['byParent'][0] $alle['byId'][$id]['name']

?>
<html>
<head>

<style type="text/css">
<!--
.navcontainer
{
  /*avoid gap after li in ie6 by setting width*/
  width: 130px;
  font-size: 11px;
  font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
  margin-left: 10px;
}

.navcontainer ul
{
  list-style-type: none;
  margin-left: 8px;
  padding-left: 0;
}

.navlist a
{
  display: block;
  color: #8592BB;
  padding: 1px 0 1px 8px;
}

/*boxmodel hack. http://css-discuss.incutio.com/?page=BoxModelHack SBMH*/
.navlist a { width: 114px; }

.navlist a, .navlist a:visited
{
  border-left: 8px solid #CCCCCC;
  background: #FFFFFF;
  color: #9C9C9C;
  text-decoration: none;
}

.navlist a:hover
{
  border-left: 8px solid #283D82;
  text-decoration: underline;
}

.navlist a.current:hover
{
  border-left: 8px solid #CCCCCC;
  text-decoration: underline;
}


a.current, a:visited.current
{
  border-left: 8px solid #283D82;
  /* background: #F3F5FC; */
  color: #283D82;
  text-decoration: none;
}
//-->
</style>

</head>
  <body>
<?php

$temp 
= array();
$temp[]='<a href="'.$_SERVER['SCRIPT_NAME'].'">Home</a>';
  foreach(
$pfad as $id)
  {
    
$url $_SERVER['SCRIPT_NAME'].'?katid='.$id;
  
$temp[]='<a href="'.$url.'">'.$alle['byId'][$id]['name'].'</a>';
  }
echo 
implode(' &gt;&gt; ',$temp);



function 
menu(&$alle,&$pfad,$level=0)
{
  
$result '';
  if(isset(
$alle['byParent'][$level]))
  {
    
$gruppe $alle['byParent'][$level];
    
$result .= '<ul class="navlist">'."\n";
    foreach(
$gruppe as $id)
    {
      
$result .= "\t".'<li>'."\n";
      
$aktiv '';
      if(
in_array($id,$pfad)) $aktiv ' class="current" ';
      
$url $_SERVER['SCRIPT_NAME'].'?katid='.$id;
      
$result .= "\t\t".'<a href="'.$url.'" '.$aktiv.'>'.$alle['byId'][$id]['name'].'</a>'."\n";
      
// $parent= $alle['byId'][$id]['parent'];
      
$parent$id;
  
//     $result .= $parent;
       
if(!= $parent && in_array($id,$pfad))
          
$result .= menu($alle,$pfad,$id);
      
$result .= "\t"."</li>\n";
    }
    
$result .= "</ul>\n";
  }
  return 
$result;
}

?>
<hr>
    <div class="navcontainer">
<?php
 
echo menu($alle,$pfad);

?>
<pre>
 

<?php
var_export
($alle);

?>

  </pre> </div>
  </body>
</html>