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

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