Index: trunk/kernel/units/admin/admin_tag_processor.php
===================================================================
diff -u -r4603 -r4607
--- trunk/kernel/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 4603)
+++ trunk/kernel/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 4607)
@@ -2,8 +2,6 @@
class AdminTagProcessor extends kDBTagProcessor {
- var $Tree = Array();
-
function SetConst($params)
{
$name = $this->SelectParam($params, 'name,const');
@@ -157,52 +155,24 @@
*/
function BuildTree($params)
{
- $this->Tree = Array();
- $unit_config_reader =& $this->Application->recallObject('kUnitConfigReader');
- $prefixes = array_keys($unit_config_reader->configData);
- foreach ($prefixes as $prefix) {
- $config =& $unit_config_reader->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 ($section_params['type'] != stTREE) continue;
- $section_params['SectionPrefix'] = $prefix;
- $section_params['url']['m_opener'] = 'r';
- $section_params['url']['section'] = $section_name;
-
- if (!isset($section_params['url']['module'])) {
- $module = $this->Application->findModule('Path', $config['ModuleFolder'].'/');
- $section_params['url']['module'] = $module['Name'];
- }
-
- if (!isset($section_params['url']['t'])) {
- $section_params['url']['t'] = 'index';
- }
-
- $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;
- }
-
- }
-
-// return '
'.print_r($this->Tree, true).''; + $sections_helper =& $this->Application->recallObject('SectionsHelper'); + $sections_helper->BuildTree(); } function DrawTree($params) { + static $deep_level = 0; + // when processings, then sort children by priority (key of children array) $ret = ''; $section_name = $params['section_name']; $params['name'] = $this->SelectParam($params, 'name,render_as,block'); - - $section_data =& $this->Tree[$section_name]; + $sections_helper =& $this->Application->recallObject('SectionsHelper'); + $section_data =& $sections_helper->getSectionData($section_name); + + $params['children_count'] = isset($section_data['children']) ? count($section_data['children']) : 0; + $params['deep_level'] = $deep_level++; $template = $section_data['url']['t']; unset($section_data['url']['t']); $section_data['section_url'] = $this->Application->HREF($template, '', $section_data['url']); @@ -215,8 +185,10 @@ foreach ($section_data['children'] as $section_name) { $params['section_name'] = $section_name; $ret .= $this->DrawTree($params); + $deep_level--; } + return $ret; } @@ -228,7 +200,9 @@ $section_name = $this->Application->RecallVar('section'); } - $section_data =& $this->Tree[$section_name]; + $sections_helper =& $this->Application->recallObject('SectionsHelper'); + $section_data =& $sections_helper->getSectionData($section_name); + $params['name'] = $this->SelectParam($params, 'name,render_as,block'); $params['section_name'] = $section_name; @@ -250,7 +224,9 @@ $section_name = $this->Application->RecallVar('section'); } - $section_data =& $this->Tree[$section_name]; + $sections_helper =& $this->Application->recallObject('SectionsHelper'); + $section_data =& $sections_helper->getSectionData($section_name); + $params['name'] = $this->SelectParam($params, 'name,render_as,block'); if (!isset($section_data['children'])) { return ''; @@ -259,7 +235,7 @@ ksort($section_data['children'], SORT_NUMERIC); foreach ($section_data['children'] as $section_name) { $params['section_name'] = $section_name; - $section_data =& $this->Tree[$section_name]; + $section_data =& $sections_helper->getSectionData($section_name); $params['children_count'] = isset($section_data['children']) ? count($section_data['children']) : 0; $template = $section_data['url']['t'];