-
Notifications
You must be signed in to change notification settings - Fork 4
/
module.php
55 lines (45 loc) · 1.83 KB
/
module.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
<?php
use Sunlight\Admin\Admin;
use Sunlight\Extend;
use Sunlight\Message;
use Sunlight\Router;
defined('SL_ROOT') or exit;
// output
if (isset($_admin->modules[$_admin->currentModule])) {
if (Admin::moduleAccess($_admin->currentModule)) {
$module = $_admin->modules[$_admin->currentModule];
$module_custom_header = (isset($module['custom_header']) && $module['custom_header']);
// backlink
if (isset($module['parent']) && !$module_custom_header) {
$output .= Admin::backlink(Router::admin($module['parent']));
}
// title
$_admin->title = $module['title'];
if (!$module_custom_header) {
$output .= '<h1>' . $module['title'] . "</h1>\n";
}
// compose script path
$script = $module['script'] ?? SL_ROOT . 'admin/action/modules/' . $_admin->currentModule . '.php';
// run script
$extend_args = Extend::args($output, [
'name' => $_admin->currentModule,
'script' => &$script,
]);
Extend::call('admin.mod.init', $extend_args);
Extend::call('admin.mod.' . $_admin->currentModule . '.before', $extend_args);
if ($script !== false && file_exists($script)) {
require $script;
$extend_args = Extend::args($output);
Extend::call('admin.mod.' . $_admin->currentModule . '.after', $extend_args);
Extend::call('admin.mod.after', $extend_args);
} else {
$output .= Message::warning(_lang('admin.moduleunavailable'));
}
} else {
// no access
$output .= '<h1>' . _lang('global.error') . "</h1>\n" . Message::warning(_lang('global.accessdenied'));
}
} else {
// module not found
$output .= '<h1>' . _lang('global.error404.title') . "</h1>\n" . Message::warning(_lang('global.error404'));
}