Index: branches/unlabeled/unlabeled-1.76.2/core/kernel/utility/unit_config_reader.php =================================================================== diff -u -r8184 -r8242 --- branches/unlabeled/unlabeled-1.76.2/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 8184) +++ branches/unlabeled/unlabeled-1.76.2/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 8242) @@ -203,6 +203,7 @@ */ function ParseConfigs() { + // 1. process normal configs and their dependencies $prioritized_configs = array(); foreach ($this->configData as $prefix => $config) { if (isset($config['ConfigPriority'])) { @@ -218,10 +219,15 @@ $clones = $this->postProcessConfig($prefix, 'Clones', 'prefix'); } + // 2. process prioritized configs and their dependencies asort($prioritized_configs); foreach ($prioritized_configs as $prefix => $priority) { $this->parseConfig($prefix); } + + foreach ($prioritized_configs as $prefix => $priority) { + $this->ProcessDependencies($prefix); + } } function AfterConfigRead() @@ -233,10 +239,49 @@ $this->Application->HandleEvent( new kEvent($prefix.':OnAfterConfigRead') ); $this->AfterConfigProcessed[] = $prefix; } - if ($this->StoreCache) $this->CacheParsedData(); + + if ($this->StoreCache) { + $this->processDynamicClones(); + $this->CacheParsedData(); + } } /** + * Re-reads all configs + * + */ + function ReReadConfigs() + { + $this->includeConfigFiles(MODULES_PATH); + $this->ParseConfigs(); + $this->AfterConfigRead(); + $this->processDynamicClones(); + } + + /** + * Process clones, that were defined via OnAfterConfigRead event + * + */ + function processDynamicClones() + { + $new_clones = Array(); + foreach ($this->configData as $prefix => $config) { + $clones = $this->postProcessConfig($prefix, 'Clones', 'prefix'); + if ($clones) { + $new_clones = array_merge($new_clones, $clones); + } + } + + // call OnAfterConfigRead for cloned configs + $new_clones = array_unique($new_clones); + foreach ($new_clones as $prefix) { + if (in_array($prefix, $this->AfterConfigProcessed)) continue; + $this->Application->HandleEvent( new kEvent($prefix.':OnAfterConfigRead') ); + $this->AfterConfigProcessed[] = $prefix; + } + } + + /** * Register nessasary classes * This method should only process the data which is cached! * @@ -475,7 +520,7 @@ function postProcessConfig($prefix, $config_key, $dst_prefix_var) { $main_config =& $this->configData[$prefix]; - $sub_configs = getArrayValue($main_config, $config_key); + $sub_configs = isset($main_config[$config_key]) && $main_config[$config_key] ? $main_config[$config_key] : false; // getArrayValue($main_config, $config_key); if (!$sub_configs) { return array(); }