Exemplo n.º 1
0
 /**
  *
  * @return boolean
  */
 protected function shouldApplyDecorator()
 {
     if (ApplicationHook::$CONTROLLERS_FOLDER_PATH === "") {
         ApplicationHook::$CONTROLLERS_FOLDER_PATH = $this->CI->config->item('controllers_directory');
     }
     if ($this->controllerName != NULL && $this->controllerMethod != NULL) {
         return TRUE;
     }
     $index_page = $this->CI->config->item('index_page');
     $tokens = explode("/" . $index_page . "/", current_url());
     if (sizeof($tokens) >= 2) {
         $routeTokens = explode("/", $tokens[1]);
         if (isset($routeTokens[0]) && strtolower($routeTokens[0]) === 'oauth') {
             //skip oauth case ?
             return FALSE;
         }
         $routeTokensSize = sizeof($routeTokens);
         if ($routeTokensSize >= 2) {
             $c = 0;
             while (is_dir(ApplicationHook::$CONTROLLERS_FOLDER_PATH . $routeTokens[$c])) {
                 if ($routeTokens[$c] == "admin") {
                     $this->is_in_admin_domain = TRUE;
                     $c++;
                     break;
                 }
                 $c++;
             }
             $this->controllerName = $routeTokens[$c];
             $next_c = $c + 1;
             if ($routeTokensSize === $next_c) {
                 $this->controllerMethod = "index";
             } else {
                 $this->controllerMethod = $routeTokens[$next_c];
             }
             $this->controllerRequest = $tokens[1];
             return TRUE;
         } else {
             if ($routeTokensSize === 1 && strlen($routeTokens[0]) > 0) {
                 $this->controllerName = $routeTokens[0];
                 $this->controllerMethod = "index";
                 $this->controllerRequest = $tokens[1];
                 $this->shouldGoToAdminPanel($this->controllerName);
                 return TRUE;
             }
         }
     } else {
         if (strrpos(current_url(), "/" . $index_page) > 0) {
             $this->controllerName = "welcome";
             $this->controllerMethod = "index";
             $this->controllerRequest = "";
             return TRUE;
         }
     }
     return FALSE;
 }
Exemplo n.º 2
0
 /**
  *
  * @return boolean
  */
 protected function isValidControllerRequest()
 {
     if (ApplicationHook::$CONTROLLERS_FOLDER_PATH === "") {
         ApplicationHook::$CONTROLLERS_FOLDER_PATH = $this->CI->config->item('controllers_directory');
     }
     if ($this->controllerName != NULL && $this->controllerMethod != NULL) {
         return TRUE;
     }
     $index_page = $this->CI->config->item('index_page');
     $tokens = explode("/" . $index_page . "/", current_url());
     if (sizeof($tokens) >= 2) {
         $routeTokens = explode("/", $tokens[1]);
         $routeTokensSize = sizeof($routeTokens);
         if ($routeTokensSize >= 2) {
             $c = 0;
             while (is_dir(ApplicationHook::$CONTROLLERS_FOLDER_PATH . $routeTokens[$c])) {
                 $c++;
             }
             $this->controllerName = $routeTokens[$c];
             $next_c = $c + 1;
             if ($routeTokensSize === $next_c) {
                 $this->controllerMethod = "index";
             } else {
                 $this->controllerMethod = $routeTokens[$next_c];
             }
             $this->controllerRequest = $tokens[1];
             return TRUE;
         } else {
             if ($routeTokensSize === 1 && strlen($routeTokens[0]) > 0) {
                 $this->controllerName = $routeTokens[0];
                 $this->controllerMethod = "index";
                 $this->controllerRequest = $tokens[1];
                 return TRUE;
             }
         }
     } else {
         if (strrpos(current_url(), "/" . $index_page) > 0) {
             $this->controllerName = "home";
             $this->controllerMethod = "index";
             $this->controllerRequest = "";
             return TRUE;
         }
     }
     return FALSE;
 }