Index: trunk/core/units/general/helpers/sections_helper.php =================================================================== diff -u -N -r6696 -r7391 --- trunk/core/units/general/helpers/sections_helper.php (.../sections_helper.php) (revision 6696) +++ trunk/core/units/general/helpers/sections_helper.php (.../sections_helper.php) (revision 7391) @@ -47,6 +47,7 @@ $unit_config_reader =& $this->Application->recallObject('kUnitConfigReader'); } + // 1. build base tree (don't update parent with children list yet) $prefixes = array_keys($unit_config_reader->configData); foreach ($prefixes as $prefix) { $config =& $unit_config_reader->configData[$prefix]; @@ -88,23 +89,58 @@ $section_params['onclick'] = 'checkEditMode()'; } - if (isset($section_params['icon']) && preg_match('/([^:]+):(.*)/', $section_params['icon'], $regs)) { - $section_params['icon'] = $regs[2]; - $section_params['icon_module'] = $regs[1]; - } - $current_data = isset($this->Tree[$section_name]) ? $this->Tree[$section_name] : Array(); $this->Tree[$section_name] = array_merge_recursive2($current_data, $section_params); + } + } - $this->Tree[ $section_params['parent'] ]['children'][ "{$section_params['priority']}" ] = $section_name; + // 2. apply section ajustments + foreach ($prefixes as $prefix) { + $config =& $unit_config_reader->configData[$prefix]; + $section_ajustments = getArrayValue($config, 'SectionAdjustments'); + if (!$section_ajustments) continue; - if ($section_params['type'] == stTAB) { - // if this is tab, then mark parent section as TabOnly - $this->Tree[ $section_params['parent'] ]['tabs_only'] = true; + foreach ($section_ajustments as $section_name => $ajustment_params) { + if (is_array($ajustment_params)) { + $this->Tree[$section_name] = array_merge_recursive2($this->Tree[$section_name], $ajustment_params); } + else { + // then remove section + unset($this->Tree[$section_name]); + } } } + // 3. + foreach ($this->Tree as $section_name => $section_params) { + // 3.1. update parent -> children references + $this->Tree[ $section_params['parent'] ]['children'][ "{$section_params['priority']}" ] = $section_name; + + if ($section_params['type'] == stTAB) { + // if this is tab, then mark parent section as TabOnly + $this->Tree[ $section_params['parent'] ]['tabs_only'] = true; + } + + // 3.2. process icons here, because they also can be ajusted + if (isset($section_params['icon']) && preg_match('/([^:]+):(.*)/', $section_params['icon'], $regs)) { + $this->Tree[$section_name]['icon'] = $regs[2]; + $this->Tree[$section_name]['icon_module'] = $regs[1]; + $module_folder = trim( $this->Application->findModule('Name', $regs[1], 'Path'), '/'); + if ($module_folder == '') $module_folder = 'core'; + } + else { + $module_folder = $this->Application->getUnitOption($section_params['SectionPrefix'], 'ModuleFolder'); + } + + // this is to display HELP icon instead of missing one.. can be replaced with some other icon to draw attention + $icon_file = $module_folder.'/admin_templates/img/icons/icon24_'.$this->Tree[$section_name]['icon']; + if (!file_exists(FULL_PATH.'/'.$icon_file.'.gif')) { + $this->Tree[$section_name]['icon'] = 'help'; + $this->Tree[$section_name]['icon_module'] = 'core'; + } + } + $this->Application->HandleEvent( new kEvent('adm:OnAfterBuildTree') ); + $this->Conn->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("sections_parsed", '.$this->Conn->qstr(serialize($this->Tree)).', '.adodb_mktime().')'); }