/** * Init the module requested */ private static function initModule() { if (!self::$module) { self::$module = factory::getModule(self::$uriInfo['module'], array(), self::$scaffold, self::$cfg->allowScaffold); if (self::$module instanceof module_scaffold_controller && !self::$cfg->allowScaffold) { // Need to test if the action was expressly defined $ref = new nReflection(); $className = 'module_'.self::$uriInfo['module'].'_controller'; $prefix = null; $action = self::$uriInfo['action']; if (array_key_exists(NYROENV, self::$module->getCfg()->basicPrefixExec) && in_array($action, self::$module->getCfg()->getInArray('basicPrefixExec', NYROENV))) $prefix = ucfirst(NYROENV); else if (self::$module->getCfg()->prefixExec && !in_array($action, self::$module->getCfg()->noPrefixExec)) $prefix = self::$module->getCfg()->prefixExec; $exec = 'exec'.$prefix.ucFirst($action); if ($ref->rebuild($className)) { if ($ref->getMethod($exec)->getDeclaringClass()->name != $className) throw new module_exception('Request - initModule: '.self::$uriInfo['module'].'.'.$exec.' not found.'); } } if (self::$scaffold) { self::$uriInfo['moduleScaffold'] = self::$uriInfo['module']; self::$uriInfo['module'] = 'scaffold'; } } }
protected function afterInit() { $t = factory::get('tpl'); $this->module = factory::getModule(request::get('module')); nReflection::callMethod($this->module, request::get('action').'Action', request::get('param')); }
/** * Render an other tpl. To be used inside the tpl * * @param array $prm Possibile keys: * - string module Module to used (default: module used for the current tpl) * - string action Action to call * - other parameters must be used for the call to the module_abstract::exec method or module_abstract::publish */ public function render($prm) { if (!is_array($prm)){ $tmp = explode('/', $prm); $prm = array(); $prm['module'] = isset($tmp[0]) ? $tmp[0] : null; $prm['action'] = isset($tmp[1]) ? $tmp[1] : null; $prm['param'] = isset($tmp[2]) ? $tmp[2] : null; } $prm = array_merge(array('module'=>$this->cfg->module), $prm); $module = factory::getModule($prm['module'], array('render'=>true)); $module->exec($prm); return $module->publish($prm); }