Index: trunk/core/kernel/utility/unit_config_reader.php =================================================================== diff -u -r2596 -r2600 --- trunk/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 2596) +++ trunk/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 2600) @@ -1,7 +1,7 @@ Application->GetADODBConnection(); $this->modules_installed = $db->GetCol('SELECT CONCAT(\'/\',Path) AS Path, Name FROM '.TABLE_PREFIX.'Modules WHERE Loaded = 1','Name'); $this->scanModules(MODULES_PATH); } - + /** * Checks if config file is allowed for includion (if module of config is installed) * @@ -49,12 +49,12 @@ if( substr($config_path, 0, strlen($module_path)) == $module_path ) { $module_found = true; - break; + break; } } return $module_found; } - + /** * Returns true if config exists and is allowed for reading * @@ -65,7 +65,7 @@ { return isset($this->configData[$prefix]) ? true : false; } - + /** * Read configs from all directories * on path specified @@ -86,9 +86,9 @@ $file = $this->getConfigName($full_path); if ( defined('DEBUG_MODE') && dbg_ConstOn('DBG_PROFILE_INCLUDES')) { - + if ( in_array($file, get_required_files()) ) return; - global $debugger; + global $debugger; $debugger->IncludeLevel++; $before_time = getmicrotime(); $before_mem = memory_get_usage(); @@ -104,23 +104,23 @@ else { include_once($file); } - + $prefix=$config['Prefix']; $config['BasePath']=$full_path; $this->configData[$prefix] = $config; } } } } - + function ParseConfigs() { foreach ($this->configData as $prefix => $config) { $this->parseConfig($prefix); } } - + function findConfigFiles($folderPath) { $folderPath = str_replace(DOC_ROOT.BASE_PATH, '', $folderPath); @@ -134,20 +134,20 @@ $this->configFiles[] = $this->getConfigName($folderPath.'/'.$sub_folder); } $this->findConfigFiles($full_path); - + // if (filemtime($full_path) > $cached) { } - + } } } - + function includeConfigFiles() { $db =& $this->Application->GetADODBConnection(); - + foreach ($this->configFiles as $filename) { - $config_found = file_exists(DOC_ROOT.BASE_PATH.$filename) && $this->configAllowed($filename); + $config_found = file_exists(FULL_PATH.$filename) && $this->configAllowed($filename); if( defined('DEBUG_MODE') && DEBUG_MODE && dbg_ConstOn('DBG_PROFILE_INCLUDES')) { if ( in_array($filename, get_required_files()) ) return; @@ -166,22 +166,22 @@ } else { - if($config_found) include_once(DOC_ROOT.BASE_PATH.$filename); + if($config_found) include_once(FULL_PATH.$filename); } - + if($config_found) { $prefix = $config['Prefix']; - $config['BasePath'] = dirname(DOC_ROOT.BASE_PATH.$filename); + $config['BasePath'] = dirname(FULL_PATH.$filename); $this->configData[$prefix] = $config; } } } - + function scanModules($folderPath) { global $debugger; - + if (defined('CACHE_CONFIGS_FILES')) { $conn =& $this->Application->GetADODBConnection(); $data = $conn->GetRow('SELECT Data, Cached FROM '.TABLE_PREFIX.'Cache WHERE VarName = "config_files"'); @@ -190,14 +190,13 @@ $files_cached = $data['Cached']; } else { - $files_cached = 0; + $files_cached = 0; } } else { $files_cached = 0; } - - + if (defined('CACHE_CONFIGS_DATA') && CACHE_CONFIGS_DATA) { $conn =& $this->Application->GetADODBConnection(); $data = $conn->GetRow('SELECT Data, Cached FROM '.TABLE_PREFIX.'Cache WHERE VarName = "config_data"'); @@ -206,21 +205,21 @@ $data_cached = $data['Cached']; } else { - $data_cached = 0; + $data_cached = 0; } } else { $data_cached = 0; } - + if ( !defined('CACHE_CONFIGS_FILES') || $files_cached == 0 ) { $this->findConfigFiles($folderPath); } - + if ( !defined('CACHE_CONFIGS_DATA') || $data_cached == 0) { $this->includeConfigFiles(); } - + /*// && (time() - $cached) > 600) - to skip checking files modified dates if ( !defined('CACHE_CONFIGS') ) { $fh=opendir($folderPath); @@ -233,22 +232,22 @@ } } }*/ - + if (defined('CACHE_CONFIGS_DATA') && $data_cached == 0) { $conn->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("config_data", '.$conn->qstr(serialize($this->configData)).', '.time().')'); } - + $this->ParseConfigs(); - + if (defined('CACHE_CONFIGS_FILES') && $files_cached == 0) { $conn->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("config_files", '.$conn->qstr(serialize($this->configFiles)).', '.time().')'); } - + unset($this->configFiles); // unset($this->configData); - + } - + /** * Register nessasary classes * @@ -269,7 +268,7 @@ $config['BasePath'].'/'.$class_info['file'], $pseudo_class); $event_manager->registerBuildEvent($pseudo_class,$class_info['build_event']); - + // register classes on which current class depends $require_classes = getArrayValue($class_info, 'require_classes'); if($require_classes) @@ -280,7 +279,7 @@ } } } - + $register_classes = getArrayValue($config,'RegisterClasses'); if($register_classes) { @@ -289,41 +288,41 @@ $this->Application->registerClass( $class_info['class'], $config['BasePath'].'/'.$class_info['file'], $class_info['pseudo']); - } + } } - + $regular_events = getArrayValue($config, 'RegularEvents'); if($regular_events) { foreach($regular_events as $short_name => $regular_event_info) { $event_manager->registerRegularEvent( $short_name, $config['Prefix'].':'.$regular_event_info['EventName'], $regular_event_info['RunInterval'], $regular_event_info['Type'] ); - } + } } - + if ( is_array(getArrayValue($config, 'Hooks')) ) { foreach ($config['Hooks'] as $hook) { $do_prefix = $hook['DoPrefix'] == '' ? $config['Prefix'] : $hook['DoPrefix']; - + if ( !is_array($hook['HookToEvent']) ) { $hook_events = Array( $hook['HookToEvent'] ); } else { $hook_events = $hook['HookToEvent']; } foreach ($hook_events as $hook_event) { - $this->Application->registerHook($hook['HookToPrefix'], $hook['HookToSpecial'], $hook_event, $hook['Mode'], $do_prefix, $hook['DoSpecial'], $hook['DoEvent'], $hook['Conditional']); + $this->Application->registerHook($hook['HookToPrefix'], $hook['HookToSpecial'], $hook_event, $hook['Mode'], $do_prefix, $hook['DoSpecial'], $hook['DoEvent'], $hook['Conditional']); } } } - + if ( is_array(getArrayValue($config, 'AggregateTags')) ) { foreach ($config['AggregateTags'] as $aggregate_tag) { $aggregate_tag['LocalPrefix'] = $config['Prefix']; - $this->Application->registerAggregateTag($aggregate_tag); + $this->Application->registerAggregateTag($aggregate_tag); } } - + if ( $this->Application->isDebugMode() && dbg_ConstOn('DBG_VALIDATE_CONFIGS') && isset($config['TableName']) ) { global $debugger; @@ -357,7 +356,7 @@ } } } - + /** * Reads unit (specified by $prefix) * option specified by $option @@ -371,7 +370,7 @@ { return isset($this->configData[$prefix][$name]) ? $this->configData[$prefix][$name] : false; } - + /** * Read all unit with $prefix options * @@ -383,7 +382,7 @@ { return $this->prefixRegistred($prefix) ? $this->configData[$prefix] : false; } - + /** * Set's new unit option value * @@ -396,7 +395,7 @@ { $this->configData[$prefix][$name] = $value; } - + function getPrefixByParamName($paramName,$prefix) { $pseudo_class_map=Array( @@ -405,9 +404,9 @@ 'EventHandlerClass'=>'%s_EventHandler', 'TagProcessorClass'=>'%s_TagProcessor' ); - return sprintf($pseudo_class_map[$paramName],$prefix); + return sprintf($pseudo_class_map[$paramName],$prefix); } - + /** * Get's config file name based * on folder name supplied @@ -420,7 +419,7 @@ { return $folderPath.'/'.basename($folderPath).'_config.php'; } - + /** * is_dir ajustment to work with * directory listings too @@ -435,9 +434,9 @@ $ret=!($base_name=='.'||$base_name=='..'); return $ret&&is_dir($folderPath); } - - + + } - + ?> \ No newline at end of file