Line # Revision Author
1 196 ahitrov %# vim:syn=mason:
2 % users_index_tree( $sect, 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
15 </%args>
16 <%init>
17 my $profile = $m->comp('/contenido/components/context.msn', name => 'profile');
18
19 sub users_index_tree
20 {
21 my ($sect, $offset, $line_ref, $count_offset, $viewmode, $profile, $width_limit, $root) = @_;
22 my $section_access = $user->section_accesses($user, $sect->{id});
23
24 my $spacer = '';
25 for(my $c=1; $c<$offset; $c++)
26 {
27 $spacer = $spacer.(($c == $offset-1) ? '&nbsp;&nbsp;&raquo;&nbsp;&nbsp;' : '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;');
28 }
29 if( $sect->{id} && ($sect->{id} != 1) && ($offset != 0) && $section_access > 0)
30 {
31 $$line_ref++;
32
33 my $href = 'sections.html?id='.$sect->id;
34
35 my $sname = decode("utf-8", $sect->name());
36 if ( defined $width_limit && $offset + length($sname) > $width_limit ) {
37 $sname = substr($sname, 0, $width_limit - $offset);
38 $sname .= '&nbsp;...';
39 }
40 $sname = encode("utf-8", $sname);
41 my $statstyle = $sect->contenido_status_style ? ' style="' . $sect->contenido_status_style . '"' : '';
42 my @properties = $sect->structure();
43 my ($statprop) = grep { $_->{attr} eq 'status' } @properties;
44 my ($statcase) = grep { $_->[0] == $sect->status } @{$statprop->{cases}} if exists $statprop->{cases} && ref $statprop->{cases} eq 'ARRAY';
45 my $statname = $statcase->[1] if ref $statcase;
46 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>';
47 my $style = ($offset == 1) ? ($viewmode ? ' style="font-size:110%;"':' style="font-size:95%;"') : '';
48
49 $m->out(<<EOT);
50 <tr>
51 <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>
52 <td><table cellpadding="0" cellspacing="0" border="0">
53 <tr valign="top">
54 <td width="10">&nbsp;</td>
55 <td>$spacer</td>
56 <td nowrap $style>$html_sect</td>
57 </tr>
58 </table>
59 </td>
60 EOT
61
62 if ($viewmode)
63 {
64 my $fhref = '/contenido/?set_context=filter-'.$sect->id();
65 $m->out(qq^\n<td align="center" nowrap><a href="$fhref">уст.фильтр</a>^);
66 $m->out(qq^&nbsp;&nbsp;&nbsp;<a href="document.html?sect_id=$sect->{id}">доб.докум</a>^) if $section_access == 2;
67 $m->out("</td>");
68 }
69
70 $m->out('</tr>');
71 }
72
73 my $childs = $sect->{childs} || [];
74 if( ref($childs) && @$childs && $offset < $count_offset )
75 {
76 $offset++;
77 foreach my $child (@$childs)
78 {
79 next if ( $child->class() ne 'users::Section' );
80 next if (! $request->{cCLASSES}->{$child->class()});
81 users_index_tree( $child, $offset, $line_ref, $count_offset, $viewmode, $profile, $width_limit, $root );
82 }
83 $offset--;
84 }
85 }
86
87 my $sect = $keeper->get_tree(light=>1, root=>$root);
88 return undef unless ref $sect;
89
90 $user->get_accesses();
91
92 my $line = 0;
93 $request->{cCLASSES} = {};
94 $request->{cCLASSES}->{'users::Section'} = 1;
95 if (ref($request->{tab}->{sections}))
96 {
97 map { $request->{cCLASSES}->{$_} = 1 } (@{ $request->{tab}->{sections} });
98 }
99 return undef if (scalar(keys(%{ $request->{cCLASSES} })) == 0);
100
101 </%init>