/**
  * Not exist function calls
  * @param string $a_name
  * @param array $a_params
  */
 public function __call($a_name, $a_params)
 {
     switch ($a_name) {
         case 'run':
         case 'exec':
         case 'start':
         case 'render':
         case 'display':
             if (!$this->getFlag(self::FLAG_NO_EXECUTE)) {
                 return $this->execute();
             }
     }
     return parent::__call($a_name, $a_params);
 }
Exemple #2
0
 /**
  * Find and load module
  * @param string $a_module
  * @return ZModule
  */
 public final function &module($a_module, $a_throw = false)
 {
     $mod_name = trim(strtolower($a_module));
     if (isset($this->m_modules[$mod_name]) or array_key_exists($mod_name, $this->m_modules)) {
         return $this->m_modules[$mod_name];
     }
     $this->emit(new ZEvent($this, 'preModule', $mod_name));
     $mod_dir = $this->getModule()->fromModuleDir($mod_name);
     if (!file_exists($mod_dir)) {
         if ($a_throw) {
             throw new ZModuleException('Module "' . $mod_name . '" not exist', ZControllerException::EXC_LOAD);
         }
     }
     if (file_exists($mod_dir) and is_dir($mod_dir)) {
         $module = null;
         try {
             $module = $this->_loadClass($mod_name, $this->m_modules, 'module', 'ZModule');
         } catch (ZLoaderException $e) {
             if ($a_throw) {
                 throw new ZModuleException($e->getMessage(), ZModuleException::EXC_LOAD);
             }
             $module = new ZModule($this->getModule(), $mod_name);
             $this->m_modules[$mod_name] = $module;
         }
         $module->initialize();
         $module->setFlag('initialized');
         $this->emit(new ZEvent($this, 'postModule', $mod_name, $module));
         return $module;
     }
     return Zoombi::$null;
 }
Exemple #3
0
 /**
  * Route path as another module
  * @param ZModule $a_mod
  * @param string $a_path
  * @param array $a_args
  * @return ZModule
  */
 private function &_reRoute(ZModule &$a_mod, $a_path, $a_args = array())
 {
     $a_mod->route($a_path, $a_args);
     $this->m_output = $a_mod->outputGet();
     $this->m_return = $a_mod->getReturn();
     return $this;
 }
 private function _processRoute(ZRoute &$a_route, &$a_code, &$a_message)
 {
     $ctl = null;
     $mod = null;
     if ($a_route->module) {
         $mod = new ZModule($this, $a_route->module . 'Module');
         $mod->setBaseDir($this->fromBaseDir(Zoombi::config('path.module', 'module')) . Zoombi::DS . $a_route->module);
     }
     if (!$a_route->controller) {
         $a_route->controller = $this->getConfig()->getValue('controller.default_name', 'index');
     }
     if (!$a_route->action) {
         $a_route->action = $this->getConfig()->getValue('controller.default_action', 'index');
     }
     if (!$mod) {
         $mod =& $this;
     }
     try {
         $ctl = $mod->load->controller($a_route->getController());
     } catch (ZControllerException $e) {
         $a_code = $e->getCode();
         $a_message = $e->getMessage();
         return false;
     }
     if (!$ctl) {
         return false;
     }
     $this->setController($ctl);
     return true;
 }
Exemple #5
0
 /**
  * Find and load module
  * @param string $a_module
  * @return ZModule
  */
 public final function &module($a_module)
 {
     $m = trim(strtolower($a_module));
     if (isset($this->m_modules[$m]) or array_key_exists($m, $this->m_modules)) {
         return $this->m_modules[$m];
     }
     $this->emit(new ZEvent($this, 'preModule', $m));
     //$p = $this->getModule()->getConfig()->getValue('module.directory_name', 'module') . Zoombi::DS . $m;
     //$d = $this->getModule()->fromBaseDir($p);
     $d = $this->getModule()->fromModuleDir($m);
     if (!file_exists($d)) {
         throw new ZModuleException('Module "' . $m . '" not exist', ZControllerException::EXC_LOAD);
     }
     if (file_exists($d) and is_dir($d)) {
         $mod = null;
         try {
             $mod = $this->_loadClass($m, $this->m_modules, 'module', 'ZModule');
         } catch (ZLoaderException $e) {
             switch ($e->getCode()) {
                 case ZLoaderException::EXC_NO_FILE:
                     $mod = new ZModule($this->getModule(), $m);
                     $this->m_modules[$m] =& $mod;
                     break;
                 default:
                     throw new ZModuleException($e->getMessage(), ZModuleException::EXC_LOAD);
                     break;
             }
         }
         $mod->setBaseDir($d)->setConfig($mod->fromConfigDir('config.php'))->initialize();
         $mod->setFlag('initialized');
         $this->emit(new ZEvent($this, 'postModule', $m, $mod));
         return $mod;
     }
     return Zoombi::$null;
 }