/[cvs]/nfo/php/libs/org.netfrag.glib/Data/Lift.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.glib/Data/Lift.php

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

revision 1.1 by joko, Sat Feb 22 16:20:04 2003 UTC revision 1.2 by joko, Thu Feb 27 16:30:17 2003 UTC
# Line 3  Line 3 
3  //    $Id$  //    $Id$
4  //    -------------------------------------------------------------------------  //    -------------------------------------------------------------------------
5  //    $Log$  //    $Log$
6    //    Revision 1.2  2003/02/27 16:30:17  joko
7    //    + enhanced '_autodetect'
8    //    + added '_check'
9    //    + now throughout returning lifted values by reference
10    //
11  //    Revision 1.1  2003/02/22 16:20:04  joko  //    Revision 1.1  2003/02/22 16:20:04  joko
12  //    + initial commit  //    + initial commit
13  //  //
# Line 38  class Data_Lift { Line 43  class Data_Lift {
43        
44    function set(&$payload, $metatype = '') {    function set(&$payload, $metatype = '') {
45      $this->payload = &$payload;      $this->payload = &$payload;
46        
47      if ($metatype) { $this->metatype = $metatype; }      if ($metatype) { $this->metatype = $metatype; }
48      $this->_autodetect();      $this->_autodetect();
49        $this->_check();
50    }    }
51        
52    function _autodetect() {    function _autodetect() {
53    
54      // FIXME: distinguish between is_array and is_hash here!      // FIXME: distinguish between is_array and is_hash here!
55      if (is_array($this->payload)) {      if (is_object($this->payload)) {
56          $this->vartype = 'object';
57          $this->metatype = get_class($this->payload);
58          if ($parent_class = get_parent_class($this->payload)) {
59            $this->metatype = $parent_class;
60          }
61    
62        } elseif (is_array($this->payload)) {
63        $this->vartype = 'hash';        $this->vartype = 'hash';
64    
65        } else {
66          $this->vartype = 'scalar';
67        
68      }      }
69    }    }
70        
71    function to($level) {    function _check() {
72    
73        $good = $this->vartype && $this->metatype;
74        
75        //print "metatype: " . $this->metatype . "<br>";
76        
77        if (!$good) {
78          print "Data::Lift cannot handle this payload: ";
79          print "(vartype=" . $this->vartype . ", metatype=" . $this->metatype . ")<br/>";
80          print Dumper($this->payload);
81        }
82        
83      }
84      
85      function &to($level) {
86      $this->_resolve_location($level);      $this->_resolve_location($level);
87      //print Dumper($this->actor);      //print Dumper($this->actor);
88      //exit;      //exit;
89      //$result = array( name => 'abc', description => 'def' );      //$result = array( name => 'abc', description => 'def' );
90      $result = $this->_perform_actor();      $result = &$this->_perform_actor();
91      return $result;      return $result;
92    }    }
93        
# Line 74  class Data_Lift { Line 107  class Data_Lift {
107            
108    }    }
109    
110    function _perform_actor() {    function &_perform_actor() {
111      //$actor_file = join('/', $this->actor) . '.php';      //$actor_file = join('/', $this->actor) . '.php';
112      //include($actor_file);      //include($actor_file);
113      $actor_name = 'Data/Lift/' . join('/', $this->actor);      $actor_name = 'Data/Lift/' . join('/', $this->actor);

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

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