owls

view Includes/Nav.inc.php @ 1:6268cdb5fc0b

Added tag owls-0.5 for changeset 3021ce32ee142c32840dbc01d6db34487f9daab8
author "Meillo r e t u r n s <meillo@marmaro.de>"
date Sun, 03 Dec 2006 22:32:33 +0100
parents
children ab74e95a8040
line source
1 <!-- Nav -->
2 <ul id="nav">
4 <?php
5 // build nav tree
6 echo ' '. navtree(0) ."\n";
9 // find unmatched nodes (orphans)
10 $sql = sprintf("
11 select distinct
12 idParent
13 from %sOwls
14 where
15 idParent not in (select id from %sOwls)
16 and idParent != 0 -- not the real root
17 -- and idParent != id -- avoid endless recursion
18 order by name asc
19 ",
20 DB_PREFIX,
21 DB_PREFIX
22 );
23 $result = mysql_query($sql) or die(mysql_error());
24 unset($sql);
26 // output only if there are orphans
27 if (mysql_num_rows($result)) {
28 echo ' <li id="orphans">orphans<ul>';
29 // output subtree for every orphan
30 while($row = mysql_fetch_array($result)) {
31 echo navtree($row['idParent']);
32 }
33 unset($row);
34 mysql_free_result($result);
36 echo '</ul></li>';
37 }
38 ?>
40 <li id="login">
41 <?php
42 if ($lsys->loggedIn()) {
43 echo ' <a href="'. $_GET['id'] .'logout" style="color: #c00;">logout</a>';
44 } else {
45 ?>
46 <form name="loginform" action="<?php echo $_GET['id']; ?>login" method="post" enctype="multipart/form-data">
47 <input name="login_loginname" type="text" />
48 <input name="login_password" type="password" />
49 <input name="login" type="submit" value="login" style="padding: 0; cursor: pointer;" />
50 </form>
51 <?php
52 }
53 ?>
54 </li>
56 </ul>
58 <?php
60 function navtree($root) {
61 // fetch subcategories
62 $result = mysql_query("select * from ". DB_PREFIX ."Owls where idParent = $root order by name asc");
64 $return = '';
65 while($row = mysql_fetch_array($result)) {
66 $return .= '<li><a href="'. $row['id'] .'"'. (($_GET['id'] == $row['id']) ? ' id="selected"' : '') .'>'. $row['name'] .'</a>';
67 if ($row['id'] != $row['idParent']) {
68 $subtree = navtree($row['id']);
69 if (!empty($subtree)) {
70 $return .= '&nbsp;&nbsp;<a href="javascript:toggleVisibility(\''. $row[id] .'\')" id="ctrl'. $row['id'] .'" style="display: none;">-</a>';
71 $return .= '<ul id="node'. $row['id'] .'">'. $subtree .'</ul>';
72 }
73 unset($subtree);
74 }
75 $return .= '</li>';
76 }
77 unset($row);
78 mysql_free_result($result);
80 // return
81 return $return;
82 }
84 ?>
86 <!-- Content -->