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

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

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