/[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.3 by joko, Sat Mar 1 21:13:00 2003 UTC
# Line 11  Line 11 
11   * $Id$   * $Id$
12   *   *
13   * $Log$   * $Log$
14     * Revision 1.3  2003/03/01 21:13:00  joko
15     * now actually doing something via '->perform'
16     *
17   * Revision 1.2  2003/03/01 16:53:57  joko   * Revision 1.2  2003/03/01 16:53:57  joko
18   * + 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
19   *    is this a case for aspect-oriented-programming?   *    is this a case for aspect-oriented-programming?
20   * - removed calls to _abstract_method   * - removed calls to _abstract_method
21   *   *
# Line 56  Line 59 
59  loadModule('DesignPattern::Container');  loadModule('DesignPattern::Container');
60  class DesignPattern_MVC extends DesignPattern_Container {  class DesignPattern_MVC extends DesignPattern_Container {
61    
62    var $_model = NULL;    var $_model = array();
63    var $_view = NULL;    var $_view = array();
64    var $_controller = NULL;    var $_controller = array();
65    
66      var $_performed_result = null;
67    
68    
69   /**   /**
# Line 72  class DesignPattern_MVC extends DesignPa Line 77  class DesignPattern_MVC extends DesignPa
77    
78    function _abstract_method($method) {    function _abstract_method($method) {
79      $package = get_class($this);      $package = get_class($this);
80      print "$package: Please implement method '$method'.<br/>";      $package_p = get_parent_class($this);
81        print "DesignPattern::MVC.$package_p.$package: Please implement method '$method'.<br/>";
82    }    }
83        
84      // 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        
121        function setup_views() {
122        $this->_abstract_method('setup_views');
123      }
124        
125    function add_model() {    function add_model() {
126      $args = &func_get_args();      $args = &func_get_args();
127      $this->__add_entity('model', &$args);      $this->__push('model', &$args[0]);
128    }    }
129    
130    function add_view() {    function add_view() {
131      $args = &func_get_args();      $args = &func_get_args();
132      $this->__add_entity('view', &$args);      $this->__push('view', &$args[0]);
133    }    }
134    
135    function add_controller() {    function add_controller() {
136      $args = &func_get_args();      $args = &func_get_args();
137      $this->__add_entity('controller', &$args);      $this->__push('controller', &$args[0]);
138      }
139    
140      function &get_model_data() {
141        return $this->__last('model');
142      }
143    
144      function &get_view_data() {
145        $args = &func_get_args();
146        $slot = $args[0];
147        return $this->__slot('view', $slot);
148      }
149    
150      function &get_controller_data() {
151        return $this->__last('controller');
152    }    }
153    
   function setup_views() {  
     $this->_abstract_method('setup_views');  
   }    
       
154  }  }
155    
156  ?>  ?>

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

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