blob: fbaf8e1a9db551c2b99bbc03a1f6a6e7e6a75ee6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
<?PHP
require_once('code/links.inc.php');
class Nav {
var $entries = array();
function Nav() {
$res = $GLOBALS['db']->Execute('SELECT * FROM nav ORDER BY id');
while(!$res->EOF) {
$this->entries[$res->fields[0]] = new NavEntry($res->fields[1], $res->fields[2], $res->fields[3]);
$res->MoveNext();
}
foreach($this->entries as $entry)
if($entry->parent != 0)
$this->entries[$entry->parent]->Add($entry);
}
function ParseEntries() {
$ret = '<ul>';
foreach($this->entries as $entry)
if($entry->parent == 0)
$ret .= $entry->Parse();
$ret .= '</ul>';
return $ret;
}
}
class NavEntry {
var $parent, $text, $link;
var $children = array();
function NavEntry($parent, $text, $link) {
$this->parent = $parent;
$this->text = $text;
$this->link = $link;
}
function Add($entry) {
array_push($this->children, $entry);
}
function Parse() {
$ccount = 0;
$ret = '<li>';
$a = $GLOBALS['links']->ParseNavLink($this->text, $this->link);
$ret .= $a;
if(count($this->children) > 0) {
$ret .= '<ul>';
foreach($this->children as $child) {
$cret = $child->Parse();
if($cret) {
$ret .= $cret;
$ccount++;
}
}
$ret .= '</ul>';
}
if(!$ccount && $a == $this->text)
return '';
return $ret . '</li>';
}
}
$GLOBALS['nav'] = new Nav;
?>
|