Index: branches/RC/core/units/general/helpers/sections_helper.php =================================================================== diff -u -r10951 -r11129 --- branches/RC/core/units/general/helpers/sections_helper.php (.../sections_helper.php) (revision 10951) +++ branches/RC/core/units/general/helpers/sections_helper.php (.../sections_helper.php) (revision 11129) @@ -46,56 +46,27 @@ $this->Tree = Array(); // 1. build base tree (don't update parent with children list yet) + + // 1.1. process prefixes without priority + $prioritized_prefixes = Array (); $prefixes = array_keys($this->Application->UnitConfigReader->configData); + foreach ($prefixes as $prefix) { $config =& $this->Application->UnitConfigReader->configData[$prefix]; - $sections = getArrayValue($config, 'Sections'); - if (!$sections) continue; -// echo 'Prefix: ['.$prefix.'] has ['.count($sections).'] sections
'; - - foreach ($sections as $section_name => $section_params) { - // we could also skip not allowed sections here in future - if ( isset($section_params['SectionPrefix']) ) { - $section_prefix = $section_params['SectionPrefix']; - } - elseif ( $this->Application->getUnitOption($prefix, 'SectionPrefix') ) { - $section_prefix = $this->Application->getUnitOption($prefix, 'SectionPrefix'); - } - else { - $section_prefix = $prefix; - } - $section_params['SectionPrefix'] = $section_prefix; - $section_params['url']['m_opener'] = 'r'; - $section_params['url']['no_pass_through'] = 1; - $pass_section = getArrayValue($section_params, 'url', 'pass_section'); - - if ($pass_section) { - unset($section_params['url']['pass_section']); - $section_params['url']['section'] = $section_name; - if (!isset($section_params['url']['module'])) { - $module_name = $this->Application->findModule('Path', $config['ModuleFolder'].'/', 'Name'); - $section_params['url']['module'] = $module_name; - } - } - - if (!isset($section_params['url']['t'])) { - $section_params['url']['t'] = 'index'; - } - - if (!isset($section_params['onclick'])) { - $section_params['onclick'] = 'checkEditMode()'; - } - - if (!isset($section_params['container'])) { - $section_params['container'] = 0; // for js tree printing to xml - } - - $current_data = isset($this->Tree[$section_name]) ? $this->Tree[$section_name] : Array(); - $this->Tree[$section_name] = array_merge_recursive2($current_data, $section_params); + if (array_key_exists('ConfigPriority', $config)) { + $prioritized_prefixes[$prefix] = $config['ConfigPriority']; + continue; } + $this->_processPrefixSections($prefix); } + // 2. process prefixes with priority + asort($prioritized_prefixes); + foreach ($prioritized_prefixes as $prefix => $priority) { + $this->_processPrefixSections($prefix); + } + // 2. apply section ajustments foreach ($prefixes as $prefix) { $config =& $this->Application->UnitConfigReader->configData[$prefix]; @@ -104,6 +75,11 @@ foreach ($section_ajustments as $section_name => $ajustment_params) { if (is_array($ajustment_params)) { + if (!array_key_exists($section_name, $this->Tree)) { + // don't process ajustments for non-existing sections + continue; + } + $this->Tree[$section_name] = array_merge_recursive2($this->Tree[$section_name], $ajustment_params); } else { @@ -156,6 +132,63 @@ $this->Conn->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("sections_parsed", '.$this->Conn->qstr(serialize($this->Tree)).', '.adodb_mktime().')'); } + function _processPrefixSections($prefix) + { + $config =& $this->Application->UnitConfigReader->configData[$prefix]; + $sections = getArrayValue($config, 'Sections'); + if (!$sections) { + return ; + } + +// echo 'Prefix: ['.$prefix.'] has ['.count($sections).'] sections
'; + + foreach ($sections as $section_name => $section_params) { + // we could also skip not allowed sections here in future + if ( isset($section_params['SectionPrefix']) ) { + $section_prefix = $section_params['SectionPrefix']; + } + elseif ( $this->Application->getUnitOption($prefix, 'SectionPrefix') ) { + $section_prefix = $this->Application->getUnitOption($prefix, 'SectionPrefix'); + } + else { + $section_prefix = $prefix; + } + $section_params['SectionPrefix'] = $section_prefix; + $section_params['url']['m_opener'] = 'r'; + $section_params['url']['no_pass_through'] = 1; + $pass_section = getArrayValue($section_params, 'url', 'pass_section'); + + if ($pass_section) { + unset($section_params['url']['pass_section']); + $section_params['url']['section'] = $section_name; + if (!isset($section_params['url']['module'])) { + $module_name = $this->Application->findModule('Path', $config['ModuleFolder'].'/', 'Name'); + $section_params['url']['module'] = $module_name; + } + } + + if (!isset($section_params['url']['t'])) { + $section_params['url']['t'] = 'index'; + } + + if (!isset($section_params['onclick'])) { + $section_params['onclick'] = 'checkEditMode()'; + } + + if (!isset($section_params['container'])) { + $section_params['container'] = 0; // for js tree printing to xml + } + + $current_data = isset($this->Tree[$section_name]) ? $this->Tree[$section_name] : Array(); + + if ($section_name == 'in-portal:system') { + echo ''; + } + + $this->Tree[$section_name] = array_merge_recursive2($current_data, $section_params); + } + } + /** * Returns details information about section *