| 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: |  | 
| 74: | $module_handler = xoops_getHandler('module'); | 
| 75: | if (!$module = $module_handler->getByDirname($dirname)) { | 
| 76: | trigger_error("Module '{$dirname}' does not exist", E_USER_WARNING); | 
| 77: |  | 
| 78: | return null; | 
| 79: | } | 
| 80: |  | 
| 81: |  | 
| 82: | $config_handler = xoops_getHandler('config'); | 
| 83: | $criteria       = new CriteriaCompo(new Criteria('conf_modid', $module->getVar('mid'))); | 
| 84: | $configs        = $config_handler->getConfigs($criteria); | 
| 85: | foreach (array_keys($configs) as $i) { | 
| 86: | $moduleConfig[$configs[$i]->getVar('conf_name')] = $configs[$i]->getConfValueForOutput(); | 
| 87: | } | 
| 88: | unset($module, $configs); | 
| 89: |  | 
| 90: | return $moduleConfig; | 
| 91: | } | 
| 92: |  | 
| 93: |  | 
| 94: |  | 
| 95: |  | 
| 96: |  | 
| 97: |  | 
| 98: | function mod_fetchConfg($dirname = '') | 
| 99: | { | 
| 100: | return mod_fetchConfig($dirname); | 
| 101: | } | 
| 102: |  | 
| 103: |  | 
| 104: |  | 
| 105: |  | 
| 106: |  | 
| 107: |  | 
| 108: |  | 
| 109: |  | 
| 110: | function mod_clearConfig($dirname = '') | 
| 111: | { | 
| 112: | if (empty($dirname)) { | 
| 113: | return false; | 
| 114: | } | 
| 115: |  | 
| 116: | xoops_load('XoopsCache'); | 
| 117: |  | 
| 118: | return XoopsCache::delete("{$dirname}_config"); | 
| 119: | } | 
| 120: |  | 
| 121: |  | 
| 122: |  | 
| 123: |  | 
| 124: |  | 
| 125: |  | 
| 126: | function mod_clearConfg($dirname = '') | 
| 127: | { | 
| 128: | return mod_clearConfig($dirname); | 
| 129: | } | 
| 130: |  | 
| 131: | endif; | 
| 132: |  |