1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: if (!defined("FRAMEWORKS_ART_FUNCTIONS_CONFIG")):
15: define("FRAMEWORKS_ART_FUNCTIONS_CONFIG", true);
16:
17: 18: 19: 20: 21: 22:
23: function mod_loadConfig($dirname = "")
24: {
25: $xoops = Xoops::getInstance();
26: if (empty($dirname) && !$xoops->isModule()) {
27: return null;
28: }
29: $dirname = !empty($dirname) ? $dirname : $xoops->module->getVar("dirname");
30:
31: if ($xoops->isModule() && $xoops->module->getVar("dirname", "n") == $dirname) {
32: if (!empty($xoops->moduleConfig)) {
33: $moduleConfig = $xoops->moduleConfig;
34: } else {
35: return null;
36: }
37: } else {
38:
39: if (!$moduleConfig = \Xoops\Cache::read("{$dirname}_config")) {
40: $moduleConfig = mod_fetchConfig($dirname);
41: \Xoops\Cache::write("{$dirname}_config", $moduleConfig);
42: }
43: }
44: if ($customConfig = @include \XoopsBaseConfig::get('root-path') . "/modules/{$dirname}/include/plugin.php") {
45: $moduleConfig = array_merge($moduleConfig, $customConfig);
46: }
47: return $moduleConfig;
48: }
49:
50: 51: 52: 53:
54: function mod_loadConfg($dirname = "")
55: {
56: return mod_loadConfig($dirname);
57: }
58:
59: 60: 61: 62: 63: 64:
65: function mod_fetchConfig($dirname = "")
66: {
67: if (empty($dirname)) {
68: return null;
69: }
70:
71: $xoops = Xoops::getInstance();
72: if (!$module = $xoops->getModuleByDirname($dirname)) {
73: trigger_error("Module '{$dirname}' does not exist", E_USER_WARNING);
74: return null;
75: }
76: $config_handler = $xoops->getHandlerConfig();
77: $criteria = new CriteriaCompo(new Criteria('conf_modid', $module->getVar('mid')));
78: $configs = $config_handler->getConfigs($criteria);
79: $moduleConfig = array();
80: foreach (array_keys($configs) as $i) {
81: $moduleConfig[$configs[$i]->getVar('conf_name')] = $configs[$i]->getConfValueForOutput();
82: }
83: unset($module, $configs);
84:
85: return $moduleConfig;
86: }
87:
88: function mod_fetchConfg($dirname = "")
89: {
90: return mod_fetchConfig($dirname);
91: }
92:
93: 94: 95: 96: 97: 98: 99:
100: function mod_clearConfig($dirname = "")
101: {
102: if (empty($dirname)) {
103: return false;
104: }
105:
106:
107: return \Xoops\Cache::delete("{$dirname}_config");
108: }
109:
110: function mod_clearConfg($dirname = "")
111: {
112: return mod_clearConfig($dirname);
113: }
114:
115: endif;
116: