owls
diff Includes/Nav.inc.php @ 2:ab74e95a8040
added display of broken nodes; Header and Footer in Owls.php now; added logos
author | "Meillo r e t u r n s <meillo@marmaro.de>" |
---|---|
date | Thu, 07 Dec 2006 21:04:30 +0100 |
parents | 3021ce32ee14 |
children | 92a8978e68c5 |
line diff
1.1 --- a/Includes/Nav.inc.php Sun Dec 03 22:32:33 2006 +0100 1.2 +++ b/Includes/Nav.inc.php Thu Dec 07 21:04:30 2006 +0100 1.3 @@ -2,11 +2,16 @@ 1.4 <ul id="nav"> 1.5 1.6 <?php 1.7 + // all nodes that are displayed in the nav 1.8 + global $nodesDisplayed; 1.9 + $nodesDisplayed = ''; 1.10 + 1.11 + 1.12 // build nav tree 1.13 echo ' '. navtree(0) ."\n"; 1.14 1.15 1.16 - // find unmatched nodes (orphans) 1.17 + // find nodes without existing parent (orphans) 1.18 $sql = sprintf(" 1.19 select distinct 1.20 idParent 1.21 @@ -14,7 +19,6 @@ 1.22 where 1.23 idParent not in (select id from %sOwls) 1.24 and idParent != 0 -- not the real root 1.25 --- and idParent != id -- avoid endless recursion 1.26 order by name asc 1.27 ", 1.28 DB_PREFIX, 1.29 @@ -35,6 +39,37 @@ 1.30 1.31 echo '</ul></li>'; 1.32 } 1.33 + 1.34 + 1.35 + 1.36 + // find broken nodes - nodes not displayed in nav or orphans (i.e. rings) 1.37 + $sql = sprintf(" 1.38 + select 1.39 + id, name 1.40 + from %sOwls 1.41 + where 1.42 + id not in ( %s ) 1.43 + order by name asc 1.44 + ", 1.45 + DB_PREFIX, 1.46 + substr($nodesDisplayed, 2) 1.47 + ); 1.48 + $result = mysql_query($sql) or die(mysql_error()); 1.49 + unset($sql); 1.50 + 1.51 + // output only if there are broken nodes 1.52 + if (mysql_num_rows($result)) { 1.53 + echo ' <li id="broken">broken<ul>'; 1.54 + // output list of nodes (no tree, cause there may be rings!) 1.55 + while($row = mysql_fetch_array($result)) { 1.56 + echo '<li><a href="'. $row['id'] .'"'. (($_GET['id'] == $row['id']) ? ' id="selected"' : '') .'>'. $row['name'] .'</a></li>'; 1.57 + } 1.58 + unset($row); 1.59 + mysql_free_result($result); 1.60 + 1.61 + echo '</ul></li>'; 1.62 + } 1.63 + 1.64 ?> 1.65 1.66 <li id="login"> 1.67 @@ -57,17 +92,34 @@ 1.68 1.69 <?php 1.70 1.71 + 1.72 + 1.73 function navtree($root) { 1.74 // fetch subcategories 1.75 - $result = mysql_query("select * from ". DB_PREFIX ."Owls where idParent = $root order by name asc"); 1.76 + $sql = sprintf(" 1.77 + select 1.78 + id, idParent, name 1.79 + from %sOwls 1.80 + where 1.81 + idParent = $root 1.82 + order by name asc 1.83 + ", 1.84 + DB_PREFIX 1.85 + ); 1.86 + $result = mysql_query($sql) or die(mysql_error()); 1.87 + unset($sql); 1.88 1.89 $return = ''; 1.90 while($row = mysql_fetch_array($result)) { 1.91 + // add to list of displayed nodes 1.92 + global $nodesDisplayed; 1.93 + $nodesDisplayed .= ', '. $row['id']; 1.94 + 1.95 $return .= '<li><a href="'. $row['id'] .'"'. (($_GET['id'] == $row['id']) ? ' id="selected"' : '') .'>'. $row['name'] .'</a>'; 1.96 if ($row['id'] != $row['idParent']) { 1.97 $subtree = navtree($row['id']); 1.98 if (!empty($subtree)) { 1.99 - $return .= ' <a href="javascript:toggleVisibility(\''. $row[id] .'\')" id="ctrl'. $row['id'] .'" style="display: none;">-</a>'; 1.100 + #$return .= ' <a href="javascript:toggleVisibility(\''. $row['id'] .'\')" id="ctrl'. $row['id'] .'" style="display: none;">-</a>'; 1.101 $return .= '<ul id="node'. $row['id'] .'">'. $subtree .'</ul>'; 1.102 } 1.103 unset($subtree);