/[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.9 - (hide annotations)
Wed Mar 5 16:32:18 2003 UTC (21 years, 4 months ago) by joko
Branch: MAIN
Changes since 1.8: +12 -11 lines
updated docu (phpDocumentor testing....)

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

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