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

1 joko 1.1 <?php
2    
3     /**
4     * This file contains the DesignPattern::MVC class.
5     *
6     * @author Andreas Motl <andreas.motl@ilo.de>
7 joko 1.5 * @module DesignPattern::MVC
8     *
9 joko 1.1 */
10    
11     /**
12 joko 1.5 * $Id: MVC.php,v 1.4 2003/03/01 22:44:54 joko Exp $
13 joko 1.2 *
14     * $Log: MVC.php,v $
15 joko 1.5 * Revision 1.4 2003/03/01 22:44:54 joko
16     * setup_views not required?
17     *
18 joko 1.4 * Revision 1.3 2003/03/01 21:13:00 joko
19     * now actually doing something via '->perform'
20     *
21 joko 1.3 * Revision 1.2 2003/03/01 16:53:57 joko
22 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
23 joko 1.3 * is this a case for aspect-oriented-programming?
24     * - removed calls to _abstract_method
25     *
26 joko 1.2 * Revision 1.1 2003/03/01 15:31:18 joko
27     * + initial commit
28 joko 1.1 *
29     *
30     */
31    
32    
33     /**
34 joko 1.2 * This tries to abstract some parts of the MVC Pattern.
35 joko 1.1 *
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 joko 1.5 * @module DesignPattern::MVC
46 joko 1.1 *
47     */
48    
49     /**
50     * Todo:
51     *
52     * o xyz
53     * o bla, bli, blub
54     *
55     *
56     */
57    
58    
59 joko 1.5 class DesignPattern_MVC extends DesignPattern_Facade {
60 joko 1.1
61 joko 1.3 var $_model = array();
62     var $_view = array();
63     var $_controller = array();
64    
65     var $_performed_result = null;
66 joko 1.1
67    
68     /**
69     * The constructor ...
70     * ... just does nothing.
71     *
72     * @param registry
73     */
74 joko 1.5 function constructor() {
75     parent::constructor();
76 joko 1.1 }
77    
78     function _abstract_method($method) {
79 joko 1.2 $package = get_class($this);
80 joko 1.3 $package_p = get_parent_class($this);
81     print "DesignPattern::MVC.$package_p.$package: Please implement method '$method'.<br/>";
82 joko 1.1 }
83 joko 1.2
84 joko 1.3 // 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 joko 1.2
121 joko 1.3 function setup_views() {
122 joko 1.4 //$this->_abstract_method('setup_views');
123 joko 1.3 }
124 joko 1.5
125    
126 joko 1.1 function add_model() {
127 joko 1.2 $args = &func_get_args();
128 joko 1.5 $this->_container->push('model', &$args[0]);
129 joko 1.1 }
130    
131     function add_view() {
132 joko 1.2 $args = &func_get_args();
133 joko 1.5 $this->_container->push('view', &$args[0]);
134 joko 1.1 }
135    
136     function add_controller() {
137 joko 1.2 $args = &func_get_args();
138 joko 1.5 $this->_container->push('controller', &$args[0]);
139 joko 1.3 }
140    
141     function &get_model_data() {
142 joko 1.5 return $this->_container->last('model');
143 joko 1.3 }
144    
145     function &get_view_data() {
146     $args = &func_get_args();
147     $slot = $args[0];
148 joko 1.5 return $this->_container->slot('view', $slot);
149 joko 1.3 }
150    
151     function &get_controller_data() {
152 joko 1.5 return $this->_container->last('controller');
153 joko 1.1 }
154    
155     }
156    
157     ?>

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