Line # Revision Author
1 8 ahitrov@rambler.ru %# vim:syn=mason:
2 % index_tree( $sect->{$root}, 0, \$line, $level, $mode, $profile, $width_limit, $root );
3 <%once>
4
5 use Encode;
6
7 </%once>
8 <%args>
9
10 $root => 1
11 $level => 3
12 $mode => 1
13 $width_limit => undef
14 $avail_classes => undef
15
16 </%args>
17 <%init>
18 my $profile = $m->comp('/contenido/components/context.msn', name => 'profile');
19
20 sub index_tree
21 {
22 my ($sect, $offset, $line_ref, $count_offset, $viewmode, $profile, $width_limit, $root) = @_;
23 my $section_access = $user->section_accesses($user, $sect->{id});
24
25 my $spacer = '';
26 for(my $c=1; $c<$offset; $c++)
27 {
28 $spacer = $spacer.(($c == $offset-1) ? '&nbsp;&nbsp;&raquo;&nbsp;&nbsp;' : '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
29 }
30 if( ref $sect && $sect->id && ($sect->id != 1) && ($offset != 0) && $section_access > 0)
31 {
32 $$line_ref++;
33
34 my $href = 'sections.html?id='.$sect->id;
35
36 my $sname = decode("utf-8", $sect->name());
37 if ( defined $width_limit && $offset + length($sname) > $width_limit ) {
38 522 ahitrov $sname =~ s/<[^>]+>//sgi;
39 8 ahitrov@rambler.ru $sname = substr($sname, 0, $width_limit - $offset);
40 $sname .= '&nbsp;...';
41 }
42 $sname = encode("utf-8", $sname);
43 my $statstyle = $sect->contenido_status_style ? ' style="' . $sect->contenido_status_style . '"' : '';
44 my @properties = $sect->structure();
45 my ($statprop) = grep { $_->{attr} eq 'status' } @properties;
46 my ($statcase) = grep { $_->[0] == $sect->status } @{$statprop->{cases}} if exists $statprop->{cases} && ref $statprop->{cases} eq 'ARRAY';
47 my $statname = $statcase->[1] if ref $statcase;
48 my $html_sect = '<span'.($statstyle).(!$sect->status ? ' class="hiddensect"' : '').'>'.($section_access ? '<a href="'.$href.'"'.$statstyle.'>' : '').$sname.($section_access ? '</a>' : '') . '&nbsp;'.($sect->status != 1 && $statname ? '&nbsp;<span style="font-size:11px;">('.$statname.')</span>' : '').'</span>';
49 120 ahitrov my $style = ($offset == 1) ? ($viewmode ? ' style="font-size:16px;font-weight:bold;"':' style="font-size:14px;"') : ' style="font-size:12px;"';
50 8 ahitrov@rambler.ru
51 522 ahitrov $m->out( $m->scomp( '.table_row.msn',
52 sect => $sect,
53 root => $root,
54 style => $style,
55 spacer => $spacer,
56 viewmode => $viewmode,
57 html_sect => $html_sect,
58 line_ref => $line_ref,
59 section_access => $section_access,
60 )
61 );
62 8 ahitrov@rambler.ru
63 }
64
65 my $childs = $sect->{children} || [];
66 if( ref($childs) && @$childs && $offset < $count_offset )
67 {
68 $offset++;
69 foreach my $child (@$childs)
70 {
71 next if (! $request->{cCLASSES}->{$child->class()});
72 index_tree( $child, $offset, $line_ref, $count_offset, $viewmode, $profile, $width_limit, $root );
73 }
74 $offset--;
75 }
76 }
77
78 $request->{cCLASSES} = {};
79 my @avail_classes;
80 if ( ref $avail_classes eq 'ARRAY' && @$avail_classes ) {
81 map { $request->{cCLASSES}->{$_} = 1 } @$avail_classes;
82 @avail_classes = @$avail_classes;
83 } elsif (ref($request->{tab}->{sections})) {
84 map { $request->{cCLASSES}->{$_} = 1 } (@{ $request->{tab}->{sections} });
85 return undef if (scalar(keys(%{ $request->{cCLASSES} })) == 0);
86 @avail_classes = keys( %{ $request->{cCLASSES} } );
87 }
88 push @avail_classes, 'Contenido::Section' unless exists $request->{cCLASSES}{'Contenido::Section'};
89 510 ahitrov my $sect = $keeper->get_section_tree(root=>$root, class => \@avail_classes, light => undef);
90 8 ahitrov@rambler.ru return undef unless ref $sect && exists $sect->{$root};
91
92 $user->get_accesses();
93
94 my $line = 0;
95
96 </%init>
97 522 ahitrov
98 <%def .table_row.msn>
99 <%args>
100
101 $sect => undef
102 $root => undef
103 $style => ''
104 $spacer => ''
105 $viewmode => undef
106 $html_sect => ''
107 $line_ref => undef
108 $section_access => undef
109
110 </%args>
111 <%init>
112
113 my ($fhref, $new_doc_class);
114 if ( $viewmode ) {
115 $fhref = '/contenido/?set_context=filter-'.$sect->id;
116 $new_doc_class = $sect->default_document_class;
117 }
118
119 </%init>
120 <tr>
121 <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>
122 <td><table cellpadding="0" cellspacing="0" border="0">
123 <tr valign="top">
124 <td width="10">&nbsp;</td>
125 <td><% $spacer %></td>
126 <td nowrap <% $style %>><% $html_sect %></td>
127 </tr>
128 </table>
129 </td>
130 % if ( $viewmode ) {
131 <td align="center" nowrap>
132 <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;<a
133 href="$fhref">фильтр</a>\
134 % if ( $section_access == 2 and $new_doc_class ) {
135 &nbsp;&nbsp;&nbsp;<a href="document.html?sect_id=<% $sect->id %>&class=<% $new_doc_class %>">доб.докум</a>\
136 % }
137 </td>
138 % } else {
139 <td align="center" nowrap><a href="section.html?id=<% $sect->id %>" title="Редактировать параметры секции"><img src="/contenido/i/actions/edit.gif" width="15" height="17" align="absmiddle" border="0"></a></td>
140 % }
141 </tr>
142 </%def>