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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Sat Feb 22 16:20:04 2003 UTC (21 years, 4 months ago) by joko
Branch: MAIN
+ initial commit

1 <?
2 // -------------------------------------------------------------------------
3 // $Id: Deep.php,v 1.1 2003/02/03 14:51:44 joko Exp $
4 // -------------------------------------------------------------------------
5 // $Log: Deep.php,v $
6 // -------------------------------------------------------------------------
7
8
9 // Data::Lift - Pass data around between locations doing operations on it
10
11
12 class Data_Lift {
13
14 var $dblocations;
15 var $actor;
16
17 var $payload;
18 var $vartype;
19 var $metatype;
20
21 function Data_Lift(&$payload, $options = array()) {
22 $this->_init_locations();
23 //print Dumper($options);
24 //exit;
25 if ($options[metatype]) { $this->metatype = $options[metatype]; }
26 $this->set(&$payload);
27 }
28
29 function _init_locations() {
30 $this->actor = array();
31 $this->dblocations = array(
32 'bla' => 'blub',
33 );
34 }
35
36 function set(&$payload, $metatype = '') {
37 $this->payload = &$payload;
38 if ($metatype) { $this->metatype = $metatype; }
39 $this->_autodetect();
40 }
41
42 function _autodetect() {
43 // FIXME: distinguish between is_array and is_hash here!
44 if (is_array($this->payload)) {
45 $this->vartype = 'hash';
46 }
47 }
48
49 function to($level) {
50 $this->_resolve_location($level);
51 //print Dumper($this->actor);
52 //exit;
53 //$result = array( name => 'abc', description => 'def' );
54 $result = $this->_perform_actor();
55 return $result;
56 }
57
58 function _resolve_location($level) {
59
60 // location can be resolved by location-table
61 if ($location = $this->dblocations[$level]) {
62 $this->actor = split('/', $location);
63 }
64
65 // try to automagically resolve location
66 $part = array();
67 array_push($part, $this->vartype);
68 array_push($part, $this->metatype);
69 array_push($part, $level);
70 $this->actor = $part;
71
72 }
73
74 function _perform_actor() {
75 //$actor_file = join('/', $this->actor) . '.php';
76 //include($actor_file);
77 $actor_name = 'Data/Lift/' . join('/', $this->actor);
78 $actor_object = mkObject($actor_name);
79 return $actor_object->perform($this->payload);
80 }
81
82 function get() {
83 return $this->payload;
84 }
85
86 function add($data = array()) {
87 $this->payload = array_merge($this->payload, $data);
88 }
89
90 }
91
92 ?>

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