forked from pepiuox/PHP-GrapesJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.php
119 lines (106 loc) · 4.26 KB
/
menu.php
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!-- menu -->
<?php
$rmenu = $conn->query("SELECT * FROM menu_options WHERE id='$menu'");
$rmopt = $rmenu->fetch_assoc();
$id_menu = $rmopt['id_menu'];
$fluid = '';
$placement = '';
$aligment = '';
$background = '';
$color = '';
if ($rmopt['fluid'] === 'yes') {
$fluid = 'container-fluid';
} else {
$fluid = 'container';
}
if ($rmopt['placement'] === 'top') {
$placement = 'fixed-top';
} elseif ($rmopt['placement'] === 'bottom') {
$placement = 'fixed-bottom';
} else {
$placement = 'sticky-top';
}
if ($rmopt['aligment'] === 'start') {
$aligment = 'justify-content-start';
} elseif ($rmopt['aligment'] === 'center') {
$aligment = 'justify-content-center';
} else {
$aligment = 'justify-content-end';
}
if ($rmopt['background'] === 'primary') {
$background = 'bg-primary';
} elseif ($rmopt['background'] === 'secondary') {
$background = 'bg-secondary';
} elseif ($rmopt['background'] === 'light') {
$background = 'bg-light';
} elseif ($rmopt['background'] === 'dark') {
$background = 'bg-dark';
} elseif ($rmopt['background'] === 'info') {
$background = 'bg-info';
} elseif ($rmopt['background'] === 'success') {
$background = 'bg-success';
} elseif ($rmopt['background'] === 'warning') {
$background = 'bg-warning';
} else {
$background = 'bg-danger';
}
if ($rmopt['color'] === 'light') {
$color = 'navbar-light';
} else {
$color = 'navbar-dark';
}
?>
<nav class="navbar navbar-expand-lg <?php echo $background; ?> <?php echo $color; ?>" id="<?php echo $id_menu; ?>">
<div class="<?php echo $fluid; ?>">
<a class="navbar-brand" href="<?php echo $base; ?>"><?php echo SITE_NAME; ?></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse <?php echo $aligment; ?>" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<?php
function getLink($mid) {
global $conn;
$result = $conn->query("SELECT * FROM page WHERE id='$mid'");
$row = $result->fetch_assoc();
return 'builder.php?id=' . $row['id'];
}
function second($mid, $plink) {
global $conn;
$mresult = $conn->query("SELECT * FROM page WHERE parent='$mid'");
echo '<ul class="dropdown-menu" aria-labelledby="navbarDropdown">' . "\n";
while ($mrow = $mresult->fetch_array()) {
echo '<li><a class="dropdown-item" href="' . $plink . '/' . $mrow['link'] . '">' . $mrow['title'] . '</a></li>' . "\n";
}
echo '</ul>' . "\n";
}
function dropdown() {
global $conn;
$mresult = $conn->query("SELECT * FROM page");
while ($mrow = $mresult->fetch_array()) {
$parents[] = $mrow['parent'];
}
$result = $conn->query("SELECT * FROM page WHERE parent=0");
while ($row = $result->fetch_array()) {
$mid = $row['id'];
$plink = SITE_PATH . $row['link'];
if (in_array($row['id'], $parents)) {
echo '<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="' . $row['link'] . '" id="navbarDropdown" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
' . $row['title'] . '
</a>' . "\n";
echo second($mid, $plink);
echo '</li>' . "\n";
} else {
echo '<li class="nav-item"><a class="nav-link" href="' . $plink . '">' . $row['title'] . '</a></li>' . "\n";
}
}
}
echo dropdown();
?>
</ul>
</div>
</div>
</nav>