/[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.12 - (show annotations)
Mon Mar 10 23:30:27 2003 UTC (21 years, 4 months ago) by joko
Branch: MAIN
Changes since 1.11: +8 -1 lines
+ fixed metadata for phpDocumentor

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

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