<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Designers Place | CMS</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<div id="head"></div>
<div id="navi">
<?php include_once("db_menu.php");
$sql=mysql_query("SELECT `menu_ID`, `menu_name` FROM `menu` WHERE `menu_topid`=0 AND `menu_display` != 0 ORDER BY `menu_position` ASC") or die("Fehler1".mysql_error());
$nav_array = array();
$i = 0;
while ($nav_data = mysql_fetch_array($sql)) {
echo $nav_data["menu_ID"];
echo $nav_data["menu_name"];
$i++;
}
$nav_id = (int) $_GET["nav_id"];
if ($nav_id <= 0) {
$nav_id = $nav_array[0]['menu_ID'];
}
$sql=mysql_query("SELECT * FROM `menu` WHERE `menu_ID` = $nav_id") or die("Fehler2".mysql_error());
$page_data = mysql_fetch_array($sql);
$page_id = $page_data["menu_page"];
$child_array = array();
$root_array = array();
//Die Stufe beginnt von unten zu zählen, statt von oben. Wird am Schluss umgerechnet
$invlevel = 1;
$sql=mysql_query("SELECT `menu_ID`, `menu_topid`, `menu_name` FROM `menu` WHERE `menu_topid` = $nav_id and `menu_display` != 0 ORDER BY `menu_position`") or die("Fehler3".mysql_error());
$i = 0;
while ($subnav_data = mysql_fetch_array($sql)) {
$child_array[$i] = array('menu_ID'=>$subnav_data["menu_ID"], 'menu_name'=>$subnav_data["menu_name"], 'menu_topid'=>$subnav_data["menu_topid"], 'level'=>$invlevel);
$i++;
}
//Die nächsthöhere TopID
$next_topid = $page_data["menu_topid"];
//Solange durchlaufen lassen bis obersten Navitationsteile erreicht sind (top_id == 0)
while (($next_topid != 0 || $next_topid != false)) {
if(empty($child_array[0]["menu_topid"])) {
$top_id = $nav_id;
} else {
$top_id = $child_array[0]["menu_topid"];
}
$invlevel++;
$i = 0; //Zähler in der Schlaufe
$sql=mysql_query("SELECT `menu_ID`, `menu_topid`, `menu_name` FROM `menu` WHERE `menu_topid` = $next_topid ORDER BY `menu_position` ASC") or die("Fehler4".mysql_error());
//Die Tabelle auslesen
while($subnav_data = mysql_fetch_array($sql)) {
$root_array[$i] = array('menu_ID'=>$subnav_data["menu_ID"], 'menu_name'=>$subnav_data["menu_name"], 'menu_topid'=>$subnav_data["menu_topid"], 'level'=>$invlevel);
if($root_array[$i]["menu_ID"] == $top_id) {
$root_array = array_merge($root_array, $child_array);
//Minus 1, weil es sonst einen Zwischenraum gibt. Z.B. $root_array[2], dann $root_array[4]
$i = count($root_array) - 1;
}
$i++;
}
$child_array = $root_array;
$root_array = array();
//Hier wird noch mit der alten $next_topid gerechnet. Die Topid vom höheren Menu wird gelesen
$sql=mysql_query("SELECT `menu_topid` FROM `menu` WHERE `menu_ID` = $next_topid LIMIT 1") or die("Fehler5".mysql_error());
$subnav_data = mysql_fetch_array($sql);
//Neues $next_topid
$next_topid = $subnav_data["menu_topid"];
}
$anzlevel = $invlevel;
$invlevel = 0;
$number = count($child_array);
//Die Umrechnunsschleife, die Levels werden neu gesetzt: Das Höchste jetzt das Tiefste und umgekehrt
for($i = 0; $i < $number; $i++) {
$invlevel = $child_array[$i]['level'];
$child_array[$i]['level'] = $anzlevel - $invlevel + 1;
}
//Die Subnav_array mit dem vollständigen child_array füllen
$subnav_array = $child_array;
?>
</div>
<div id="content">
<?php include_once("db_content.php");
$sql=mysql_query("SELECT * FROM `content` WHERE `content_ID` = $page_id") or die("Fehler6".mysql_error());
$data = mysql_fetch_array($sql);
$content_title = $data["content_title"];
$content_text = $data["content_text"];
if ($content_title == "" && $content_text == "") {
$content_title = "JClub-Noch kein Inhalt";
$content_text = "Keine Daten gefunden";
}
?>
</div>
</div>
</body>
</html>