Example #1
0
 /**
  * Routes the request to appropriate controller and returns resource params
  *
  * @return Resource $resource
  */
 public static function getResource()
 {
     $resource = new Resource();
     $firstParam = RequestManager::getParam(RequestManager::FIRST_PARAM);
     $secondParam = RequestManager::getParam(RequestManager::SECOND_PARAM);
     $thirdParam = RequestManager::getParam(RequestManager::THIRD_PARAM);
     if (AuthController::isLoggedIn()) {
         if (empty($firstParam) && empty($secondParam) && empty($thirdParam)) {
             $resource->setKey(Constants::INDEX_URI_KEY);
         } else {
             $className = ucfirst($firstParam) . 'Controller';
             if (class_exists($className) && is_subclass_of(new $className(), 'AbstractController')) {
                 $resource->setKey($className::MODULE_KEY);
             } else {
                 if (!empty($firstParam) && !empty($secondParam) && !empty($thirdParam)) {
                     $resource->setKey(Constants::EXPLORER_URI_KEY);
                 } else {
                     $resource->setKey(Constants::INDEX_URI_KEY);
                 }
             }
         }
     } else {
         $resource->setKey(Constants::AUTH_URI_KEY);
         if ($firstParam !== Constants::AUTH_URI_KEY) {
             RequestManager::setPendingRequestURI();
         }
     }
     $resource = self::setCorrectParams($resource, array($firstParam, $secondParam, $thirdParam));
     return $resource;
 }
Example #2
0
 /**
  * @see AbstractController::run()
  */
 public function run(Resource $resource)
 {
     $searchQuery = RequestManager::getParam(self::SEARCH_QUERY_PARAM);
     if (!empty($searchQuery)) {
         $results = $this->search($searchQuery);
         $this->setBean(array('query' => $searchQuery, 'resultSet' => $results));
         $this->getView()->setViewName(self::MODULE_KEY)->display();
     } else {
         RequestManager::redirect();
     }
 }
Example #3
0
 /**
  * Store current url before going to auth form
  */
 public static function setPendingRequestURI()
 {
     $uri = RequestManager::getParam(RequestManager::PRIMITIVE_PARAM);
     // hack for avoiding unneccessary favicon.ico http requests from browsers
     if (!empty($uri) && strtolower($uri) != 'favicon.ico') {
         setcookie(Session::SESS_PENDING_REQ_URI, $uri);
     }
 }
Example #4
0
 /**
  * @see AbstractController::run()
  */
 public function run(Resource $resource)
 {
     $pid = RequestManager::getParam('id');
     $this->execute($pid);
 }