Revision 526

Date:
2015/11/25 16:12:34
Author:
ahitrov
Revision Log:
multimedia_multi - multifile field type

Files:

Legend:

 
Added
 
Removed
 
Modified
  • koi8/core/comps/contenido/components/object_form.msn

     
    39 39 {
    40 40
    41 41 my $prop = $properties[$_];
    42 next if ($prop->{hidden} == 1) || ($prop->{type} eq 'image') || ($prop->{type} eq 'external') || ($prop->{type} =~ /^array/i) || ($prop->{type} =~ /^image/) || ($prop->{type} eq 'multimedia') || ($prop->{type} eq 'multimedia_new') || ($prop->{type} eq 'audio');
    42 next if ($prop->{hidden} == 1) || ($prop->{type} eq 'image') || ($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');
    43 43
    44 44 </%perl>
    45 45 <tr><td height="8"></td></tr>
     
    161 161 MULTI => $MULTI,
    162 162 options => $options,
    163 163 &>
    164 % } elsif ($prop->{type} eq 'multimedia_new')
    165 % {
    164 % } elsif ($prop->{type} eq 'multimedia_new') {
    166 165 % my $MULTI = $object->get_image( $prop->{attr} );
    167 166
    168 167 <& "/contenido/components/inputs/multimedia_new.msn",
     
    172 171 MULTI => $MULTI,
    173 172 options => $options,
    174 173 &>
    175 % } elsif ($prop->{type} eq 'audio')
    176 % {
    174 % } elsif ($prop->{type} eq 'multimedia_multi') {
    175 % my $FILES = $object->get_image( $prop->{attr} );
    176 % if (ref($FILES) ne 'HASH') { next };
    177 % my $MN = $FILES->{maxnumber}+0;
    178 % for my $mn (1..$MN) {
    179 % my $MULTI = $FILES->{'file_'.$mn};
    180 <& "/contenido/components/inputs/multimedia_new.msn",
    181 rusname => $prop->{rusname},
    182 prop => $prop, object=>$object,
    183 attr => $prop->{attr}.'_'.$mn,
    184 MULTI => $MULTI,
    185 options => $options,
    186 &>
    187
    188 % }
    189 % my $ME = exists $prop->{empty_slots} ? $prop->{empty_slots} : 3;
    190 % $ME = ($ME + $FILES->{maxnumber}) >= 100 ? 0 : (100 - $FILES->{maxnumber} < $ME ? 100 - $FILES->{maxnumber} : $ME );
    191 % for my $mn (1..$ME) {
    192
    193 <& "/contenido/components/inputs/multimedia_new.msn",
    194 rusname => $prop->{rusname},
    195 prop => $prop, object=>$object,
    196 attr => $prop->{attr}.'_'.($MN+$mn),
    197 MULTI => {},
    198 options => $options,
    199 &>
    200
    201 % }
    202 % } elsif ($prop->{type} eq 'audio') {
    177 203 % my $MULTI = $object->get_image( $prop->{attr} );
    178 204
    179 205 <& "/contenido/components/inputs/audio.msn",
  • koi8/core/comps/contenido/components/set_properties.msn

     
    146 146 }
    147 147 }
    148 148
    149 } elsif ($prop->{type} eq 'multimedia_multi') {
    150 # --------------------------------------------------------------------------------------
    151 # � ��� ��� ��� ������� - ����������� ����� �� ���� ������...
    152
    153 my $FILES = $object->get_image( $name );
    154 if ( ref($FILES) ne 'HASH' ) {
    155 $FILES = {};
    156 $FILES->{maxnumber} = 0;
    157 };
    158
    159 # ������ ���� ����������� ��� ��������� - � ����� ��� ��, ��� ��� �����...
    160 foreach my $arg (keys(%{ $SETS }))
    161 {
    162 # ��������� ��� �� �����, ��������...
    163 my ($partname,undef) = split(/\./,$arg);
    164 $partname =~ /^(.+)_(\d+)$/;
    165 my ($localname,$number) = ($1, $2);
    166 if ( ($localname eq $prop->{attr}) && ($number > 0) && ( $arg eq $localname.'_'.$number )) {
    167 # ���! ����� �������!
    168
    169 my $partname = $localname.'_'.$number;
    170
    171 if ($SETS->{'_delete_multi.'.$partname} == 1) {
    172 $object->_delete_binary( $FILES->{'file_'.$number} );
    173 delete $FILES->{'file_'.$number};
    174 } else {
    175 my $MULTI = undef;
    176 if (exists($FILES->{'file_'.$number})) {
    177 $MULTI = $FILES->{'file_'.$number};
    178 };
    179 $MULTI = $m->comp('/contenido/components/set_multimedia_new.msn', default=>$MULTI, field=>$partname, SETS=>$SETS, object=>$object, prop => $prop);
    180 if (exists($MULTI->{filename})) {
    181 $MULTI->{number} = $number;
    182 $FILES->{'file_'.$number} = $MULTI;
    183 $FILES->{maxnumber} = $number if ($number > $FILES->{maxnumber});
    184 }
    185 }
    186 }
    187 }
    188
    189 if ( scalar(keys(%{ $FILES })) > 0) {
    190 my $maxnumber = 0;
    191 for ( 1..100 ) {
    192 $maxnumber = $_ if exists $FILES->{"file_$_"} && $_ > $maxnumber;
    193 }
    194 $FILES->{maxnumber} = $maxnumber;
    195 $object->$name( $object->_serialize($FILES) );
    196 }
    197
    149 198 } elsif ( $prop->{type} eq 'audio' ) {
    150 199 # --------------------------------------------------------------------------------------
    151 200 # ���������� ������ ������ �����������
  • koi8/core/lib/Contenido/Object.pm

     
    608 608 if ( exists $opts{attachments} && $opts{attachments} ) {
    609 609 my @props = $self->structure();
    610 610 if ( @props ) {
    611 @props = grep { $_->{type} =~ /^(image|images|multimedia_new)$/ } @props;
    611 @props = grep { $_->{type} =~ /^(image|images|multimedia_new|multimedia_multi)$/ } @props;
    612 612 foreach my $prop ( @props ) {
    613 613 my $att = $self->get_image($prop->{attr});
    614 614 if ( $prop->{type} eq 'image' ) {
     
    644 644 if ( ref $att && exists $att->{filename} && $att->{filename} ) {
    645 645 Contenido::File::remove( $att->{filename} );
    646 646 }
    647 } elsif ( $prop->{type} eq 'multimedia_multi' ) {
    648 for ( 1..100 ) {
    649 next unless exists $att->{"file_$_"};
    650 my $file = $att->{"file_$_"};
    651 if ( ref $file && exists $file->{filename} && $file->{filename} ) {
    652 Contenido::File::remove( $file->{filename} );
    653 }
    654 }
    647 655 }
    648 656 }
    649 657 }
     
    1165 1173 }
    1166 1174
    1167 1175 # ----------------------------------------------------------------------------
    1168 # ����� _store_binary() ��������� ������������ �������� ����, ����������� � ���� multimedia ��� multimedia_new
    1176 # ����� _store_binary() ��������� ������������ �������� ����, ����������� � ���� multimedia_multi ��� multimedia_new
    1169 1177 #
    1170 1178 # ������ �������������:
    1171 1179 # $document->_store_binary( INPUT, attr => 'fieldname' )