| 1 | joko | 1.1 | <? | 
| 2 |  |  | /** | 
| 3 |  |  | * This file contains the abstract MVCPage class. | 
| 4 |  |  | * It inherits from phpHtmlLib's abstract PageWidget | 
| 5 |  |  | * class to seamlessly integrate into its render queue. | 
| 6 |  |  | * | 
| 7 |  |  | * @author Andreas Motl <andreas.motl@ilo.de> | 
| 8 | joko | 1.2 | * @package org.netfrag.glib | 
| 9 |  |  | * @name DesignPattern::AdapterProxy | 
| 10 | joko | 1.1 | * | 
| 11 |  |  | */ | 
| 12 |  |  |  | 
| 13 |  |  | /** | 
| 14 | joko | 1.2 | * $Id: AdapterProxy.php,v 1.1 2003/03/05 12:07:10 joko Exp $ | 
| 15 |  |  | * | 
| 16 |  |  | * $Log: AdapterProxy.php,v $ | 
| 17 |  |  | * Revision 1.1  2003/03/05 12:07:10  joko | 
| 18 |  |  | * + initial commit | 
| 19 | joko | 1.1 | * | 
| 20 |  |  | * Revision 1.1  2003/03/03 22:11:08  joko | 
| 21 |  |  | * + initial commit | 
| 22 |  |  | * | 
| 23 |  |  | * | 
| 24 |  |  | */ | 
| 25 |  |  |  | 
| 26 |  |  |  | 
| 27 |  |  | /** | 
| 28 |  |  | * This class is used to build content | 
| 29 |  |  | * for an MVC controlled page.  It instantiates | 
| 30 |  |  | * an concrete helper MVC object which does the | 
| 31 |  |  | * dispatching stuff. (phpHtmlLib::controller::WebMVC, | 
| 32 |  |  | * inherited from the abstract DesignPattern::MVC) | 
| 33 |  |  | * | 
| 34 |  |  | * This class is established here to act as a wrapper | 
| 35 |  |  | * bringing MVC and phpHtmlLib together. | 
| 36 |  |  | * | 
| 37 |  |  | * By now we inherit from the PageWidget, but this has | 
| 38 |  |  | * to be broken using the ProxyPattern or s.th.l.th. | 
| 39 |  |  | * I guess we'll have to dispatch to arbitrary concrete | 
| 40 |  |  | * Page-implementations here in future... | 
| 41 |  |  | * | 
| 42 | joko | 1.2 | * | 
| 43 | joko | 1.1 | * @author Andreas Motl <andreas.motl@ilo.de> | 
| 44 | joko | 1.2 | * @link http://www.netfrag.org/~joko/ | 
| 45 |  |  | * @copyright (c) 2003 - All Rights reserved. | 
| 46 |  |  | * @license GNU LGPL (GNU Lesser General Public License) | 
| 47 |  |  | * @link http://www.gnu.org/licenses/lgpl.txt | 
| 48 |  |  | * | 
| 49 |  |  | * @package org.netfrag.glib | 
| 50 |  |  | * @name DesignPattern::AdapterProxy | 
| 51 | joko | 1.1 | * | 
| 52 |  |  | */ | 
| 53 |  |  |  | 
| 54 |  |  | /** | 
| 55 |  |  | * Make sure we have the required parent class | 
| 56 |  |  | */ | 
| 57 |  |  |  | 
| 58 |  |  | //class Site_WebPageMVC extends PageWidget { | 
| 59 |  |  | //loadModule('DesignPattern::MVC'); | 
| 60 |  |  |  | 
| 61 |  |  | //require_once($phphtmllib."/widgets/PageWidget.inc"); | 
| 62 |  |  |  | 
| 63 |  |  |  | 
| 64 |  |  | // TODO: Learn TransparentProxy to do procedural calls instead | 
| 65 |  |  | // of instantiating a component and even less code could be in here..... | 
| 66 |  |  | // benefit: the TransparentProxy would be become even more powerful | 
| 67 |  |  | // eeäähhh, to the master Proxy it goes......!!! This one calls the handler(s)! | 
| 68 |  |  |  | 
| 69 |  |  |  | 
| 70 |  |  | //class Site_Adapter_php_Class { | 
| 71 |  |  | //class Site_Adapter_php_IncludeFile extends GenericDataWidget { | 
| 72 |  |  | class DesignPattern_AdapterProxy extends DesignPattern_TransparentProxy { | 
| 73 |  |  |  | 
| 74 |  |  | var $_adapter; | 
| 75 |  |  | var $_adapter_module; | 
| 76 |  |  | var $_adapter_options; | 
| 77 |  |  |  | 
| 78 |  |  | function &get_adapter() { | 
| 79 |  |  | return $this->_adapter; | 
| 80 |  |  | } | 
| 81 |  |  |  | 
| 82 |  |  | function &set_adapter(&$adapter) { | 
| 83 |  |  | $this->_adapter = &$adapter; | 
| 84 |  |  | } | 
| 85 |  |  |  | 
| 86 |  |  | // move this code to php::call_func!!! and wrap here!!! | 
| 87 |  |  | function &create_adapter($m, $f, $a, $options = array()) { | 
| 88 |  |  |  | 
| 89 |  |  | // load required module | 
| 90 |  |  | php::loadModule($m); | 
| 91 |  |  |  | 
| 92 |  |  | // V0: call-handler tests | 
| 93 |  |  | //$m::$f(); | 
| 94 |  |  | //$res = call_user_func(array($m, $f)); | 
| 95 |  |  | //call_user_func("$m::$f"); | 
| 96 |  |  | //$m->$f(); | 
| 97 |  |  |  | 
| 98 |  |  | // V1: | 
| 99 |  |  | //$res = call_user_func( array( $m, $f ) ); | 
| 100 |  |  |  | 
| 101 |  |  | // V2: | 
| 102 |  |  | //return call_user_func( array( $m, $f ), $a ); | 
| 103 |  |  |  | 
| 104 |  |  | if ($options[object]) { | 
| 105 |  |  | $m = php::mkInstance($m); | 
| 106 |  |  | } | 
| 107 |  |  |  | 
| 108 |  |  | // V3: | 
| 109 |  |  | $this->set_adapter( call_user_func( array( &$m, $f ), $a ) ); | 
| 110 |  |  | return $this->get_adapter(); | 
| 111 |  |  |  | 
| 112 |  |  | //print Dumper($res); | 
| 113 |  |  | //exit; | 
| 114 |  |  |  | 
| 115 |  |  | // FIXME: use TransparentProxy for this! | 
| 116 |  |  | // V1: | 
| 117 |  |  | //$this = $res; | 
| 118 |  |  | // V2: | 
| 119 |  |  | //$this->make_transparent(); | 
| 120 |  |  |  | 
| 121 |  |  | //return $res; | 
| 122 |  |  |  | 
| 123 |  |  | } | 
| 124 |  |  |  | 
| 125 |  |  | function set_adapter_module($name) { | 
| 126 |  |  | $this->_adapter_module = $name; | 
| 127 |  |  | } | 
| 128 |  |  | function get_adapter_module() { | 
| 129 |  |  | return $this->_adapter_module; | 
| 130 |  |  | } | 
| 131 |  |  | function set_adapter_options(&$options) { | 
| 132 |  |  | $this->_adapter_options = &$options; | 
| 133 |  |  | } | 
| 134 |  |  | function get_adapter_options() { | 
| 135 |  |  | return $this->_adapter_options; | 
| 136 |  |  | } | 
| 137 |  |  |  | 
| 138 |  |  | } | 
| 139 |  |  |  | 
| 140 |  |  | ?> |