/
dashboard_menu.php
74 lines (67 loc) · 2.2 KB
/
dashboard_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
<?php
namespace Concrete\Controller\Element\Navigation;
use Concrete\Core\Controller\ElementController;
use Concrete\Core\Entity\Express\Entity;
use Concrete\Core\Page\Page;
use Concrete\Core\Page\PageList;
class DashboardMenu extends Menu
{
public function __construct(Page $currentPage)
{
$dashboard = \Page::getByPath('/dashboard');
parent::__construct($dashboard, $currentPage);
}
public function displayChildPages(Page $page)
{
$display = parent::displayChildPages($page);
if ($display) {
return true;
} else {
if (
strpos($this->currentPage->getCollectionPath(), '/account') === 0 &&
(
strpos($page->getCollectionPath(), '/dashboard/welcome') === 0 ||
strpos($page->getCollectionPath(), '/account') === 0
)
) {
return true;
}
}
}
protected function getPageList($parent)
{
$list = parent::getPageList($parent);
$list->includeSystemPages();
$list->includeAliases();
return $list;
}
public function getMenuItemClass(Page $page)
{
$class = parent::getMenuItemClass($page);
$classes = explode(' ', $class);
if (
strpos($this->currentPage->getCollectionPath(), '/account') === 0 &&
(
strpos($page->getCollectionPath(), '/dashboard/welcome') === 0 ||
strpos($page->getCollectionPath(), '/account') === 0
)
) {
$classes[] = 'nav-path-selected';
}
return implode(' ' , $classes);
}
public function getChildPages($parent)
{
$pages = parent::getChildPages($parent);
if ($parent->getCollectionPath() == '/dashboard/welcome') {
// Add My Account to the List
$pages[] = Page::getByPath('/account');
$site = \Core::make("site")->getSite();
$config = $site->getConfigRepository();
if (is_object($site) && $config->get('user.profiles_enabled')) {
$pages[] = Page::getByPath('/members/profile');
}
}
return $pages;
}
}