/[cvs]/nfo/php/libs/org.netfrag.elib/dagl/lib_tracking_process.php.inc
ViewVC logotype

Annotation of /nfo/php/libs/org.netfrag.elib/dagl/lib_tracking_process.php.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (vendor branch)
Wed Jan 23 17:40:34 2002 UTC (22 years, 5 months ago) by cvsjoko
Branch: nfo, MAIN
CVS Tags: v003, HEAD
Changes since 1.1: +0 -0 lines
initial

1 cvsjoko 1.1 <?
2    
3     class AbstractProcessObject {
4    
5     var $name;
6     var $uniqueId;
7     var $results;
8    
9     function AbstractProcessObject($name = '') {
10     $this->uniqueId = getUniqueId();
11     if ($name) {
12     $this->name = $name;
13     } else {
14     $this->name = 'process_' . $this->uniqueId;
15     }
16     }
17    
18     function &callHandler($handler_name, $list_results_requested = array(), $args_optional = array()) {
19     $handler_name = '__' . $handler_name;
20     if (method_exists($this, $handler_name)) {
21     // filter all results through list of all result-item-varnames in "$list_results_requested" and return them
22     $results = $this->$handler_name($args_optional);
23     return $this->returnResultsByRequestedResults($results, $list_results_requested);
24     } else {
25     print "<font color=\"red\">{$this->name}->callHandler($handler_name, ..., ...) failed, the handler was not found.</font><br>";
26     return createHash($list_results_requested);
27     }
28     }
29    
30     function &returnResultsByRequestedResults(&$results, $list_results_requested) {
31     $results_filtered = array();
32     reset($list_results_requested);
33     while($resultitem_name = current($list_results_requested)) {
34     if (isset($results[$resultitem_name])) {
35     $results_filtered[$resultitem_name] =& $results[$resultitem_name];
36     } else {
37     $results_filtered[$resultitem_name] = '';
38     }
39     next($list_results_requested);
40     }
41     return $results_filtered;
42     }
43    
44     }
45    
46     class AbstractObjectHandler extends AbstractProcessObject {
47     // TODO:
48     // implement functionality that no library-code for standard-object-operations is necessary any more
49    
50     // --------------------------------------------------
51     // called if a list of objects is requested
52     function &__list($args = array()) {
53     return $this->getAllResults_ForObjectList($args);
54     }
55    
56     // --------------------------------------------------
57     // called if a single object is requested for viewing
58     function &__show($args = array()) {
59     return $this->getAllResults_ForSingleObject($args);
60     }
61    
62     // --------------------------------------------------
63     // called if a single object is requested for editing
64     function &__edit($args = array()) {
65     // check if the "save"-flag on the data-transfer of object-data is set
66     $this->onBeforeEdit(&$args);
67     $this->_checkForSave($args);
68     $this->onAfterEdit(&$args);
69     return $this->getAllResults_ForSingleObject($args);
70     }
71    
72     // --------------------------------------------------
73     // called if a single object should be newly created
74     function &__create($args = array()) {
75     $args['objectkey'] = '<new>';
76     // check if the "save"-flag on the data-transfer of object-data is set
77     $this->onBeforeCreate(&$args);
78     $this->_checkForSave(&$args);
79     $this->onAfterCreate(&$args);
80     return $this->getAllResults_ForSingleObject(&$args);
81     }
82    
83     // --------------------------------------------------
84     // called if a single object gets a delete-request
85     function &__delete($args = array()) {
86     $results =& $this->getAllResults_ForSingleObject($args);
87     $this->onBeforeDelete($args);
88     $results['ref_object']->delete();
89     $this->onAfterDelete($args);
90     }
91    
92     // --------------------------------------------------
93     // checks if an object should be saved immediately
94     function _checkForSave($args = array()) {
95    
96     global $esave;
97     if ($esave) {
98     $results =& $this->getAllResults_ForSingleObject($args);
99     $this->onBeforeSave($args);
100     $results['ref_object']->save();
101     $this->onAfterSave($args);
102     return 1;
103     } else {
104     return 0;
105     }
106    
107     }
108    
109     function onBeforeSave($args = array()) { }
110     function onAfterSave($args = array()) { }
111     function onBeforeDelete($args = array()) { }
112     function onAfterDelete($args = array()) { }
113     function onBeforeCreate($args = array()) { }
114     function onAfterCreate($args = array()) { }
115     function onBeforeEdit($args = array()) { }
116     function onAfterEdit($args = array()) { }
117    
118     }
119    
120     ?>

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