blob: 59f4c8d0af3a7f3ee6efc13f31406e02b3a73b3c (
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
<?PHP
if(!defined('NAV_INC')) {
define('NAV_INC', 1);
include('code/links.inc.php');
class Nav {
var $entries = array();
function Nav() {
$res = DBQuery('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->GetParentId() != 0)
$this->entries[$entry->GetParentId()]->Add($entry);
}
function ParseEntries() {
$ret = '<ul>';
foreach($this->entries as $entry)
if($entry->GetParentId() == 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 GetChildren() {
return $this->children;
}
function GetParentId() {
return $this->parent;
}
function GetText() {
return $this->text;
}
function GetLink() {
return $this->link;
}
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>';
}
}
$nav = new Nav;
}
?>
|