Esempio n. 1
0
 public function route()
 {
     $mm = new Default_Model_Cmenu();
     $menu = $mm->fetchRow(array('`controller` = ?' => $this->config->controller));
     $error = '';
     if ($this->config->controller == 'cindex' || $menu) {
         if ($this->config->controller == 'cindex' || $this->view->user()->isAllowed($this->view->user('role'), $menu->resource)) {
             $this->config->control_lang_current = $this->config->control_lang_data[$this->config->control_lang];
             if ($this->config->post) {
                 if ($this->config->post['_search'] == 'true') {
                     $ss = array();
                     foreach ($this->config->post as $k => $v) {
                         if (substr($k, 0, 1) != '_' && $k != 'nd' && $k != 'rows') {
                             $ss[$k] = $v;
                         }
                     }
                     $this->config->post['_search'] = $ss;
                 } else {
                     unset($this->config->post['_search']);
                 }
                 foreach ($this->config->post as $k => $v) {
                     if (substr($k, 0, 1) == '_') {
                         $this->config->param[substr($k, 1)] = $v;
                     }
                 }
             }
             $s = new Zend_Session_Namespace();
             if (!is_array(@$s->control['history'][$this->config->controller])) {
                 $s->control['history'][$this->config->controller] = array();
             }
             $this->config->param = $s->control['history'][$this->config->controller] = array_merge($s->control['history'][$this->config->controller], $this->config->param->toArray());
             $this->view->inlineScript('script', 'c.cfg.controller = "' . $this->config->controller . '";c.cfg.action = "' . $this->config->action . '";');
             $_SESSION['isLoggedIn'] = $this->view->user()->isAllowed($this->view->user('role'), Zkernel_Common::getById(array('model' => new Default_Model_Cresource(), 'field' => 'id', 'key' => 'key', 'id' => 'file')));
             $this->configFromDb();
             try {
                 $this->view->render($this->config->controller . '/' . $this->config->action . '.phtml');
             } catch (Zend_View_Exception $e) {
                 try {
                     $this->view->render($this->config->controller . '/ctl.phtml');
                 } catch (Zend_View_Exception $e) {
                 }
             }
             $type = $this->config->type;
             if (!$type) {
                 $type = substr($this->config->action, 3);
             }
             switch ($type) {
                 case 'list':
                 case 'text':
                     $func = 'show';
                     break;
                 case 'add':
                 case 'edit':
                     $func = 'form';
                     break;
                 default:
                     $func = $type;
                     break;
             }
             $type = $type == 'show' ? 'list' : $type;
             $func = 'route' . ucfirst($func);
             $this->config->type = $type;
             $this->configFromType();
             $this->configFromDb();
             $this->configFromRequest();
             $this->{$func}();
         } else {
             $error = $this->config->control_lang_current['access_error'];
         }
     } else {
         $error = $this->config->control_lang_current['no_controller'];
     }
     if ($error) {
         $this->view->inlineScript('script', 'c.load_menu();c.load_auth();c.go(c.cfg.def_controller);');
         $this->config->stop_frame = true;
         $this->config->info = array($error);
     }
     return $this;
 }