2 |
## $Id$ |
## $Id$ |
3 |
## --------------------------------------------------------------------------- |
## --------------------------------------------------------------------------- |
4 |
## $Log$ |
## $Log$ |
5 |
|
## Revision 1.14 2003/02/22 17:13:55 jonen |
6 |
|
## + added function 'childObject2string()' to encode 'child'-references to option related string |
7 |
|
## + use new option at 'expand()' for replacing 'childObject2string' |
8 |
|
## |
9 |
## Revision 1.13 2003/02/21 01:48:50 joko |
## Revision 1.13 2003/02/21 01:48:50 joko |
10 |
## renamed core function |
## renamed core function |
11 |
## |
## |
159 |
my $item; |
my $item; |
160 |
# if current item is a reference ... |
# if current item is a reference ... |
161 |
if (ref $_[0]) { |
if (ref $_[0]) { |
162 |
# ... expand structure recursively |
$item = $_[0]; |
163 |
$item = expand($_[0], $options); |
# if $options->{childObj2string} is TRUE or STRING don't expand referenced object, |
164 |
|
# instead replace it by per option choosed string (default: o_<classname>_<ref type>_<guid> ) |
165 |
|
if ($item && $options->{childObj2string}) { |
166 |
|
$item = childObj2string($item, $options->{childObj2string}); |
167 |
|
} else { |
168 |
|
# ... expand structure recursively |
169 |
|
$item = expand($_[0], $options); |
170 |
|
} |
171 |
# destroy item via seperate callback method (a POST) if requested |
# destroy item via seperate callback method (a POST) if requested |
172 |
#$options->{cb}->{destroy}->($_[0]) if $options->{destroy}; |
#$options->{cb}->{destroy}->($_[0]) if $options->{destroy}; |
173 |
|
|
196 |
|
|
197 |
# if current item is a reference ... |
# if current item is a reference ... |
198 |
if (ref $_[1]) { |
if (ref $_[1]) { |
199 |
# ... expand structure recursively |
$item = $_[1]; |
200 |
$item = expand($_[1], $options); |
# if $options->{childObj2string} is TRUE or STRING don't expand referenced object, |
201 |
|
# instead replace it by per option choosed string (default: o_<classname>_<ref type>_<guid> ) |
202 |
|
if ($item && $options->{childObj2string} && !(ref $_[1] eq "ARRAY") && !(ref $_[1] eq "HASH")) { |
203 |
|
$item = childObj2string($item, $options->{childObj2string}); |
204 |
|
} else { |
205 |
|
# ... expand structure recursively |
206 |
|
$item = expand($_[1], $options); |
207 |
|
} |
208 |
# destroy item via seperate callback method (a POST) if requested |
# destroy item via seperate callback method (a POST) if requested |
209 |
#$options->{cb}->{destroy}->($_[1]) if $options->{destroy}; |
#$options->{cb}->{destroy}->($_[1]) if $options->{destroy}; |
210 |
|
|
476 |
} |
} |
477 |
|
|
478 |
|
|
479 |
|
sub childObj2string { |
480 |
|
my $obj = shift; |
481 |
|
my $option = shift; |
482 |
|
my $classname = ref $obj; |
483 |
|
|
484 |
|
if($option == 1) { |
485 |
|
my $string = "o_" . $classname . "_" .$obj->{guid}; |
486 |
|
return $string; |
487 |
|
} |
488 |
|
} |
489 |
|
|
490 |
|
|
491 |
1; |
1; |
492 |
__END__ |
__END__ |