Exemplo n.º 1
0
 /**
  * 启动路由器
  * @access public
  * @return void
  */
 public function run()
 {
     $this->_request = XF_Controller_Request_Http::getInstance();
     $this->_getFinalUri();
     $status = $this->_validateRewrite();
     if ($status == false) {
         //是否启用默认路由规则
         if (XF_Config::getInstance()->isUseDefaultRouter() == false) {
             if ($this->_final_uri != '' && $this->_final_uri != '/' && $this->_final_uri != '/index.php') {
                 throw new XF_Controller_Router_Exception('404 Not found!', 404);
             } else {
                 $this->_setDefault();
             }
         } else {
             $this->_start();
         }
     }
     //当前分析到的模块是否有效
     if ($this->_request->getModule() == 'unknown') {
         throw new XF_Controller_Router_Exception('404 Not found!', 404);
     }
     if (strtolower($this->_request->getModule()) != 'default' && $this->_close_all_module === true && !isset($this->_open_modules[strtolower($this->_request->getModule())])) {
         throw new XF_Controller_Router_Exception('The module is close', 404);
     }
     if (isset($this->_close_modules[strtolower($this->_request->getModule())])) {
         throw new XF_Controller_Router_Exception('The module is close', 404);
     }
     //当前Action是否禁用了默认路由
     if ($this->_request_default_route === TRUE) {
         if (isset($this->_disabled_default_routes[strtolower($this->_request->getModule() . $this->_request->getController() . $this->_request->getAction())])) {
             throw new XF_Controller_Router_Exception('The action default router disabled', 404);
         }
     }
     $this->_readOldRequestParams();
 }
Exemplo n.º 2
0
 /**
  * 设置模板文件
  * @access public
  * @param string $tpl
  * @return XF_Controller_Abstract
  */
 public function setTemplate($tpl)
 {
     if (strpos($tpl, '.php') > 0) {
         $file = APPLICATION_PATH . '/' . $tpl;
     } else {
         $file = $this->_view->getTemplateStartLocation() . '/' . $this->_request->getController() . '/' . $tpl . '.php';
     }
     if (is_file($file)) {
         $this->_action_template = $file;
         return $this;
     }
     throw new XF_Controller_Exception('Action template not found');
 }