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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (hide annotations)
Wed Mar 5 16:10:17 2003 UTC (21 years, 5 months ago) by joko
Branch: MAIN
Changes since 1.7: +7 -3 lines
updated docu (phpDocumentor testing....)

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

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