/**
  * Constructor
  * @param ZObject $a_parent
  * @param string $a_name
  */
 function __construct(ZObject &$a_parent = null, $a_name = null)
 {
     parent::__construct($a_parent, $a_name);
     $this->m_plugins = array();
     if ($a_parent) {
         $this->setTarget($a_parent->getDispatcher());
     }
 }
示例#2
0
 /**
  * Constructor
  */
 function __construct(ZObject &$a_parent = null, $a_name = null)
 {
     parent::__construct($a_parent, $a_name);
     $this->m_models = array();
     $this->m_controllers = array();
     $this->m_library = array();
     $this->m_plugins = array();
     $this->m_modules = array();
 }
示例#3
0
 /**
  * Constructor
  * @param ZObject $a_parent
  * @param string $a_name
  */
 function __construct(ZObject &$a_parent = null, $a_name = null)
 {
     $this->m_block = array();
     parent::__construct($a_parent, $a_name);
     if (isset($this->action)) {
         $actions = array();
         switch (gettype($this->action)) {
             case 'string':
                 $actions = explode(' ', $this->action);
                 break;
             case 'array':
                 $actions =& $this->action;
                 break;
         }
         foreach ($actions as $k => $v) {
             $key = trim((string) $k);
             $name = trim((string) $v);
             if (empty($name)) {
                 continue;
             }
             if (empty($key) or is_numeric($key)) {
                 $key = $name;
             }
             try {
                 $action = $this->getModule()->getLoader()->action($name);
                 $action->setController($this);
                 $this->m_actions[$key] =& $action;
             } catch (ZActionException $e) {
                 if ($this->getModule()->isMode(ZModule::MODE_DEBUG)) {
                     throw new ZControllerException($e->getMessage(), ZControllerException::EXC_MODEL);
                 }
             }
         }
         unset($this->actions);
     }
     if (isset($this->model)) {
         $models = array();
         switch (gettype($this->model)) {
             default:
                 throw new ZControllerException("Controller '{$this->getName()}':  has wrong model type.", ZControllerException::EXC_MODEL);
                 break;
             case 'string':
                 $models = explode(' ', $this->model);
                 break;
             case 'array':
                 $models =& $this->model;
                 break;
         }
         foreach ($models as $m) {
             $name = trim((string) $m);
             if (empty($name)) {
                 continue;
             }
             try {
                 $this->addModel($name);
             } catch (ZModelException $e) {
                 if ($this->getModule()->isMode(ZModule::MODE_DEBUG)) {
                     throw new ZControllerException($e->getMessage(), ZControllerException::EXC_MODEL);
                 }
             }
         }
         unset($this->model);
     }
     if (isset($this->helper)) {
         $helpers = array();
         switch (gettype($this->helper)) {
             default:
                 throw new ZControllerException("Controller '{$this->getName()}':  has wrong helper type.", ZControllerException::EXC_MODEL);
                 break;
             case 'string':
                 $helpers = explode(' ', trim($this->helper));
                 break;
             case 'array':
                 $helpers =& $this->helper;
                 break;
         }
         foreach ($helpers as $h) {
             $name = trim((string) $h);
             if (empty($name)) {
                 continue;
             }
             $mod = $this->getModule();
             if (substr($name, 0, 1) == Zoombi::SS) {
                 $mod = Zoombi::getApplication();
                 $name = substr($name, 1);
             }
             try {
                 $mod->getLoader()->helper($name);
             } catch (ZHelperException $e) {
                 if ($this->getModule()->isMode(ZModule::MODE_DEBUG)) {
                     throw new ZControllerException($e->getMessage(), ZControllerException::EXC_HELPER);
                 }
             }
         }
         unset($this->helper);
     }
 }
示例#4
0
 /**
  * Module constructor
  * @param ZObject $parent
  * @param string $a_name
  */
 public function __construct(ZObject &$a_parent = null, $a_name = null)
 {
     parent::__construct($a_parent, $a_name);
     $this->m_stack_iterator = 0;
     $this->m_flag = array();
     $this->m_route_args = array();
     $this->m_stack = array();
     $this->setAcl(new ZAcl());
     $this->setMode(self::MODE_NORMAL);
     if ($a_parent instanceof ZModule) {
         $this->setMode($a_parent->getMode());
         $this->setConfig($a_parent->getConfig());
     }
     /*$d = new ZDispatcher($this, $a_name . '_dispatcher');
     		$this->setDispatcher($d);*/
     $this->m_plugin_mgr = new ZPluginManager($this);
 }
示例#5
0
 /**
  * Module constructor
  * @param ZObject $parent
  * @param string $a_name
  */
 public function __construct(ZObject &$a_parent = null, $a_name = null)
 {
     parent::__construct($a_parent, $a_name);
     $this->m_stack_iterator = 0;
     $this->m_flag = array();
     $this->m_route_args = array();
     $this->m_stack = array();
     $this->setAcl(new ZAcl());
     $this->setMode(self::MODE_NORMAL);
     if ($a_parent instanceof ZModule) {
         $this->setMode($a_parent->getMode());
         $cfg = clone $a_parent->getConfig();
         $cfg->unsetValue('load');
         $this->setConfig($cfg);
         unset($cfg);
         $this->setBaseDir($a_parent->fromModuleDir($a_name));
     }
     $this->setPluginManager(new ZPluginManager($this));
     $this->setConfig($this->fromConfigDir('config.php'));
 }