/[cvs]/nfo/perl/libs/Data/Mungle/Transform/Deep.pm
ViewVC logotype

Diff of /nfo/perl/libs/Data/Mungle/Transform/Deep.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.12 by joko, Thu Feb 20 22:45:19 2003 UTC revision 1.15 by jonen, Thu Feb 27 14:39:48 2003 UTC
# Line 2  Line 2 
2  ##  $Id$  ##  $Id$
3  ## ---------------------------------------------------------------------------  ## ---------------------------------------------------------------------------
4  ##  $Log$  ##  $Log$
5    ##  Revision 1.15  2003/02/27 14:39:48  jonen
6    ##  + fixed bug at _hash2object()
7    ##
8    ##  Revision 1.14  2003/02/22 17:13:55  jonen
9    ##  + added function 'childObject2string()' to encode 'child'-references to option related string
10    ##  + use new option at 'expand()' for replacing 'childObject2string'
11    ##
12    ##  Revision 1.13  2003/02/21 01:48:50  joko
13    ##  renamed core function
14    ##
15  ##  Revision 1.12  2003/02/20 22:45:19  joko  ##  Revision 1.12  2003/02/20 22:45:19  joko
16  ##  fix regarding new deep_copy  ##  fix regarding new deep_copy
17  ##  ##
# Line 136  sub _var_deref_test { Line 146  sub _var_deref_test {
146  }  }
147    
148    
149    # convert values in hash to utf8 (and back) to be ready for (e.g.) encapsulation in XML
150    # but still using the known latin locale stuff
151  sub expand {  sub expand {
152    
153    my $obj = shift;    my $obj = shift;
# Line 150  sub expand { Line 162  sub expand {
162        my $item;        my $item;
163        # if current item is a reference ...        # if current item is a reference ...
164        if (ref $_[0]) {        if (ref $_[0]) {
165          # ... expand structure recursively          $item = $_[0];
166          $item = expand($_[0], $options);          # if $options->{childObj2string} is TRUE or STRING don't expand referenced object,
167            # instead replace it by per option choosed string (default: o_<classname>_<ref type>_<guid> )
168            if ($item && $options->{childObj2string}) {
169              $item = childObj2string($item, $options->{childObj2string});
170            } else {
171              # ... expand structure recursively
172              $item = expand($_[0], $options);
173            }
174          # destroy item via seperate callback method (a POST) if requested          # destroy item via seperate callback method (a POST) if requested
175          #$options->{cb}->{destroy}->($_[0]) if $options->{destroy};          #$options->{cb}->{destroy}->($_[0]) if $options->{destroy};
176    
# Line 180  sub expand { Line 199  sub expand {
199                
200        # if current item is a reference ...        # if current item is a reference ...
201        if (ref $_[1]) {        if (ref $_[1]) {
202          # ... expand structure recursively          $item = $_[1];
203          $item = expand($_[1], $options);          # if $options->{childObj2string} is TRUE or STRING don't expand referenced object,
204            # instead replace it by per option choosed string (default: o_<classname>_<ref type>_<guid> )
205            if ($item && $options->{childObj2string} && !(ref $_[1] eq "ARRAY") && !(ref $_[1] eq "HASH")) {
206              $item = childObj2string($item, $options->{childObj2string});
207            } else {
208              # ... expand structure recursively
209              $item = expand($_[1], $options);
210            }
211          # destroy item via seperate callback method (a POST) if requested          # destroy item via seperate callback method (a POST) if requested
212          #$options->{cb}->{destroy}->($_[1]) if $options->{destroy};          #$options->{cb}->{destroy}->($_[1]) if $options->{destroy};
213                
# Line 205  sub expand { Line 231  sub expand {
231    
232    # convert all values to utf8 (inside complex struct)    # convert all values to utf8 (inside complex struct)
233      # now done in core-item-callbacks via Greg London's "Iterate" from CPAN      # now done in core-item-callbacks via Greg London's "Iterate" from CPAN
234      # var2utf8($result) if ($options->{utf8});      # latin_to_utf8($result) if ($options->{utf8});
235    
236    # destroy persistent object from memory to be sure to get a fresh one next time    # destroy persistent object from memory to be sure to get a fresh one next time
237    #undef $obj if $options->{destroy};    #undef $obj if $options->{destroy};
# Line 282  sub _hash2object { Line 308  sub _hash2object {
308    numhash2list($data) if ($options->{php});    numhash2list($data) if ($options->{php});
309    
310    # utf8-conversion/-encoding (essential for I18N)    # utf8-conversion/-encoding (essential for I18N)
311    var_utf2iso($data) if ($options->{utf8});    utf8_to_latin($data) if ($options->{utf8});
312    
313    # get fresh object from database    # get fresh object from database
314    # todo:    # todo:
# Line 453  sub deep_copy { Line 479  sub deep_copy {
479  }  }
480    
481    
482    sub childObj2string {
483      my $obj = shift;
484      my $option = shift;
485      my $classname = ref $obj;
486      
487      if($option == 1) {
488        my $string = "o_" . $classname . "_" .$obj->{guid};
489        return $string;
490      }  
491    }
492    
493    
494  1;  1;
495  __END__  __END__

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.15

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed