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