1 |
8 |
ahitrov@rambler.ru |
<!-- Форма для редактирования объекта --> |
2 |
|
|
<a name="top"></a> |
3 |
374 |
ahitrov |
|
4 |
|
|
% if ( $m->comp_exists ('/contenido/components/object_context_form.msn') ) { |
5 |
|
|
<div style="text-align:right;"><& '/contenido/components/object_context_form.msn', object => $object &></div> |
6 |
|
|
% } |
7 |
|
|
|
8 |
440 |
ahitrov |
<form enctype="multipart/form-data" action="<% $PROTOS->{$proto}->[1] %>" method="POST" name="form" onSubmit="return Save(this)"> |
9 |
8 |
ahitrov@rambler.ru |
<table border="0" width="100%" cellspacing="0" cellpadding="6"> |
10 |
|
|
<tr> |
11 |
|
|
<td style="font-size:110%;"> |
12 |
|
|
<b><% (ref($object) && $object->id() ) ? 'Редактирование' : 'Создание' %> <% $PROTOS->{$proto}->[0] %> типа "<% $object->class_name() %>"</b> |
13 |
645 |
ahitrov |
% if ( $object->get_url ) { |
14 |
646 |
ahitrov |
<div style="margin-top:5px; font-size:85%;">Ссылка: <a href="<% $object->get_url %>" target="_blank"><% $object->get_url %></a></div> |
15 |
645 |
ahitrov |
% } |
16 |
8 |
ahitrov@rambler.ru |
</td> |
17 |
|
|
<td align="right"> |
18 |
|
|
% unless ( $proto eq 'sections' && $object->id == 1 ) { |
19 |
|
|
<input type="submit" value="Сохранить" class="input_btn"> |
20 |
|
|
% if (( $proto eq 'documents' ) || ( $proto eq 'sections' )) { |
21 |
795 |
ahitrov |
<script> |
22 |
|
|
<!-- |
23 |
|
|
var isCtrlPressed = false; |
24 |
|
|
$().ready(function(){ |
25 |
|
|
$(document).keyup(function (e) { |
26 |
|
|
if (e.which == 17) isCtrlPressed=false; |
27 |
|
|
}).keydown(function (e) { |
28 |
|
|
if (e.which == 17) { |
29 |
|
|
isCtrlPressed=true; |
30 |
|
|
} |
31 |
|
|
if (e.which == 81 && isCtrlPressed == true) { |
32 |
|
|
$('#save-and-leave').click(); |
33 |
|
|
} |
34 |
|
|
}); |
35 |
|
|
}); |
36 |
|
|
//--> |
37 |
|
|
</script> |
38 |
|
|
<input type="submit" name="_save_and_leave" value="Сохранить и выйти" class="input_btn" id="save-and-leave"> |
39 |
8 |
ahitrov@rambler.ru |
<input type="submit" name="_save_and_again" value="Сохранить и создать новый" class="input_btn"> |
40 |
|
|
% } |
41 |
|
|
% } |
42 |
|
|
</td> |
43 |
|
|
</tr> |
44 |
|
|
</table> |
45 |
|
|
|
46 |
|
|
% if ( $m->comp_exists ('/contenido/components/object_context_menu.msn') ) { |
47 |
|
|
<div style="text-align:right;"><& '/contenido/components/object_context_menu.msn', object => $object &></div> |
48 |
|
|
% } |
49 |
|
|
|
50 |
|
|
<center> |
51 |
|
|
<table width="100%" cellpadding="0" cellspacing="0" border="0"> |
52 |
|
|
<tr> |
53 |
|
|
<td bgcolor="#999999"> |
54 |
|
|
<table width="100%" cellpadding="0" cellspacing="1" border="0"> |
55 |
|
|
<tr><td valign="top" width="80%" bgcolor="#ffffff"> |
56 |
|
|
<center> |
57 |
|
|
<table width="98%" cellpadding="1" cellspacing="0" border="0"> |
58 |
|
|
|
59 |
|
|
<%perl> |
60 |
|
|
|
61 |
|
|
my @properties = $object->structure(); |
62 |
|
|
|
63 |
|
|
for (0..$#properties) |
64 |
|
|
{ |
65 |
|
|
|
66 |
|
|
my $prop = $properties[$_]; |
67 |
271 |
ahitrov |
my $name = $prop->{attr}; |
68 |
528 |
ahitrov |
next if ($prop->{hidden} == 1) || ($prop->{type} eq 'external') || ($prop->{type} =~ /^array/i) || ($prop->{type} =~ /^image/) || ($prop->{type} eq 'multimedia') || ($prop->{type} eq 'multimedia_new') || ($prop->{type} eq 'multimedia_multi') || ($prop->{type} eq 'audio'); |
69 |
8 |
ahitrov@rambler.ru |
|
70 |
|
|
</%perl> |
71 |
|
|
<tr><td height="8"></td></tr> |
72 |
|
|
<tr><td nowrap> |
73 |
|
|
<table cellpadding="0" cellspacing="0" border="0"> |
74 |
|
|
<tr> |
75 |
493 |
ahitrov |
% if ( $prop->{type} eq 'flag' || $prop->{type} eq 'checkbox' ) { |
76 |
271 |
ahitrov |
<td><& "/contenido/components/inputs/checkbox.msn", prop => $prop, object=>$object, options=>$options, name => $name, check => ($object->$name || $object->{$name}), id => $object->id() &></td> |
77 |
8 |
ahitrov@rambler.ru |
% } |
78 |
|
|
<td nowrap><b><% $prop->{rusname} %></b> /</td> |
79 |
|
|
<td align="right" nowrap><font color="#888888" size="-1"> name="<% $prop->{attr} %>"</font></td> |
80 |
493 |
ahitrov |
% if ( $prop->{readonly} ) { |
81 |
8 |
ahitrov@rambler.ru |
<td align="right" nowrap> / <font color="#CC0000" size="-1">Значение нельзя изменить</font></td> |
82 |
|
|
% } |
83 |
|
|
</tr> |
84 |
|
|
</table> |
85 |
|
|
</td></tr> |
86 |
418 |
ahitrov |
% if ($prop->{type} eq 'parent') { |
87 |
271 |
ahitrov |
<tr><td><& "/contenido/components/inputs/$prop->{type}.msn", prop => $prop, object=>$object, options=>$options, name => $name, check => ($object->$name || $prop->{default} || $sect_id ), id => $object->id() &></td></tr> |
88 |
418 |
ahitrov |
% } elsif( ( $prop->{type} ne 'flag' ) && ($prop->{type} ne 'checkbox') ) { |
89 |
|
|
% if ( $m->comp_exists( "/contenido/components/inputs/$prop->{type}.msn" ) ) { |
90 |
271 |
ahitrov |
<tr><td><& "/contenido/components/inputs/$prop->{type}.msn", prop => $prop, object=>$object, options => $options, name => $name, check => ($object->$name || $object->{$name}), id => ($object->id() || 0) &></td></tr> |
91 |
418 |
ahitrov |
% } else { |
92 |
|
|
<tr><td style="color:red">Попытка вызвать компоненту неизвестного типа (<% Dumper $prop %>)</td></tr> |
93 |
|
|
% } |
94 |
8 |
ahitrov@rambler.ru |
% } |
95 |
493 |
ahitrov |
% if ( exists $prop->{rem} && $prop->{rem} ) { |
96 |
|
|
<tr><td><div style="color:gray; font-size:85%; padding:4px">» <% $prop->{rem} %></div></td></tr> |
97 |
|
|
% } |
98 |
8 |
ahitrov@rambler.ru |
% } |
99 |
|
|
<tr> |
100 |
|
|
<td><br> |
101 |
|
|
|
102 |
|
|
% for (0..$#properties) |
103 |
|
|
% { |
104 |
|
|
% my $prop = $properties[$_]; |
105 |
|
|
% next if ($prop->{hidden} != 1); |
106 |
|
|
% next if ($prop->{attr} eq 'id' && $clone); |
107 |
|
|
<input type="hidden" name="<% $prop->{attr} %>" value="<% html_escape($object->{ $prop->{attr} }) %>"> |
108 |
|
|
% } |
109 |
|
|
<input type="hidden" name="sect_id" value="<% $sect_id %>"> |
110 |
|
|
%#если класса в свойствах обьекта нет все равно надо его пробросить как hidden |
111 |
|
|
% unless (grep {$_->{attr} eq 'class'} @properties) { |
112 |
|
|
<input type="hidden" name="class" value="<% html_escape($object->{class}) %>"> |
113 |
|
|
% } |
114 |
|
|
% if ( $clone ) { |
115 |
|
|
<input type="hidden" name="clone" value="<% $object->id %>"> |
116 |
|
|
% } |
117 |
|
|
<input type="hidden" name="save" value="1"> |
118 |
|
|
|
119 |
|
|
</td> |
120 |
|
|
</tr> |
121 |
|
|
</table> |
122 |
|
|
</center> |
123 |
|
|
|
124 |
|
|
</td> |
125 |
|
|
<td valign="top" bgcolor="#efefef"> |
126 |
|
|
<div style="width:270px"><spacer type="block" width="270"></div> |
127 |
|
|
<div><iframe name="DocFinder" id="DocFinder" src="/contenido/find_document.html" frameborder="0" |
128 |
|
|
marginheight="0" marginwidth="0" width="100%" height="0"></iframe></div> |
129 |
|
|
<table cellpadding="5" cellspacing="0" border="0"><tr><td> |
130 |
117 |
ahitrov |
<p><b style="font-size:15px;"><nobr>Мультимедиа-объекты</nobr> к <% $PROTOS->{$proto}->[2] %></b></p> |
131 |
8 |
ahitrov@rambler.ru |
|
132 |
|
|
% for (0..$#properties) |
133 |
|
|
% { |
134 |
|
|
% my $prop = $properties[$_]; |
135 |
568 |
ahitrov |
% next if exists $prop->{hidden} && $prop->{hidden}; |
136 |
8 |
ahitrov@rambler.ru |
% |
137 |
|
|
% if ($prop->{type} eq 'image') |
138 |
|
|
% { |
139 |
|
|
% my $IMAGE = $object->get_image( $prop->{attr} ); |
140 |
|
|
% if (ref($IMAGE) ne 'HASH') { next }; |
141 |
|
|
<& "/contenido/components/inputs/image.msn", |
142 |
|
|
IMAGE => $IMAGE, |
143 |
|
|
rusname => $prop->{rusname}, |
144 |
|
|
prop => $prop, object=>$object, |
145 |
|
|
attr => $prop->{attr}, |
146 |
|
|
options => $options, |
147 |
|
|
&> |
148 |
|
|
|
149 |
|
|
% } elsif ($prop->{type} eq 'images') |
150 |
|
|
% { |
151 |
|
|
% my $IMAGES = $object->get_image( $prop->{attr} ); |
152 |
|
|
% if (ref($IMAGES) ne 'HASH') { next }; |
153 |
|
|
% my $MN = $IMAGES->{maxnumber}+0; |
154 |
|
|
% for my $mn (1..$MN) |
155 |
|
|
% { |
156 |
|
|
% my $IMAGE = $IMAGES->{'image_'.$mn}; |
157 |
|
|
|
158 |
|
|
<& "/contenido/components/inputs/image.msn", |
159 |
|
|
rusname => $prop->{rusname}, |
160 |
|
|
prop => $prop, object=>$object, |
161 |
|
|
attr => $prop->{attr}.'_'.$mn, |
162 |
|
|
IMAGE => $IMAGE, |
163 |
|
|
options => $options, |
164 |
649 |
ahitrov |
&> |
165 |
8 |
ahitrov@rambler.ru |
|
166 |
|
|
% } |
167 |
63 |
ahitrov@rambler.ru |
% my $ME = exists $prop->{empty_slots} ? $prop->{empty_slots} : 5; |
168 |
|
|
% $ME = ($ME + $IMAGES->{maxnumber}) >= 100 ? 0 : (100 - $IMAGES->{maxnumber} < $ME ? 100 - $IMAGES->{maxnumber} : $ME ); |
169 |
|
|
% for my $mn (1..$ME) |
170 |
8 |
ahitrov@rambler.ru |
% { |
171 |
|
|
|
172 |
|
|
|
173 |
|
|
<& "/contenido/components/inputs/image.msn", |
174 |
|
|
IMAGE => {}, |
175 |
|
|
rusname => $prop->{rusname}, |
176 |
|
|
prop => $prop, object=>$object, |
177 |
|
|
attr => $prop->{attr}.'_'.($MN+$mn), |
178 |
|
|
options => $options, |
179 |
649 |
ahitrov |
&> |
180 |
8 |
ahitrov@rambler.ru |
|
181 |
|
|
% } |
182 |
649 |
ahitrov |
% } elsif ($prop->{type} eq 'multimedia') { |
183 |
8 |
ahitrov@rambler.ru |
% my $MULTI = $object->get_image( $prop->{attr} ); |
184 |
|
|
|
185 |
|
|
<& "/contenido/components/inputs/multimedia.msn", |
186 |
|
|
rusname => $prop->{rusname}, |
187 |
|
|
prop => $prop, object=>$object, |
188 |
|
|
attr => $prop->{attr}, |
189 |
|
|
MULTI => $MULTI, |
190 |
|
|
options => $options, |
191 |
649 |
ahitrov |
&> |
192 |
347 |
ahitrov |
% } elsif ($prop->{type} eq 'multimedia_new') { |
193 |
8 |
ahitrov@rambler.ru |
% my $MULTI = $object->get_image( $prop->{attr} ); |
194 |
|
|
|
195 |
|
|
<& "/contenido/components/inputs/multimedia_new.msn", |
196 |
|
|
rusname => $prop->{rusname}, |
197 |
|
|
prop => $prop, object=>$object, |
198 |
|
|
attr => $prop->{attr}, |
199 |
|
|
MULTI => $MULTI, |
200 |
|
|
options => $options, |
201 |
649 |
ahitrov |
&> |
202 |
347 |
ahitrov |
|
203 |
|
|
% } elsif ($prop->{type} eq 'multimedia_multi') { |
204 |
|
|
% my $FILES = $object->get_image( $prop->{attr} ); |
205 |
|
|
% if (ref($FILES) ne 'HASH') { next }; |
206 |
|
|
% my $MN = $FILES->{maxnumber}+0; |
207 |
|
|
% for my $mn (1..$MN) { |
208 |
|
|
% my $MULTI = $FILES->{'file_'.$mn}; |
209 |
|
|
<& "/contenido/components/inputs/multimedia_new.msn", |
210 |
|
|
rusname => $prop->{rusname}, |
211 |
|
|
prop => $prop, object=>$object, |
212 |
|
|
attr => $prop->{attr}.'_'.$mn, |
213 |
|
|
MULTI => $MULTI, |
214 |
|
|
options => $options, |
215 |
|
|
&> |
216 |
|
|
|
217 |
|
|
% } |
218 |
|
|
% my $ME = exists $prop->{empty_slots} ? $prop->{empty_slots} : 3; |
219 |
|
|
% $ME = ($ME + $FILES->{maxnumber}) >= 100 ? 0 : (100 - $FILES->{maxnumber} < $ME ? 100 - $FILES->{maxnumber} : $ME ); |
220 |
|
|
% for my $mn (1..$ME) { |
221 |
|
|
|
222 |
|
|
<& "/contenido/components/inputs/multimedia_new.msn", |
223 |
|
|
rusname => $prop->{rusname}, |
224 |
649 |
ahitrov |
prop => $prop, object=>$object, |
225 |
347 |
ahitrov |
attr => $prop->{attr}.'_'.($MN+$mn), |
226 |
|
|
MULTI => {}, |
227 |
|
|
options => $options, |
228 |
|
|
&> |
229 |
|
|
|
230 |
649 |
ahitrov |
% } |
231 |
347 |
ahitrov |
% } elsif ($prop->{type} eq 'audio') { |
232 |
8 |
ahitrov@rambler.ru |
% my $MULTI = $object->get_image( $prop->{attr} ); |
233 |
|
|
|
234 |
|
|
<& "/contenido/components/inputs/audio.msn", |
235 |
|
|
rusname => $prop->{rusname}, |
236 |
|
|
prop => $prop, object=>$object, |
237 |
|
|
attr => $prop->{attr}, |
238 |
|
|
MULTI => $MULTI, |
239 |
|
|
options => $options, |
240 |
|
|
&> |
241 |
|
|
% } |
242 |
|
|
% } |
243 |
|
|
|
244 |
|
|
</table> |
245 |
|
|
</td></tr></table> |
246 |
|
|
|
247 |
|
|
|
248 |
|
|
</td></tr> |
249 |
|
|
</table> |
250 |
|
|
|
251 |
|
|
</td></tr></table> |
252 |
|
|
</center> |
253 |
|
|
|
254 |
|
|
<script> |
255 |
|
|
<!-- |
256 |
|
|
function updateList(theFild,value,text) { |
257 |
|
|
for (var i = 0; i < theFild.options.length; i++) { |
258 |
|
|
if (theFild.options[i].value == value) { |
259 |
|
|
return false; |
260 |
|
|
} |
261 |
|
|
} |
262 |
|
|
var option_length = theFild.options.length++; |
263 |
|
|
eval("theFild.options[option_length].value=value"); |
264 |
|
|
eval("theFild.options[option_length].text=text"); |
265 |
|
|
|
266 |
|
|
Save(); this.form.submit(); |
267 |
|
|
|
268 |
|
|
} |
269 |
|
|
//--> |
270 |
|
|
</script> |
271 |
|
|
|
272 |
|
|
% unless ( $proto eq 'sections' && $object->id == 1 ) { |
273 |
|
|
<div align="center"><input type="submit" value="Сохранить" class="input_btn"> |
274 |
|
|
%# <input type="submit" value="Сохранить изменения в <% $PROTOS->{$proto}->[3] %>" class="input_btn"> |
275 |
|
|
|
276 |
|
|
%# |
277 |
|
|
%# Как же сохранять эти гребанные связи? |
278 |
|
|
%# onClick="javascript:updateList(parent.opener.links.links,'link_6_20_DefaultLink','test');" |
279 |
|
|
%# |
280 |
|
|
|
281 |
|
|
|
282 |
|
|
% if ($object->id > 0 && !$clone) { |
283 |
|
|
<input name="delete" type="button" value="Удалить" onClick="javascript:window.location='confirm.html?id=<% $object->id() %>&action=<% $proto %>_deletion&class=<% $object->class() %>'" class="input_btn">\ |
284 |
|
|
% } |
285 |
|
|
% if ( ref $filter_params eq 'HASH' ) { |
286 |
|
|
% while ( my ($key, $value) = each %$filter_params ) { |
287 |
|
|
% next if grep { $_->{attr} eq $key } $object->structure(); |
288 |
|
|
<input type="hidden" name="<% $key %>" value="<% $value %>"> |
289 |
|
|
% } |
290 |
|
|
% } |
291 |
|
|
<input type="hidden" name="control_charset" value="Контроль"> |
292 |
|
|
% if (( $proto eq 'documents' ) || ( $proto eq 'sections' )) { |
293 |
|
|
<input type="submit" name="_save_and_leave" value="Сохранить и выйти" class="input_btn"> |
294 |
|
|
% unless ( $clone ) { |
295 |
|
|
<input type="submit" name="_save_and_again" value="Сохранить и создать новый" class="input_btn"> |
296 |
|
|
% } |
297 |
|
|
% } |
298 |
|
|
</div> |
299 |
|
|
% } |
300 |
|
|
</form> |
301 |
|
|
|
302 |
|
|
<%ARGS> |
303 |
|
|
|
304 |
|
|
$proto => 'documents' |
305 |
|
|
$object => undef |
306 |
|
|
$clone => undef |
307 |
|
|
$sect_id => 1 |
308 |
|
|
$filter_params => undef |
309 |
|
|
|
310 |
|
|
</%ARGS> |
311 |
|
|
|
312 |
|
|
<%ONCE> |
313 |
|
|
my $PROTOS = { |
314 |
|
|
'documents' => ['документа','document.html','документу','документе'], |
315 |
|
|
'sections' => ['секции','section.html','секции','секции'], |
316 |
|
|
'links' => ['связи','link.html','связи','связи'], |
317 |
|
|
'users' => ['пользователя','users.html','пользователю','пользователе'], |
318 |
|
|
}; |
319 |
|
|
</%ONCE> |
320 |
|
|
|
321 |
|
|
<%INIT> |
322 |
|
|
return undef unless ref($object); |
323 |
|
|
|
324 |
|
|
my $toopi = $project->$proto(); |
325 |
|
|
my $options = {}; |
326 |
|
|
if ($toopi && (ref($toopi) eq 'HASH') && (exists($toopi->{ $object->class }))) { |
327 |
|
|
%{ $options } = %{ $toopi->{ $object->class } }; |
328 |
|
|
} |
329 |
117 |
ahitrov |
my $is_multimedia = scalar( grep { $_->{type} =~ /(image|multimedia|audio)/ } $object->structure ); |
330 |
|
|
my $is_pickup = scalar( grep { $_->{type} =~ /(pickup)/ } $object->structure ); |
331 |
|
|
|
332 |
8 |
ahitrov@rambler.ru |
</%INIT> |