|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Config-file for navigation bar. |
|
4
|
|
|
* |
|
5
|
|
|
*/ |
|
6
|
|
|
return [ |
|
7
|
|
|
|
|
8
|
|
|
// Use for styling the menu |
|
9
|
|
|
'class' => 'navbar', |
|
10
|
|
|
|
|
11
|
|
|
// Here comes the menu strcture |
|
12
|
|
|
'items' => [ |
|
13
|
|
|
|
|
14
|
|
|
// This is a menu item |
|
15
|
|
|
'home' => [ |
|
16
|
|
|
'text' => 'Home', |
|
17
|
|
|
'url' => $this->di->get('url')->create(''), |
|
18
|
|
|
'title' => 'Home route of current frontcontroller' |
|
19
|
|
|
], |
|
20
|
|
|
|
|
21
|
|
|
// This is a menu item |
|
22
|
|
|
'test' => [ |
|
23
|
|
|
'text' => 'Submenu', |
|
24
|
|
|
'url' => $this->di->get('url')->create('submenu'), |
|
25
|
|
|
'title' => 'Submenu with url as internal route within this frontcontroller', |
|
26
|
|
|
|
|
27
|
|
|
// Here we add the submenu, with some menu items, as part of a existing menu item |
|
28
|
|
|
'submenu' => [ |
|
29
|
|
|
|
|
30
|
|
|
'items' => [ |
|
31
|
|
|
|
|
32
|
|
|
// This is a menu item of the submenu |
|
33
|
|
|
'item 0' => [ |
|
34
|
|
|
'text' => 'Item 0', |
|
35
|
|
|
'url' => $this->di->get('url')->create('submenu/item-0'), |
|
36
|
|
|
'title' => 'Url as internal route within this frontcontroller' |
|
37
|
|
|
], |
|
38
|
|
|
|
|
39
|
|
|
// This is a menu item of the submenu |
|
40
|
|
|
'item 2' => [ |
|
41
|
|
|
'text' => '/humans.txt', |
|
42
|
|
|
'url' => $this->di->get('url')->asset('/humans.txt'), |
|
43
|
|
|
'title' => 'Url to sitespecific asset', |
|
44
|
|
|
'class' => 'italic' |
|
45
|
|
|
], |
|
46
|
|
|
|
|
47
|
|
|
// This is a menu item of the submenu |
|
48
|
|
|
'item 3' => [ |
|
49
|
|
|
'text' => 'humans.txt', |
|
50
|
|
|
'url' => $this->di->get('url')->asset('humans.txt'), |
|
51
|
|
|
'title' => 'Url to asset relative to frontcontroller', |
|
52
|
|
|
], |
|
53
|
|
|
], |
|
54
|
|
|
], |
|
55
|
|
|
], |
|
56
|
|
|
|
|
57
|
|
|
// This is a menu item |
|
58
|
|
|
'controller' => [ |
|
59
|
|
|
'text' =>'Controller (marked for all descendent actions)', |
|
60
|
|
|
'url' => $this->di->get('url')->create('controller'), |
|
61
|
|
|
'title' => 'Url to relative frontcontroller, other file', |
|
62
|
|
|
'mark-if-parent-of' => 'controller', |
|
63
|
|
|
], |
|
64
|
|
|
|
|
65
|
|
|
// This is a menu item |
|
66
|
|
|
'about' => [ |
|
67
|
|
|
'text' =>'About', |
|
68
|
|
|
'url' => $this->di->get('url')->create('about'), |
|
69
|
|
|
'title' => 'Internal route within this frontcontroller' |
|
70
|
|
|
], |
|
71
|
|
|
], |
|
72
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Callback tracing the current selected menu item base on scriptname |
|
77
|
|
|
* |
|
78
|
|
|
*/ |
|
79
|
|
|
'callback' => function ($url) { |
|
80
|
|
|
if ($url == $this->di->get('request')->getCurrentUrl(false)) { |
|
|
|
|
|
|
81
|
|
|
return true; |
|
82
|
|
|
} |
|
83
|
|
|
}, |
|
84
|
|
|
|
|
85
|
|
|
|
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Callback to check if current page is a decendant of the menuitem, this check applies for those |
|
89
|
|
|
* menuitems that has the setting 'mark-if-parent' set to true. |
|
90
|
|
|
* |
|
91
|
|
|
*/ |
|
92
|
|
|
'is_parent' => function ($parent) { |
|
93
|
|
|
$route = $this->di->get('request')->getRoute(); |
|
|
|
|
|
|
94
|
|
|
return !substr_compare($parent, $route, 0, strlen($parent)); |
|
95
|
|
|
}, |
|
96
|
|
|
|
|
97
|
|
|
|
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Callback to create the url, if needed, else comment out. |
|
101
|
|
|
* |
|
102
|
|
|
*/ |
|
103
|
|
|
/* |
|
104
|
|
|
'create_url' => function ($url) { |
|
105
|
|
|
return $this->di->get('url')->create($url); |
|
106
|
|
|
}, |
|
107
|
|
|
*/ |
|
108
|
|
|
]; |
|
109
|
|
|
|
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.