-
Notifications
You must be signed in to change notification settings - Fork 0
/
modules.php
122 lines (102 loc) · 3.25 KB
/
modules.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
$adminModulesTemp = array();
$ams = scandir(CLIENT_PATH.'/admin/');
$currentLocation = 0;
foreach($ams as $am){
if(is_dir(CLIENT_PATH.'/admin/'.$am) && $am != '.' && $am != '..'){
$meta = json_decode(file_get_contents(CLIENT_PATH.'/admin/'.$am.'/meta.json'));
$arr = array();
$arr['name'] = $am;
$arr['label'] = $meta->label;
$arr['menu'] = $meta->menu;
$arr['order'] = $meta->order;
if(!isset($adminModulesTemp[$arr['menu']])){
$adminModulesTemp[$arr['menu']] = array();
}
if($arr['order'] == '0'){
$adminModulesTemp[$arr['menu']]["Z".$currentLocation] = $arr;
$currentLocation++;
}else{
$adminModulesTemp[$arr['menu']]["A".$arr['order']] = $arr;
}
$moduleCapsName = ucfirst($am);
$initFile = CLIENT_PATH.'/admin/'.$am."/api/".$moduleCapsName."Initialize.php";
if(file_exists($initFile)){
include $initFile;
$class = $moduleCapsName."Initialize";
if(class_exists($class)){
$initClass = new $class();
$initClass->setBaseService($baseService);
$initClass->init();
}
}
}
}
$userModulesTemp = array();
$ams = scandir(CLIENT_PATH.'/modules/');
foreach($ams as $am){
if(is_dir(CLIENT_PATH.'/modules/'.$am) && $am != '.' && $am != '..'){
$meta = json_decode(file_get_contents(CLIENT_PATH.'/modules/'.$am.'/meta.json'));
$arr = array();
$arr['name'] = $am;
$arr['label'] = $meta->label;
$arr['menu'] = $meta->menu;
$arr['order'] = $meta->order;
if(!isset($userModulesTemp[$arr['menu']])){
$userModulesTemp[$arr['menu']] = array();
}
if($arr['order'] == '0'){
$userModulesTemp[$arr['menu']]["Z".$currentLocation] = $arr;
$currentLocation++;
}else{
$userModulesTemp[$arr['menu']]["A".$arr['order']] = $arr;
}
$moduleCapsName = ucfirst($am);
$initFile = CLIENT_PATH.'/modules/'.$am."/api/".$moduleCapsName."Initialize.php";
if(file_exists($initFile)){
include $initFile;
$class = $moduleCapsName."Initialize";
if(class_exists($class)){
$initClass = new $class();
$initClass->setBaseService($baseService);
$initClass->init();
}
}
}
}
foreach ($adminModulesTemp as $k=>$v){
ksort($adminModulesTemp[$k]);
}
foreach ($userModulesTemp as $k=>$v){
ksort($userModulesTemp[$k]);
}
$adminMenus = json_decode(file_get_contents(CLIENT_PATH.'/admin/meta.json'));
$adminModules = array();
$added = array();
foreach($adminMenus as $menu){
$arr = array("name"=>$menu,"menu"=>$adminModulesTemp[$menu]);
$adminModules[] = $arr;
$added[] = $menu;
}
foreach($adminModulesTemp as $k=>$v){
if(!in_array($k, $added)){
$arr = array("name"=>$k,"menu"=>$adminModulesTemp[$k]);
$adminModules[] = $arr;
}
}
$userMenus = json_decode(file_get_contents(CLIENT_PATH.'/modules/meta.json'));
$userModules = array();
$added = array();
foreach($userMenus as $menu){
$arr = array("name"=>$menu,"menu"=>$userModulesTemp[$menu]);
$userModules[] = $arr;
$added[] = $menu;
}
foreach($userModulesTemp as $k=>$v){
if(!in_array($k, $added)){
$arr = array("name"=>$k,"menu"=>$userModulesTemp[$k]);
$userModules[] = $arr;
}
}
error_log("Admin Modules :".print_r($adminModules,true));
//error_log("User Modules :".print_r($userModules,true));