2 |
## $Id$ |
## $Id$ |
3 |
## --------------------------------------------------------------------------- |
## --------------------------------------------------------------------------- |
4 |
## $Log$ |
## $Log$ |
5 |
|
## Revision 1.21 2003/04/09 07:21:56 joko |
6 |
|
## childObj2string now inside Encode.pm, renamed to 'twingle_reference' |
7 |
|
## |
8 |
|
## Revision 1.20 2003/04/04 17:31:23 joko |
9 |
|
## minor update to 'childObj2string' |
10 |
|
## |
11 |
|
## Revision 1.19 2003/03/28 03:11:25 jonen |
12 |
|
## + bugfix |
13 |
|
## |
14 |
|
## Revision 1.18 2003/03/28 03:07:26 jonen |
15 |
|
## + minor changes |
16 |
|
## |
17 |
|
## Revision 1.17 2003/03/27 15:17:07 joko |
18 |
|
## namespace fixes for Data::Mungle::* |
19 |
|
## |
20 |
|
## Revision 1.16 2003/03/27 15:04:52 joko |
21 |
|
## minor update: comment |
22 |
|
## |
23 |
|
## Revision 1.15 2003/02/27 14:39:48 jonen |
24 |
|
## + fixed bug at _hash2object() |
25 |
|
## |
26 |
|
## Revision 1.14 2003/02/22 17:13:55 jonen |
27 |
|
## + added function 'childObject2string()' to encode 'child'-references to option related string |
28 |
|
## + use new option at 'expand()' for replacing 'childObject2string' |
29 |
|
## |
30 |
## Revision 1.13 2003/02/21 01:48:50 joko |
## Revision 1.13 2003/02/21 01:48:50 joko |
31 |
## renamed core function |
## renamed core function |
32 |
## |
## |
74 |
## --------------------------------------------------------------------------- |
## --------------------------------------------------------------------------- |
75 |
|
|
76 |
|
|
77 |
package Data::Transform::Deep; |
package Data::Mungle::Transform::Deep; |
78 |
|
|
79 |
use strict; |
use strict; |
80 |
use warnings; |
use warnings; |
93 |
use Iterate; |
use Iterate; |
94 |
|
|
95 |
use Pitonyak::DeepCopy; |
use Pitonyak::DeepCopy; |
96 |
use Data::Transform::Encode qw( latin_to_utf8 latin_to_utf8_scalar utf8_to_latin utf8_to_latin_scalar ); |
use Data::Mungle::Transform::Encode qw( latin_to_utf8 latin_to_utf8_scalar utf8_to_latin utf8_to_latin_scalar twingle_reference ); |
97 |
use Data::Code::Ref qw( ref_slot ); |
use Data::Mungle::Code::Ref qw( ref_slot ); |
98 |
|
|
99 |
sub numhash2list { |
sub numhash2list { |
100 |
my $vref = shift; |
my $vref = shift; |
180 |
my $item; |
my $item; |
181 |
# if current item is a reference ... |
# if current item is a reference ... |
182 |
if (ref $_[0]) { |
if (ref $_[0]) { |
183 |
# ... expand structure recursively |
$item = $_[0]; |
184 |
$item = expand($_[0], $options); |
# if $options->{childObj2string} is TRUE or STRING don't expand referenced object, |
185 |
|
# instead replace it by per option choosed string (default: o_<classname>_<ref type>_<guid> ) |
186 |
|
if ($item && $options->{childObj2string}) { |
187 |
|
$item = twingle_reference($item); |
188 |
|
} else { |
189 |
|
# ... expand structure recursively |
190 |
|
$item = expand($_[0], $options); |
191 |
|
} |
192 |
# destroy item via seperate callback method (a POST) if requested |
# destroy item via seperate callback method (a POST) if requested |
193 |
#$options->{cb}->{destroy}->($_[0]) if $options->{destroy}; |
#$options->{cb}->{destroy}->($_[0]) if $options->{destroy}; |
194 |
|
|
217 |
|
|
218 |
# if current item is a reference ... |
# if current item is a reference ... |
219 |
if (ref $_[1]) { |
if (ref $_[1]) { |
220 |
# ... expand structure recursively |
$item = $_[1]; |
221 |
$item = expand($_[1], $options); |
# if $options->{childObj2string} is TRUE or STRING don't expand referenced object, |
222 |
|
# instead replace it by per option choosed string (default: o_<classname>_<ref type>_<guid> ) |
223 |
|
if ($item && $options->{childObj2string} && !(ref $_[1] eq "ARRAY") && !(ref $_[1] eq "HASH")) { |
224 |
|
$item = twingle_reference($item); |
225 |
|
} else { |
226 |
|
# ... expand structure recursively |
227 |
|
$item = expand($_[1], $options); |
228 |
|
} |
229 |
# destroy item via seperate callback method (a POST) if requested |
# destroy item via seperate callback method (a POST) if requested |
230 |
#$options->{cb}->{destroy}->($_[1]) if $options->{destroy}; |
#$options->{cb}->{destroy}->($_[1]) if $options->{destroy}; |
231 |
|
|
309 |
sub merge_to { |
sub merge_to { |
310 |
_hash2object(@_); |
_hash2object(@_); |
311 |
# TODO: |
# TODO: |
312 |
# re-implement using CPAN's "Iterate". |
# re-implement using CPAN's "Iterate" and/or a modified Hash::Merge. |
313 |
} |
} |
314 |
|
|
315 |
|
|
326 |
numhash2list($data) if ($options->{php}); |
numhash2list($data) if ($options->{php}); |
327 |
|
|
328 |
# utf8-conversion/-encoding (essential for I18N) |
# utf8-conversion/-encoding (essential for I18N) |
329 |
var_utf2iso($data) if ($options->{utf8}); |
utf8_to_latin($data) if ($options->{utf8}); |
330 |
|
|
331 |
# get fresh object from database |
# get fresh object from database |
332 |
# todo: |
# todo: |