/[cvs]/nfo/php/libs/org.netfrag.glib/DesignPattern/MVC.php
ViewVC logotype

Contents of /nfo/php/libs/org.netfrag.glib/DesignPattern/MVC.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (show annotations)
Wed Mar 5 16:32:18 2003 UTC (21 years, 4 months ago) by joko
Branch: MAIN
Changes since 1.8: +12 -11 lines
updated docu (phpDocumentor testing....)

1 <?php
2 /**
3 * This file contains the DesignPattern::MVC class
4 *
5 * @author Andreas Motl <andreas.motl@ilo.de>
6 * @package org.netfrag.glib
7 * @name DesignPattern::MVC
8 * @filesource
9 *
10 *
11 *
12 * <b>Cvs-Log:</b>
13 *
14 * <pre>
15 * $Id: MVC.php,v 1.8 2003/03/05 16:10:17 joko Exp $
16 *
17 * $Log: MVC.php,v $
18 * Revision 1.8 2003/03/05 16:10:17 joko
19 * updated docu (phpDocumentor testing....)
20 *
21 * Revision 1.7 2003/03/05 15:41:03 joko
22 * updated docu (phpDocumentor testing....)
23 *
24 * Revision 1.6 2003/03/05 15:24:23 joko
25 * updated docu (phpDocumentor testing....)
26 *
27 * Revision 1.5 2003/03/03 21:57:42 joko
28 * changed base class
29 *
30 * Revision 1.4 2003/03/01 22:44:54 joko
31 * setup_views not required?
32 *
33 * Revision 1.3 2003/03/01 21:13:00 joko
34 * now actually doing something via '->perform'
35 *
36 * Revision 1.2 2003/03/01 16:53:57 joko
37 * + now propagating/forwarding passed-in data to add_[model|view|controller] to base class method DesignPattern::Container::push_element to store it
38 * is this a case for aspect-oriented-programming?
39 * - removed calls to _abstract_method
40 *
41 * Revision 1.1 2003/03/01 15:31:18 joko
42 * + initial commit
43 * </pre>
44 *
45 *
46 */
47
48
49 /**
50 * This tries to abstract some parts of the MVC Pattern
51 *
52 * @author Andreas Motl <andreas.motl@ilo.de>
53 * @link http://www.netfrag.org/~joko/
54 * @copyright (c) 2003 - All Rights reserved.
55 * @license GNU LGPL (GNU Lesser General Public License)
56 * @link http://www.gnu.org/licenses/lgpl.txt
57 *
58 * @package org.netfrag.glib
59 * @name DesignPattern::MVC
60 *
61 *
62 * @todo xyz
63 * @todo bla, bli, blub
64 *
65 *
66 */
67 class DesignPattern_MVC extends DesignPattern_Facade {
68
69 var $_model = array();
70 var $_view = array();
71 var $_controller = array();
72
73 var $_performed_result = null;
74
75
76 /**
77 * The constructor ...
78 * ... just does nothing.
79 *
80 * @param registry
81 */
82 function constructor() {
83 parent::constructor();
84 }
85
86 function _abstract_method($method) {
87 $package = get_class($this);
88 $package_p = get_parent_class($this);
89 print "DesignPattern::MVC.$package_p.$package: Please implement method '$method'.<br/>";
90 }
91
92 // spool controller rules
93 function &perform() {
94
95 $this->_model_data = &$this->get_model_data();
96 $this->_controller_data = &$this->get_controller_data();
97
98 //print Dumper($this);
99 //exit;
100
101 // create instance of controller from module
102 $this->_controller_instance = mkObject($this->_controller_data[module]);
103
104 // trace
105 //print Dumper($this);
106 //print Dumper($this->_controller_data);
107 //print Dumper($this->_controller_instance);
108 //exit;
109
110 //$this->perform_rules();
111
112 // new!!! request data is propagated here!!!
113 // FIXME: '_raw[request]' - really?
114 $this->_controller_instance->set_request(&$this->_raw[request]);
115
116 $this->_controller_instance->set_rules($this->_controller_data[rules]);
117 $this->_performed_result = $this->_controller_instance->perform($this->_model_data);
118
119 // finally, re-integrate into main application flow
120 return $this->handle();
121
122 }
123
124 // dispatch on controller state flags/variables
125 function handle() {
126 $this->_abstract_method('handle');
127 }
128
129 function setup_views() {
130 //$this->_abstract_method('setup_views');
131 }
132
133
134 function add_model() {
135 $args = &func_get_args();
136 $this->_container->push('model', &$args[0]);
137 }
138
139 function add_view() {
140 $args = &func_get_args();
141 $this->_container->push('view', &$args[0]);
142 }
143
144 function add_controller() {
145 $args = &func_get_args();
146 $this->_container->push('controller', &$args[0]);
147 }
148
149 function &get_model_data() {
150 return $this->_container->last('model');
151 }
152
153 function &get_view_data() {
154 $args = &func_get_args();
155 $slot = $args[0];
156 return $this->_container->slot('view', $slot);
157 }
158
159 function &get_controller_data() {
160 return $this->_container->last('controller');
161 }
162
163 }
164
165 ?>

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