/[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.6 - (hide annotations)
Wed Mar 5 15:24:23 2003 UTC (21 years, 5 months ago) by joko
Branch: MAIN
Changes since 1.5: +11 -12 lines
updated docu (phpDocumentor testing....)

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

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