Line # Revision Author
1 3 ahitrov@rambler.ru %# vim:syn=mason
2 <%args>
3 $object
4 $name => undef
5 $SETS => undef
6 </%args>
7 <%init>
8 return undef unless ref $SETS;
9 return undef unless $name;
10
11 # ���� ��� �������� � ���� ���� integer[] �� ��� �������� ������, ���� � data, �� ������ �� ������.
12 # ��������� �����
13
14 my %ids;
15 while (my ($k, $v) = each(%$SETS)) {
16 next unless $v;
17 if ( $k =~ /^${name}_(\d+)_(delete|id)/ ) {
18 my $id = $1;
19 my $key = $2;
20 if ( ref $v eq 'ARRAY' ) {
21 map { $ids{$_}{$key} => $_ } @$v;
22 } else {
23 $ids{$id}{$key} = $id;
24 }
25 } elsif ( $k =~ /^${name}_(addanotheritem)/ ) {
26 if ( ref $v eq 'ARRAY' ) {
27 map { $ids{$_}{id} => $_ } @$v;
28 } else {
29 $ids{$v}{id} = $v;
30 }
31 }
32 }
33 warn "\n\nPickup form ($name)".Dumper(\%ids)."\n";
34 my @ids = map { $_->{id} } grep { !exists $_->{delete} } values %ids;
35 warn "What to leave ($name)".Dumper(\@ids)."\n\n";
36
37 return \@ids;
38
39 </%init>