/[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.6 - (show annotations)
Wed Mar 5 15:24:23 2003 UTC (21 years, 4 months ago) by joko
Branch: MAIN
Changes since 1.5: +11 -12 lines
updated docu (phpDocumentor testing....)

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

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