Line # Revision Author
1 3 ahitrov@rambler.ru %# vim:syn=mason:
2 % index_tree( $sect->{$root}, 0, \$line, $level, $mode, $profile, $width_limit, $root );
3 <%args>
4
5 $root => 1
6 $level => 3
7 $mode => 1
8 $width_limit => undef
9 $avail_classes => undef
10
11 </%args>
12 <%init>
13 my $profile = $m->comp('/contenido/components/context.msn', name => 'profile');
14
15 sub index_tree
16 {
17 my ($sect, $offset, $line_ref, $count_offset, $viewmode, $profile, $width_limit, $root) = @_;
18 my $section_access = $user->section_accesses($user, $sect->{id});
19
20 my $spacer = '';
21 for(my $c=1; $c<$offset; $c++)
22 {
23 $spacer = $spacer.(($c == $offset-1) ? '&nbsp;&nbsp;&raquo;&nbsp;&nbsp;' : '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
24 }
25 if( ref $sect && $sect->id && ($sect->id != 1) && ($offset != 0) && $section_access > 0)
26 {
27 $$line_ref++;
28
29 my $href = 'sections.html?id='.$sect->id;
30
31 my $sname = $sect->name();
32 $sname =~ s/<\/?.+?>//g;
33 $sname = substr($sname, 0, $width_limit - $offset).' ...' if defined $width_limit && $offset + length($sname) > $width_limit;
34 my $statstyle = $sect->contenido_status_style ? ' style="' . $sect->contenido_status_style . '"' : '';
35 my @properties = $sect->structure();
36 my ($statprop) = grep { $_->{attr} eq 'status' } @properties;
37 my ($statcase) = grep { $_->[0] == $sect->status } @{$statprop->{cases}} if exists $statprop->{cases} && ref $statprop->{cases} eq 'ARRAY';
38 my $statname = $statcase->[1] if ref $statcase;
39 my $html_sect = '<span'.($statstyle).(!$sect->status ? ' class="hiddensect"' : '').'>'.($section_access ? '<a href="'.$href.'"'.$statstyle.'>' : '').$sname.'&nbsp;' . ($section_access ? '</a>' : '') . '&nbsp;'.($sect->status != 1 && $statname ? '&nbsp;<span style="font-size:12px;">('.$statname.')</span>' : '').'</span>';
40 my $style = ($offset == 1) ? ($viewmode ? ' style="font-size:110%;"':' style="font-size:95%;"') : '';
41
42 $m->out(<<EOT);
43 <tr>
44 <td align="right">&nbsp;${$line_ref}&nbsp;<a href="section.html?id=$sect->{id}&move=up&ret=$root"><img src="/contenido/i/ico-up-9x10.gif" border=0 alt="����������� ������ �� ��� �����"></a>&nbsp;<a href="section.html?id=$sect->{id}&move=down&ret=$root"><img src="/contenido/i/ico-down-9x10.gif" border=0 alt="����������� ������ �� ��� ����"></a></td>
45 <td><table cellpadding="0" cellspacing="0" border="0">
46 <tr valign="top">
47 <td width="10">&nbsp;</td>
48 <td>$spacer</td>
49 <td nowrap $style>$html_sect</td>
50 </tr>
51 </table>
52 </td>
53 EOT
54
55 if ($viewmode)
56 {
57 my $fhref = '/contenido/?set_context=filter-'.$sect->id();
58 my $new_doc_class = $sect->default_document_class;
59 $m->out(qq^\n<td align="center" nowrap><a href="$fhref">���.������</a>^);
60 $m->out(qq^&nbsp;&nbsp;&nbsp;<a href="document.html?sect_id=$sect->{id}&class=$new_doc_class">���.�����</a>^) if $section_access == 2 and $new_doc_class;
61 $m->out("</td>");
62 }
63
64 $m->out('</tr>');
65 }
66
67 my $childs = $sect->{children} || [];
68 if( ref($childs) && @$childs && $offset < $count_offset )
69 {
70 $offset++;
71 foreach my $child (@$childs)
72 {
73 next if (! $request->{cCLASSES}->{$child->class()});
74 index_tree( $child, $offset, $line_ref, $count_offset, $viewmode, $profile, $width_limit, $root );
75 }
76 $offset--;
77 }
78 }
79
80 $request->{cCLASSES} = {};
81 my @avail_classes;
82 if ( ref $avail_classes eq 'ARRAY' && @$avail_classes ) {
83 map { $request->{cCLASSES}->{$_} = 1 } @$avail_classes;
84 @avail_classes = @$avail_classes;
85 } elsif (ref($request->{tab}->{sections})) {
86 map { $request->{cCLASSES}->{$_} = 1 } (@{ $request->{tab}->{sections} });
87 return undef if (scalar(keys(%{ $request->{cCLASSES} })) == 0);
88 @avail_classes = keys( %{ $request->{cCLASSES} } );
89 }
90 push @avail_classes, 'Contenido::Section' unless exists $request->{cCLASSES}{'Contenido::Section'};
91 my $sect = $keeper->get_section_tree(root=>$root, class => \@avail_classes);
92 return undef unless ref $sect && exists $sect->{$root};
93
94 $user->get_accesses();
95
96 my $line = 0;
97
98 </%init>