| 1 |
3 |
ahitrov@rambler.ru |
<select name="<% $name %>" class="selects"> |
| 2 |
|
|
% select_index_tree( $root_sect, 0, $level, $check, $CACHE ); |
| 3 |
|
|
</select> |
| 4 |
|
|
|
| 5 |
|
|
<%args> |
| 6 |
|
|
|
| 7 |
|
|
$name => undef |
| 8 |
|
|
$check => undef |
| 9 |
|
|
|
| 10 |
|
|
$root => 1 |
| 11 |
|
|
$level => 15 |
| 12 |
|
|
|
| 13 |
|
|
</%args> |
| 14 |
|
|
<%init> |
| 15 |
|
|
sub select_index_tree |
| 16 |
|
|
{ |
| 17 |
|
|
use locale; |
| 18 |
|
|
my ($sect, $offset, $count_offset, $selected, $CACHE) = @_; |
| 19 |
|
|
|
| 20 |
|
|
my $spacer = ''; |
| 21 |
|
|
for(my $c=0; $c<$offset; $c++) |
| 22 |
|
|
{ |
| 23 |
|
|
$spacer = $spacer.(($c == $offset-1) ? ' >> ' : ' '); |
| 24 |
|
|
} |
| 25 |
|
|
if( $sect->id() ) |
| 26 |
|
|
{ |
| 27 |
|
|
$m->out('<option value="'.$sect->id.'" '.(($selected == $sect->id) ? ' selected' : '').'>'.$spacer.$sect->name.'</option>'); |
| 28 |
|
|
} |
| 29 |
|
|
elsif( $sect->id() && $sect->id() == 1 ) |
| 30 |
|
|
{ |
| 31 |
|
|
|
| 32 |
|
|
$m->out('<option style="background-color:#606060;color:#ffffff;" value="'.$sect->id.'" '.(($selected == $sect->id) ? ' selected' : '').'>'.$sect->name.'</option>'); |
| 33 |
|
|
} |
| 34 |
|
|
my @childs = $sect->childs(); |
| 35 |
|
|
if( @childs && $offset < $count_offset ) |
| 36 |
|
|
{ |
| 37 |
|
|
$offset++; |
| 38 |
|
|
foreach my $child_id (@childs) |
| 39 |
|
|
{ |
| 40 |
|
|
my $child = $CACHE->{$child_id}; |
| 41 |
|
|
select_index_tree( $child, $offset, $count_offset, $selected, $CACHE); |
| 42 |
|
|
} |
| 43 |
|
|
$offset--; |
| 44 |
|
|
} |
| 45 |
|
|
} |
| 46 |
|
|
|
| 47 |
|
|
|
| 48 |
|
|
my $CACHE = {}; |
| 49 |
|
|
my @cacher = $keeper->get_sections( light => 1 ); |
| 50 |
|
|
for my $c (@cacher) |
| 51 |
|
|
{ |
| 52 |
|
|
$CACHE->{$c->id()} = $c; |
| 53 |
|
|
} |
| 54 |
|
|
|
| 55 |
|
|
my $root_sect = $CACHE->{$root} || $CACHE->{1}; |
| 56 |
|
|
|
| 57 |
|
|
</%init> |