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

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

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