Revision 551
- Date:
- 2016/02/29 20:52:16
- Files:
Legend:
- Added
- Removed
- Modified
-
utf8/core/comps/contenido/components/inputs/pairset.msn
1 Добавить значение 2 <script type="text/javascript"> 3 <!-- 4 var sFirstIndex_<% $name %> = 1; 5 var sLastIndex_<% $name %> = <% $i %>; 6 //--> 7 </script> 8 <%args> 9 10 $name => undef 11 $rusname => undef 12 $check => undef 13 $object => undef 14 15 </%args> 16 <%init> 17 18 return unless ref $object; 19 20 my $fields = ref $object->$name ? $object->$name : $object->get_image($name); 21 $fields = [] unless $fields && ref $fields eq 'ARRAY'; 22 23 $m->out(''); 24 $m->out('<table width="95%" style="margin:5px 0;padding:5 6 5 6;border:1px solid #ccc;font-size:70%;font-family:Tahoma;background-color:#f5f5f5;color:#000;" id="parset-table-'.$name.'">'); 25 $m->out('<tr><th width="1%"><h5 style="margin:0; padding:4px; font-size:11px; color:blue; background:silver;">#</h5></th>'); 26 $m->out('<th width="33%"><h5 style="margin:0; padding:4px; font-size:11px; color:blue; background:silver;">Параметр:</h5></th>'); 27 $m->out('<th width="66%"><h5 style="margin:0; padding:4px; font-size:11px; color:blue; background:silver;">Значение:</h5></th></tr>'); 28 my $i = 1; 29 foreach my $field (@$fields) { 30 my $rusname = "$rusname N$i"; 31 $m->comp('.field', 32 name => $name, 33 fname => $field->{name}, 34 value => $field->{value}, 35 number => $i); 36 $i++; 37 } 38 $rusname = "$rusname N$i"; 39 for (1..5) { 40 $m->comp('.field', name => $name, fname => '', value => '', number => $i++); 41 } 42 $m->out('</table>'); 43 </%init> 44 45 <%def .field> 46 <%args> 47 48 $name => undef 49 $fname => undef 50 $value => undef 51 $number => undef 52 53 </%args> 54 <%init> 55 56 $value =~ s/&/&/g; 57 58 </%init> 59 <tr valign="top"> 60 <td><input type="text" name="<% $name.'_num_'.$number %>" value="<% $number %>" size="2" maxlength="3"></td> 61 <td><input type="text" name="<% $name.'_name_'.$number %>" value="<% $fname %>" style="width:97%"></td> 62 <td><textarea class="textarea" name="<% $name.'_value_'.$number %>" rows="2" style="width:97%;"><% $value %></textarea></td> 63 </tr> 64 </%def> -
utf8/core/comps/contenido/components/outputs/pairset.msn
1 <%args> 2 3 $name => undef 4 $SETS => undef 5 6 </%args> 7 <%init> 8 9 return unless ref $SETS; 10 return unless $name; 11 12 my $result = []; 13 foreach my $key (keys %$SETS) { 14 if ($key =~ /^${name}_(num|name|value)_(\d+)$/) { 15 my $field = $1; 16 my $i = $2; 17 $result->[$i-1]->{$field} = $SETS->{$key} if defined $SETS->{$key}; 18 } 19 } 20 @$result = map { delete $_->{num}; $_ } sort { $a->{num} <=> $b->{num} } grep { $_->{name} } @$result; 21 22 return $result; 23 24 </%init>