Index: parent.msn =================================================================== --- parent.msn (revision 385) +++ parent.msn (revision 386) @@ -1,7 +1,6 @@ - <%args> $name => undef @@ -12,46 +11,32 @@ <%init> - sub select_index_tree - { - use locale; - my ($sect, $offset, $count_offset, $selected, $CACHE) = @_; - my $spacer = ''; - for(my $c=0; $c<$offset; $c++) - { - $spacer = $spacer.(($c == $offset-1) ? '   >>   ' : '      '); + my $tree; + if ( exists $request->{"_section_tree_$root"} ) { + $tree = $request->{"_section_tree_$root"}; + } else { + $tree = $keeper->get_section_tree( root_id => $root ); + $request->{"_section_tree_$root"} = $tree; + } + my $root_sect = $tree->{root}; + my $color = 0; + + sub select_index_tree { + my ($sect, $offset, $count_offset, $selected, $cb, $TREE) = @_; + return unless ref $sect; + my $padding = 'padding-left:'.int($offset * 15).'px;'; + my $color = $$cb ? 'background:#f0f0f0;' : ''; + $$cb = $$cb ? 0 : 1; + my $style = $sect->id == 1 ? ' style="background-color:#606060;color:#ffffff;'.$padding.$color.'"' : ' style="'.$padding.$color.'"'; + my $sel = $selected && $selected == $sect->id ? ' selected' : ''; + $m->out (''."\n"); + if ( exists $sect->{children} && $offset < $count_offset ) { + $offset++; + foreach my $child ( @{$sect->{children}} ) { + select_index_tree( $child, $offset, $count_offset, $selected, $cb, $TREE ); } - if( $sect->id() ) - { - $m->out(''); - } - elsif( $sect->id() && $sect->id() == 1 ) - { - - $m->out(''); - } - my @childs = $sect->childs(); - if( @childs && $offset < $count_offset ) - { - $offset++; - foreach my $child_id (@childs) - { - my $child = $CACHE->{$child_id}; - select_index_tree( $child, $offset, $count_offset, $selected, $CACHE); - } - $offset--; - } } + } - - my $CACHE = {}; - my @cacher = $keeper->get_sections( light => 1 ); - for my $c (@cacher) - { - $CACHE->{$c->id()} = $c; - } - - my $root_sect = $CACHE->{$root} || $CACHE->{1}; -