00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009 class ViewFactoryBase implements IViewFactory {
00010
00011
00012
00013
00014
00015 private $delegate = null;
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 public function create_view($type, $template_name, $params) {
00026 if ($this->delegate) {
00027 return $this->delegate->create_view($type, $template_name, $params);
00028 }
00029 else {
00030 switch ($type) {
00031 case IViewFactory::PAGE:
00032 require_once(dirname(__FILE__) . '/pageviewbase.cls.php');
00033 return new PageViewBase($params, $template_name);
00034 case IViewFactory::CONTENT:
00035 require_once(dirname(__FILE__) . '/contentviewbase.cls.php');
00036 return new ContentViewBase($template_name, $params);
00037 case IViewFactory::MESSAGE:
00038 require_once(dirname(__FILE__) . '/messageviewbase.cls.php');
00039 return new MessageViewBase($template_name);
00040 case IViewFactory::XML:
00041 require_once(dirname(__FILE__) . '/xmlviewbase.cls.php');
00042 return new XmlViewBase($template_name, $params);
00043 }
00044 }
00045 throw new Exception(tr('Unkown view type %t','core', array('%t' => $type)));
00046 }
00047
00048
00049
00050
00051
00052
00053 public function set_old_implementation(IViewFactory $implementation) {
00054 $this->delegate = $implementation;
00055 }
00056 }