/[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.5 - (show annotations)
Mon Mar 3 21:57:42 2003 UTC (21 years, 4 months ago) by joko
Branch: MAIN
Changes since 1.4: +19 -18 lines
changed base class

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

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