1 |
8 |
ahitrov@rambler.ru |
<script language="JavaScript"><!-- |
2 |
|
|
var dom = (document.getElementById) ? true : false; |
3 |
|
|
var nn4 = (document.layers) ? true : false; |
4 |
|
|
var ie4 = (!dom && document.all) ? true : false; |
5 |
|
|
var layerOk; |
6 |
|
|
|
7 |
|
|
if( dom || ie4 || nn4 ) { |
8 |
|
|
layerOk = 1; |
9 |
|
|
} else { |
10 |
|
|
layerOk = 0; |
11 |
|
|
} |
12 |
|
|
|
13 |
|
|
var layerRef, styleRef, showVar, hideVar, showDVar, hideDVar; |
14 |
|
|
var srcOpen = '/contenido/i/open11x11.gif'; |
15 |
|
|
var srcClose = '/contenido/i/close11x11.gif'; |
16 |
|
|
|
17 |
|
|
var imageRef; |
18 |
|
|
|
19 |
|
|
if( nn4 ) { |
20 |
|
|
layerRef = "document.layers."; |
21 |
|
|
styleRef = ""; |
22 |
|
|
imageRef = ""; |
23 |
|
|
showDVar = "'block'"; |
24 |
|
|
hideDVar = "'none'"; |
25 |
|
|
showVar = "'show'"; |
26 |
|
|
hideVar = "'hide'"; |
27 |
|
|
} else { |
28 |
|
|
layerRef = "document.all."; |
29 |
|
|
imageRef = ""; |
30 |
|
|
styleRef = ".style"; |
31 |
|
|
showDVar = "'block'"; |
32 |
|
|
hideDVar = "'none'"; |
33 |
|
|
showVar = "'visible'"; |
34 |
|
|
hideVar = "'hidden'"; |
35 |
|
|
} |
36 |
|
|
|
37 |
|
|
if( dom ) { |
38 |
|
|
layerRef = "document.getElementById('"; |
39 |
|
|
styleRef = "').style"; |
40 |
|
|
imageRef = "')"; |
41 |
|
|
} |
42 |
|
|
|
43 |
|
|
function changeDiv( divID ) { |
44 |
|
|
if( eval( layerRef+'slinks'+divID+styleRef+'.visibility' ) == 'hidden' ) { |
45 |
|
|
showDiv( divID ); |
46 |
|
|
} else { |
47 |
|
|
hideDiv( divID ); |
48 |
|
|
} |
49 |
|
|
} |
50 |
|
|
|
51 |
|
|
function showDiv( divID ) { |
52 |
|
|
if( layerOk ) { |
53 |
|
|
eval( layerRef+'slinks'+divID+styleRef+'.visibility=' + showVar ); |
54 |
|
|
eval( layerRef+'slinks'+divID+styleRef+'.display=' + showDVar ); |
55 |
|
|
eval( layerRef+'simg'+divID+imageRef+'.src = "' + srcClose + '"' ); |
56 |
|
|
} |
57 |
|
|
} |
58 |
|
|
|
59 |
|
|
function hideDiv( divID ) { |
60 |
|
|
if( layerOk ) { |
61 |
|
|
eval( layerRef+'slinks'+divID+styleRef+'.visibility=' + hideVar ); |
62 |
|
|
eval( layerRef+'slinks'+divID+styleRef+'.display=' + hideDVar ); |
63 |
|
|
eval( layerRef+'simg'+divID+imageRef+'.src = "' + srcOpen + '"' ); |
64 |
|
|
} |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
//--> |
68 |
|
|
</script> |
69 |
|
|
<fieldset> |
70 |
|
|
<legend>Принадлежность к рубрикам (разделам) сайта<sup>1</sup></legend> |
71 |
|
|
<table height="400" border=0><tr valign="top"><td> |
72 |
|
|
<form action="store_document_sections.html" method="POST"> |
73 |
|
|
<input type="submit" value="Сохранить привязки" class="input_btn"> |
74 |
|
|
% my @sections = $document->sections(); |
75 |
|
|
% my $document_sections = @sections ? $keeper->get_sections ( id => \@sections, return_mode => 'hash_ref' ) : {}; |
76 |
|
|
% my $sections_ = {}; |
77 |
|
|
% $sections_->{$section_tree->{root}->id} = 1 if exists $section_tree->{root}; |
78 |
|
|
% for my $secti (@sections) { |
79 |
|
|
% $sections_->{ $secti } = 1; |
80 |
|
|
% my $sect = exists $document_sections->{$secti} ? $document_sections->{$secti} : undef; |
81 |
|
|
% next unless ref $sect; |
82 |
|
|
% while ( $sect->pid != 1 && (exists $section_tree->{$sect->pid} && (exists $section_tree->{root} && $section_tree->{$sect->pid} != $section_tree->{root}) || ( !exists $section_tree->{root} && $section_tree->{$sect->pid} != $section_tree->{0} ) ) ) { |
83 |
|
|
% $sections_->{ $sect->pid } = 1; |
84 |
|
|
% $sect = $section_tree->{$sect->pid}; |
85 |
|
|
% } |
86 |
|
|
% } |
87 |
|
|
% my @fullsections = keys(%{ $sections_ }); |
88 |
|
|
<ul style="font-size:13px;font-family:Tahoma;"> |
89 |
|
|
% tree( $section_tree->{root}, $section_tree, \@fullsections, \@sections, 0 ); |
90 |
|
|
</ul> |
91 |
|
|
|
92 |
|
|
<input type="hidden" name="id" value="<% $document->id %>"> |
93 |
|
|
<input type="hidden" name="class" value="<% $document->class %>"> |
94 |
|
|
<input type="submit" value="Сохранить привязки" class="input_btn"> |
95 |
|
|
</form> |
96 |
|
|
</td></tr></table> |
97 |
|
|
</fieldset> |
98 |
|
|
|
99 |
|
|
<!-- Примечания --> |
100 |
|
|
<fieldset> |
101 |
|
|
<legend>Примечания</legend> |
102 |
|
|
|
103 |
|
|
<table width="100%" cellspacing="5" cellpadding="0" class="tform" height="100"> |
104 |
|
|
<tr> |
105 |
|
|
<th valign=top>1)</th> |
106 |
|
|
<td width="100%">Символом <img src="/contenido/i/checkbox-14x14.gif" width="14" height="14" alt="checkbox" align="absmiddle"> показаны привязки к рубрикам (может быть несколько рубрик);<br></td> |
107 |
|
|
</tr> |
108 |
|
|
<tr> |
109 |
|
|
<th valign=top>1)</th> |
110 |
|
|
<td width="100%">Символом <img src="/contenido/i/radio-14x14.gif" width="14" height="14" alt="radio buttom" align="absmiddle"> показана главная (не обязательно корневая) рубрика.<br></td> |
111 |
|
|
</tr> |
112 |
|
|
</table> |
113 |
|
|
</fieldset> |
114 |
|
|
|
115 |
|
|
|
116 |
|
|
<%ARGS> |
117 |
|
|
|
118 |
|
|
$document => undef |
119 |
|
|
|
120 |
|
|
</%ARGS> |
121 |
|
|
<%INIT> |
122 |
|
|
return undef if (! ref($document)); |
123 |
|
|
return undef unless ($document->{attributes}->{sections}); |
124 |
|
|
|
125 |
|
|
my $root_section = $keeper->get_section_by_id( $Contenido::Section::ROOT || 1, light => 1 ); |
126 |
|
|
my $section_tree = exists $request->{section_tree} ? $request->{section_tree} : $keeper->get_section_tree(); |
127 |
|
|
$request->{section_tree} ||= $section_tree; |
128 |
|
|
|
129 |
|
|
sub tree |
130 |
|
|
{ |
131 |
|
|
my ($sect, $section_tree, $fullsections, $sections, $depth) = @_; |
132 |
|
|
my $count_checked = 0; |
133 |
|
|
|
134 |
|
|
my @childs; |
135 |
|
|
|
136 |
|
|
if (ref $sect && $sect->id) { |
137 |
|
|
@childs = ref $section_tree && exists $section_tree->{$sect->id} ? @{ $section_tree->{$sect->id}{children} } : (); |
138 |
|
|
my $checked = (grep {$_ == $sect->id } @{ $sections }) ? ' checked' : ''; |
139 |
|
|
my $main = ($sect->id == $sections->[0]) ? ' checked' : ''; |
140 |
|
|
$count_checked++ if( grep {$_ == $sect->{id} } @{ $fullsections } ); |
141 |
|
|
|
142 |
|
|
if( @childs && $sect->id != 1) { |
143 |
|
|
$m->out("<a title=\"Раскрыть/закрыть\" style=\"width:22px;text-decoration:none;\" href=\"javascript:changeDiv('$sect->{id}');\"><img id=\"simg$sect->{id}\" src=\"/contenido/i/open11x11.gif\" width=\"11\" height=\"11\" border=\"0\"></a>"); |
144 |
|
|
} else { |
145 |
|
|
$m->out( '<span style="width:22px;"></span>' ); |
146 |
|
|
} |
147 |
|
|
$m->out("<input type=\"checkbox\" name=\"section_$sect->{id}\" value=\"1\" $checked><input type=\"radio\" name=\"main_section\" value=\"$sect->{id}\"$main>"); |
148 |
|
|
$m->out("$sect->{name}<br>\n"); |
149 |
|
|
} |
150 |
|
|
|
151 |
|
|
if (@childs) { |
152 |
|
|
my $check_childs = undef; |
153 |
|
|
if( $depth > 0 ) { |
154 |
|
|
$m->out( '<div style="visibility:hidden;display:none;" id="slinks'.$sect->id.'">'."\n" ); |
155 |
|
|
} |
156 |
|
|
$m->out( '<ul>'."\n" ); |
157 |
|
|
foreach my $child (@childs) { |
158 |
|
|
$check_childs += tree( $child, $section_tree, $fullsections, $sections, $depth+1 ); |
159 |
|
|
} |
160 |
|
|
$m->out("</ul>\n"); |
161 |
|
|
if( $depth > 0 ) { |
162 |
|
|
$m->out( '</div>'."\n" ); |
163 |
|
|
} |
164 |
|
|
if( $check_childs > 0 && $sect->id != 1) { |
165 |
|
|
$m->out( "<script language=\"JavaScript\"><!--\nshowDiv('$sect->{id}');\n//-->\n</script>\n" ); |
166 |
|
|
} |
167 |
|
|
} |
168 |
|
|
|
169 |
|
|
return $count_checked; |
170 |
|
|
} |
171 |
|
|
|
172 |
|
|
</%INIT> |