|
14 | 14 | class UtilityComponent extends AppComponent
|
15 | 15 | {
|
16 | 16 | /** Get all the modules */
|
17 |
| - static public function getAllModules() |
| 17 | + public function getAllModules() |
18 | 18 | {
|
19 | 19 | $modules = array();
|
20 | 20 | if(file_exists(BASE_PATH.'/modules/') && opendir(BASE_PATH.'/modules/'))
|
21 | 21 | {
|
22 |
| - $handle = opendir(BASE_PATH.'/modules/'); |
23 |
| - while(false !== ($file = readdir($handle))) |
| 22 | + $array = $this->initModulesConfig(BASE_PATH.'/modules/'); |
| 23 | + $modules = array_merge($modules, $array); |
| 24 | + } |
| 25 | + |
| 26 | + if(file_exists(BASE_PATH.'/privateModules/') && opendir(BASE_PATH.'/privateModules/')) |
| 27 | + { |
| 28 | + $array = $this->initModulesConfig(BASE_PATH.'/privateModules/'); |
| 29 | + $modules = array_merge($modules, $array); |
| 30 | + } |
| 31 | + |
| 32 | + return $modules; |
| 33 | + } |
| 34 | + |
| 35 | + /** find modules configuration in a folder */ |
| 36 | + private function initModulesConfig($dir) |
| 37 | + { |
| 38 | + $handle = opendir($dir); |
| 39 | + while(false !== ($file = readdir($handle))) |
| 40 | + { |
| 41 | + if(file_exists($dir.$file.'/configs/module.ini')) |
24 | 42 | {
|
25 |
| - if(file_exists(BASE_PATH.'/modules/'.$file.'/configs/module.ini')) |
| 43 | + $config = new Zend_Config_Ini($dir.$file.'/configs/module.ini', 'global', true); |
| 44 | + $config->db = array(); |
| 45 | + if(!file_exists($dir.$file.'/database')) |
26 | 46 | {
|
27 |
| - $config = new Zend_Config_Ini(BASE_PATH.'/modules/'.$file.'/configs/module.ini', 'global', true); |
28 |
| - $config->db = array(); |
29 |
| - if(!file_exists(BASE_PATH.'/modules/'.$file.'/database')) |
30 |
| - { |
31 |
| - $config->db->PDO_MYSQL = true; |
32 |
| - $config->db->PDO_IBM = true; |
33 |
| - $config->db->PDO_OCI = true; |
34 |
| - $config->db->PDO_SQLITE = true; |
35 |
| - $config->db->CASSANDRA = true; |
36 |
| - $config->db->MONGO = true; |
37 |
| - } |
38 |
| - else |
| 47 | + $config->db->PDO_MYSQL = true; |
| 48 | + $config->db->PDO_IBM = true; |
| 49 | + $config->db->PDO_OCI = true; |
| 50 | + $config->db->PDO_SQLITE = true; |
| 51 | + $config->db->CASSANDRA = true; |
| 52 | + $config->db->MONGO = true; |
| 53 | + } |
| 54 | + else |
| 55 | + { |
| 56 | + $handleDB = opendir($dir.$file.'/database'); |
| 57 | + if(file_exists($dir.$file.'/database')) |
39 | 58 | {
|
40 |
| - $handleDB = opendir(BASE_PATH.'/modules/'.$file.'/database'); |
41 |
| - if(file_exists(BASE_PATH.'/modules/'.$file.'/database')) |
| 59 | + while(false !== ($fileDB = readdir($handleDB))) |
42 | 60 | {
|
43 |
| - while(false !== ($fileDB = readdir($handleDB))) |
| 61 | + if(file_exists($dir.$file.'/database/'.$fileDB.'/')) |
44 | 62 | {
|
45 |
| - if(file_exists(BASE_PATH.'/modules/'.$file.'/database/'.$fileDB.'/')) |
| 63 | + switch($fileDB) |
46 | 64 | {
|
47 |
| - switch($fileDB) |
48 |
| - { |
49 |
| - case 'mysql' : $config->db->PDO_MYSQL = true; break; |
50 |
| - case 'pgsql' : $config->db->PDO_PGSQL = true;break; |
51 |
| - case 'ibm' : $config->db->PDO_IBM = true;break; |
52 |
| - case 'oci' : $config->db->PDO_OCI = true;break; |
53 |
| - case 'sqlite' : $config->db->PDO_SQLITE = true;break; |
54 |
| - case 'cassandra' : $config->db->CASSANDRA = true;break; |
55 |
| - case 'mongo' : $config->db->MONGO = true;break; |
56 |
| - default : break; |
57 |
| - } |
| 65 | + case 'mysql' : $config->db->PDO_MYSQL = true; break; |
| 66 | + case 'pgsql' : $config->db->PDO_PGSQL = true;break; |
| 67 | + case 'ibm' : $config->db->PDO_IBM = true;break; |
| 68 | + case 'oci' : $config->db->PDO_OCI = true;break; |
| 69 | + case 'sqlite' : $config->db->PDO_SQLITE = true;break; |
| 70 | + case 'cassandra' : $config->db->CASSANDRA = true;break; |
| 71 | + case 'mongo' : $config->db->MONGO = true;break; |
| 72 | + default : break; |
58 | 73 | }
|
59 | 74 | }
|
60 | 75 | }
|
61 | 76 | }
|
62 |
| - $modules[$file] = $config; |
63 | 77 | }
|
| 78 | + $modules[$file] = $config; |
64 | 79 | }
|
65 |
| - closedir($handle); |
66 | 80 | }
|
67 |
| - |
| 81 | + closedir($handle); |
68 | 82 | return $modules;
|
69 | 83 | }
|
70 | 84 |
|
|
0 commit comments