/[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.7 - (hide annotations)
Wed Mar 5 15:41:03 2003 UTC (21 years, 5 months ago) by joko
Branch: MAIN
Changes since 1.6: +5 -1 lines
updated docu (phpDocumentor testing....)

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

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