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

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

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