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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.12

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