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

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

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