blob: acb2629760c11f0a41639ff9c703b6222e6eaa92 (
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
|
<?php
class Menu {
public static function getItems() {
return Env::get('menu', 'items');
}
private static function _getPageID($url) {
return trim(explode('#', $url)[0], '/');
}
public static function getActiveLink($pageID) {
$activeContent = $pageID;
foreach (self::getItems() as $item => $link) {
if (is_array($link)) {
foreach ($link as $subitem => $sublink) {
if (self::_getPageID($sublink) === $pageID) {
$activeContent = $link['_'];
break;
}
}
} else {
if (self::_getPageID($link) === $pageID) {
$activeContent = $link;
}
}
}
return $activeContent;
}
}
?>
|