Line # Revision Author
1 8 ahitrov@rambler.ru <& "/contenido/components/title.msn" &>
2 <style>
3 <!--
4 fieldset { font:11px Verdana; }
5 fieldset table { font:11px Verdana; }
6 fieldset table td { padding:1px 4px; }
7 fieldset table th { font:bold 10px Verdana; padding:1px 2px; }
8 div.pad_active { font-weight:bold; padding:3px 4px; border-bottom:2px solid gray; float:left;
9 border-right:1px solid gray; background:#f0f0f0; border-top:1px solid #f0f0f0; border-left:1px solid #f0f0f0; }
10 div.pad_passive { padding:3px 4px; border-bottom:2px solid gray; float:left;
11 border-right:1px solid gray; background:#d0d0d0; border-top:1px solid #f0f0f0; border-left:1px solid #f0f0f0; };
12 -->
13 </style>
14 <script type="text/javascript">
15 <!--
16 function switch_div (sName) {
17 var oDiv = document.getElementById(sName);
18 var oDivPrompt = document.getElementById(sName + '_hidden');
19 if ( oDiv.style.display == 'block' ) {
20 oDiv.style.display = 'none';
21 oDivPrompt.style.display = 'block';
22 } else {
23 oDiv.style.display = 'block';
24 oDivPrompt.style.display = 'none';
25 }
26 }
27 //-->
28 </script>
29 % if ($document) {
30 % if ( @sources ) {
31 % my $show = (@sources && $link_class && grep { $_ eq $link_class } @sources) || ((@sources && @destinations) || !@destinations) ? 1 : 0;
32 % my $lclass = $link_class;
33 % if ( $link_class && grep { $_ eq $link_class } @destinations ) {
34 % $show = 0;
35 % $lclass = undef;
36 % }
37 <fieldset>
38 <legend>&rarr; <a href="javascript:switch_div('div_source')" style="color:white;"
39 onclick="switch_div('div_source'); return false;">Связи, ведущие от этого документа:</a></legend>
40 <div id="div_source" style="display:<% $show ? 'block' : 'none' %>">
41 <& "/contenido/components/document_links_block.msn",
42 document => $document, lclasses => \@sources, class => $lclass, p => $p,
43 link_id_name => 'source_id',
44 link_class_name => 'source_class'
45 &>
46 </div>
47 <div id="div_source_hidden" style="display:<% $show ? 'none' : 'block' %>; padding:5px;"><a href="javascript:switch_div('div_source')"
48 onclick="switch_div('div_source'); return false;">Содержимое скрыто</a></div>
49 </fieldset>
50 % }
51 % if ( @destinations ) {
52 % my $show = (@destinations && $link_class && grep { $_ eq $link_class } @destinations ) || !@sources ? 1 : 0;
53 % my $lclass = $link_class;
54 % if ( $link_class && grep { $_ eq $link_class } @sources ) {
55 % $show = 0;
56 % $lclass = undef;
57 % }
58 <fieldset>
59 <legend>&larr; <a href="javascript:switch_div('div_destination')" style="color:white;"
60 onclick="switch_div('div_destination'); return false;">Связи, ведущие к этому документу:</a></legend>
61 <div id="div_destination" style="display:<% $show ? 'block' : 'none' %>">
62 <& "/contenido/components/document_links_block.msn",
63 document => $document, lclasses => \@destinations, class => $lclass, p => $p,
64 link_id_name => 'dest_id',
65 link_class_name => 'dest_class'
66 &>
67 </div>
68 <div id="div_destination_hidden" style="display:<% $show ? 'none' : 'block' %>; padding:5px;"><a href="javascript:switch_div('div_destination')"
69 onclick="switch_div('div_destination'); return false;">Содержимое скрыто</a></div>
70 </fieldset>
71 % }
72 % } else {
73 <p><font color="red">Не могу получить документ по данным id=<% $id %> и class=<% $class %></font></p>
74 % }
75 </body>
76 </html>
77
78 <%ARGS>
79
80 $p => 1
81 $class => undef
82 $id => undef
83 $link_class => undef
84
85 </%ARGS>
86
87 <%INIT>
88 return unless ($state->{available_links} and @{$state->{available_links}});
89 my $document;
90 my (@sources, @destinations);
91 if ($id && ($id !~ /\D/) && ($id > 0)) {
92 $document = $keeper->get_document_by_id($id, class=>$class);
93 }
94 if ( ref $document ) {
95 foreach my $classlink ( @{ $state->{available_links} } ) {
96 my $sources = $classlink->available_sources;
97 if ( ref $sources eq 'ARRAY' && @$sources ) {
98 push @sources, $classlink if grep { $document->class eq $_ } @$sources;
99 }
100 my $dests = $classlink->available_destinations;
101 if ( ref $dests eq 'ARRAY' && @$dests ) {
102 push @destinations, $classlink if grep { $document->class eq $_ } @$dests;
103 }
104 }
105 }
106 </%INIT>
107