-
Notifications
You must be signed in to change notification settings - Fork 5
/
admin.php
executable file
·74 lines (54 loc) · 2.03 KB
/
admin.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
// ACL
$app("acl")->addResource("hugo", ['manage.hugo']);
$app->on('admin.init', function() {
$this->helper('admin')->addAssets('hugo:assets/components/cp-dirselect.tag');
$this->helper('admin')->addAssets('hugo:assets/components/cp-themeselect.tag');
if (!$this->module('cockpit')->hasaccess('hugo', ['manage.hugo'])) {
return;
}
// bind admin routes /collections/*
$this->bindClass('Hugo\\Controller\\Admin', 'hugo');
// add to modules menu
$this('admin')->addMenuItem('modules', [
'label' => 'Hugo',
'icon' => 'hugo:icon.svg',
'route' => '/hugo',
'active' => strpos($this['route'], '/hugo') === 0
]);
/**
* listen to app search to filter collections
*/
$this->on('cockpit.search', function($search, $list) {
foreach ($this->module('hugo')->collections() as $collection => $meta) {
if (stripos($collection, $search)!==false || stripos($meta['label'], $search)!==false) {
$list[] = [
'icon' => 'hugo:icon.svg',
'title' => $meta['label'] ? $meta['label'] : $meta['name'],
'url' => $this->routeUrl('/hugo/admin/')
];
}
}
});
/*
$this->on('cockpit.menu.aside', function() {
$cols = $this->module('hugo')->collections();
$collections = [];
foreach($cols as $collection) {
if ($collection['in_menu']) $collections[] = $collection;
}
if (count($collections)) {
$this->renderView("hugo:views/partials/menu.php", compact('collections'));
}
});
*/
// dashboard widgets
$this->on("admin.dashboard.widgets", function($widgets) {
$collections = $this->module("collections")->collections(true);
$widgets[] = [
"name" => "hugo",
"content" => $this->view("hugo:views/widgets/dashboard.php", compact('collections')),
"area" => 'aside-left'
];
}, 100);
});