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 121 ahitrov my $style = ($offset == 1) ? ($viewmode ? ' style="font-size:16px;font-weight:bold;"':' style="font-size:14px;"') : ' style="font-size:12px;"';
41 3 ahitrov@rambler.ru
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 121 ahitrov 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>^);
60 $m->out(qq^<a href="section.html?id=$sect->{id}" title="������������� ��������� ������"><img src="/contenido/i/actions/edit.gif" width="15" height="17" align="absmiddle" border="0"></a>&nbsp;&nbsp;&nbsp;^);
61 $m->out(qq^<a href="$fhref">������</a>^);
62 $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;
63 $m->out("</td>");
64 3 ahitrov@rambler.ru }
65
66 $m->out('</tr>');
67 }
68
69 my $childs = $sect->{children} || [];
70 if( ref($childs) && @$childs && $offset < $count_offset )
71 {
72 $offset++;
73 foreach my $child (@$childs)
74 {
75 next if (! $request->{cCLASSES}->{$child->class()});
76 index_tree( $child, $offset, $line_ref, $count_offset, $viewmode, $profile, $width_limit, $root );
77 }
78 $offset--;
79 }
80 }
81
82 $request->{cCLASSES} = {};
83 my @avail_classes;
84 if ( ref $avail_classes eq 'ARRAY' && @$avail_classes ) {
85 map { $request->{cCLASSES}->{$_} = 1 } @$avail_classes;
86 @avail_classes = @$avail_classes;
87 } elsif (ref($request->{tab}->{sections})) {
88 map { $request->{cCLASSES}->{$_} = 1 } (@{ $request->{tab}->{sections} });
89 return undef if (scalar(keys(%{ $request->{cCLASSES} })) == 0);
90 @avail_classes = keys( %{ $request->{cCLASSES} } );
91 }
92 push @avail_classes, 'Contenido::Section' unless exists $request->{cCLASSES}{'Contenido::Section'};
93 my $sect = $keeper->get_section_tree(root=>$root, class => \@avail_classes);
94 return undef unless ref $sect && exists $sect->{$root};
95
96 $user->get_accesses();
97
98 my $line = 0;
99
100 </%init>