1 |
522 |
ahitrov |
<select name="<% $name %>" class="selects"<% $style ? ' style="'.$style.'"' : '' %>> |
2 |
386 |
ahitrov |
% select_index_tree( $root_sect, 0, $level, $check, \$color, $tree ); |
3 |
8 |
ahitrov@rambler.ru |
</select> |
4 |
|
|
<%args> |
5 |
|
|
|
6 |
522 |
ahitrov |
$name => undef |
7 |
|
|
$check => undef |
8 |
8 |
ahitrov@rambler.ru |
|
9 |
522 |
ahitrov |
$root => 1 |
10 |
|
|
$level => 15 |
11 |
|
|
$style => undef |
12 |
8 |
ahitrov@rambler.ru |
|
13 |
|
|
</%args> |
14 |
|
|
<%init> |
15 |
|
|
|
16 |
386 |
ahitrov |
my $tree; |
17 |
|
|
if ( exists $request->{"_section_tree_$root"} ) { |
18 |
|
|
$tree = $request->{"_section_tree_$root"}; |
19 |
|
|
} else { |
20 |
|
|
$tree = $keeper->get_section_tree( root_id => $root ); |
21 |
|
|
$request->{"_section_tree_$root"} = $tree; |
22 |
|
|
} |
23 |
|
|
my $root_sect = $tree->{root}; |
24 |
|
|
my $color = 0; |
25 |
|
|
|
26 |
|
|
sub select_index_tree { |
27 |
|
|
my ($sect, $offset, $count_offset, $selected, $cb, $TREE) = @_; |
28 |
|
|
return unless ref $sect; |
29 |
|
|
my $padding = 'padding-left:'.int($offset * 15).'px;'; |
30 |
|
|
my $color = $$cb ? 'background:#f0f0f0;' : ''; |
31 |
|
|
$$cb = $$cb ? 0 : 1; |
32 |
|
|
my $style = $sect->id == 1 ? ' style="background-color:#606060;color:#ffffff;'.$padding.$color.'"' : ' style="'.$padding.$color.'"'; |
33 |
|
|
my $sel = $selected && $selected == $sect->id ? ' selected' : ''; |
34 |
|
|
$m->out ('<option value="'.$sect->id.'"'.$style.$sel.'>» '.$sect->name.'</option>'."\n"); |
35 |
|
|
if ( exists $sect->{children} && $offset < $count_offset ) { |
36 |
|
|
$offset++; |
37 |
|
|
foreach my $child ( @{$sect->{children}} ) { |
38 |
|
|
select_index_tree( $child, $offset, $count_offset, $selected, $cb, $TREE ); |
39 |
8 |
ahitrov@rambler.ru |
} |
40 |
|
|
} |
41 |
386 |
ahitrov |
} |
42 |
8 |
ahitrov@rambler.ru |
|
43 |
|
|
</%init> |