rev |
line source |
meillo@0
|
1 <!-- Nav -->
|
meillo@0
|
2 <ul id="nav">
|
meillo@0
|
3
|
meillo@0
|
4 <?php
|
meillo@2
|
5 // all nodes that are displayed in the nav
|
meillo@2
|
6 global $nodesDisplayed;
|
meillo@2
|
7 $nodesDisplayed = '';
|
meillo@2
|
8
|
meillo@2
|
9
|
meillo@0
|
10 // build nav tree
|
meillo@0
|
11 echo ' '. navtree(0) ."\n";
|
meillo@0
|
12
|
meillo@0
|
13
|
meillo@2
|
14 // find nodes without existing parent (orphans)
|
meillo@0
|
15 $sql = sprintf("
|
meillo@0
|
16 select distinct
|
meillo@0
|
17 idParent
|
meillo@0
|
18 from %sOwls
|
meillo@0
|
19 where
|
meillo@0
|
20 idParent not in (select id from %sOwls)
|
meillo@0
|
21 and idParent != 0 -- not the real root
|
meillo@0
|
22 order by name asc
|
meillo@0
|
23 ",
|
meillo@0
|
24 DB_PREFIX,
|
meillo@0
|
25 DB_PREFIX
|
meillo@0
|
26 );
|
meillo@0
|
27 $result = mysql_query($sql) or die(mysql_error());
|
meillo@0
|
28 unset($sql);
|
meillo@0
|
29
|
meillo@0
|
30 // output only if there are orphans
|
meillo@0
|
31 if (mysql_num_rows($result)) {
|
meillo@0
|
32 echo ' <li id="orphans">orphans<ul>';
|
meillo@0
|
33 // output subtree for every orphan
|
meillo@0
|
34 while($row = mysql_fetch_array($result)) {
|
meillo@0
|
35 echo navtree($row['idParent']);
|
meillo@0
|
36 }
|
meillo@0
|
37 unset($row);
|
meillo@0
|
38 mysql_free_result($result);
|
meillo@0
|
39
|
meillo@3
|
40 echo '</ul></li>'."\n";
|
meillo@0
|
41 }
|
meillo@2
|
42
|
meillo@2
|
43
|
meillo@2
|
44
|
meillo@2
|
45 // find broken nodes - nodes not displayed in nav or orphans (i.e. rings)
|
meillo@2
|
46 $sql = sprintf("
|
meillo@2
|
47 select
|
meillo@2
|
48 id, name
|
meillo@2
|
49 from %sOwls
|
meillo@2
|
50 where
|
meillo@2
|
51 id not in ( %s )
|
meillo@2
|
52 order by name asc
|
meillo@2
|
53 ",
|
meillo@2
|
54 DB_PREFIX,
|
meillo@2
|
55 substr($nodesDisplayed, 2)
|
meillo@2
|
56 );
|
meillo@2
|
57 $result = mysql_query($sql) or die(mysql_error());
|
meillo@2
|
58 unset($sql);
|
meillo@2
|
59
|
meillo@2
|
60 // output only if there are broken nodes
|
meillo@2
|
61 if (mysql_num_rows($result)) {
|
meillo@2
|
62 echo ' <li id="broken">broken<ul>';
|
meillo@2
|
63 // output list of nodes (no tree, cause there may be rings!)
|
meillo@2
|
64 while($row = mysql_fetch_array($result)) {
|
meillo@2
|
65 echo '<li><a href="'. $row['id'] .'"'. (($_GET['id'] == $row['id']) ? ' id="selected"' : '') .'>'. $row['name'] .'</a></li>';
|
meillo@2
|
66 }
|
meillo@2
|
67 unset($row);
|
meillo@2
|
68 mysql_free_result($result);
|
meillo@2
|
69
|
meillo@3
|
70 echo '</ul></li>'."\n";
|
meillo@2
|
71 }
|
meillo@2
|
72
|
meillo@0
|
73 ?>
|
meillo@0
|
74
|
meillo@0
|
75 <li id="login">
|
meillo@0
|
76 <?php
|
meillo@0
|
77 if ($lsys->loggedIn()) {
|
meillo@0
|
78 echo ' <a href="'. $_GET['id'] .'logout" style="color: #c00;">logout</a>';
|
meillo@0
|
79 } else {
|
meillo@0
|
80 ?>
|
meillo@0
|
81 <form name="loginform" action="<?php echo $_GET['id']; ?>login" method="post" enctype="multipart/form-data">
|
meillo@0
|
82 <input name="login_loginname" type="text" />
|
meillo@0
|
83 <input name="login_password" type="password" />
|
meillo@0
|
84 <input name="login" type="submit" value="login" style="padding: 0; cursor: pointer;" />
|
meillo@0
|
85 </form>
|
meillo@0
|
86 <?php
|
meillo@0
|
87 }
|
meillo@0
|
88 ?>
|
meillo@0
|
89 </li>
|
meillo@0
|
90
|
meillo@0
|
91 </ul>
|
meillo@0
|
92
|
meillo@0
|
93 <?php
|
meillo@0
|
94
|
meillo@2
|
95
|
meillo@8
|
96 /**
|
meillo@8
|
97 * recursive function creates the output for the nav tree
|
meillo@8
|
98 *
|
meillo@8
|
99 * @param $root the id of the parent of the root node
|
meillo@8
|
100 * @return string HTML output that shows the nav tree
|
meillo@8
|
101 */
|
meillo@0
|
102 function navtree($root) {
|
meillo@0
|
103 // fetch subcategories
|
meillo@2
|
104 $sql = sprintf("
|
meillo@2
|
105 select
|
meillo@2
|
106 id, idParent, name
|
meillo@2
|
107 from %sOwls
|
meillo@2
|
108 where
|
meillo@2
|
109 idParent = $root
|
meillo@2
|
110 order by name asc
|
meillo@2
|
111 ",
|
meillo@2
|
112 DB_PREFIX
|
meillo@2
|
113 );
|
meillo@2
|
114 $result = mysql_query($sql) or die(mysql_error());
|
meillo@2
|
115 unset($sql);
|
meillo@0
|
116
|
meillo@0
|
117 $return = '';
|
meillo@0
|
118 while($row = mysql_fetch_array($result)) {
|
meillo@2
|
119 // add to list of displayed nodes
|
meillo@2
|
120 global $nodesDisplayed;
|
meillo@2
|
121 $nodesDisplayed .= ', '. $row['id'];
|
meillo@2
|
122
|
meillo@0
|
123 $return .= '<li><a href="'. $row['id'] .'"'. (($_GET['id'] == $row['id']) ? ' id="selected"' : '') .'>'. $row['name'] .'</a>';
|
meillo@0
|
124 if ($row['id'] != $row['idParent']) {
|
meillo@0
|
125 $subtree = navtree($row['id']);
|
meillo@0
|
126 if (!empty($subtree)) {
|
meillo@2
|
127 #$return .= ' <a href="javascript:toggleVisibility(\''. $row['id'] .'\')" id="ctrl'. $row['id'] .'" style="display: none;">-</a>';
|
meillo@0
|
128 $return .= '<ul id="node'. $row['id'] .'">'. $subtree .'</ul>';
|
meillo@0
|
129 }
|
meillo@0
|
130 unset($subtree);
|
meillo@0
|
131 }
|
meillo@0
|
132 $return .= '</li>';
|
meillo@0
|
133 }
|
meillo@0
|
134 unset($row);
|
meillo@0
|
135 mysql_free_result($result);
|
meillo@0
|
136
|
meillo@0
|
137 // return
|
meillo@0
|
138 return $return;
|
meillo@0
|
139 }
|
meillo@0
|
140
|
meillo@0
|
141 ?>
|
meillo@0
|
142
|
meillo@0
|
143 <!-- Content -->
|