Example #1
0
 /**
  * Returns an instance of class (singleton pattern implementation).
  *
  * @return OW_ApiRequestHandler
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Example #2
0
 /**
  * @return OW_RequestHandler
  */
 public static function getRequestHandler()
 {
     self::detectContext();
     switch (self::$context) {
         case self::CONTEXT_API:
             return OW_ApiRequestHandler::getInstance();
         default:
             return OW_RequestHandler::getInstance();
     }
 }
Example #3
0
 /**
  * ---------
  */
 public function handleRequest()
 {
     $baseConfigs = OW::getConfig()->getValues('base');
     //members only
     if ((int) $baseConfigs['guests_can_view'] === BOL_UserService::PERMISSIONS_GUESTS_CANT_VIEW && !OW::getUser()->isAuthenticated()) {
         $attributes = array(OW_RequestHandler::CATCH_ALL_REQUEST_KEY_CTRL => 'BASE_CTRL_User', OW_RequestHandler::CATCH_ALL_REQUEST_KEY_ACTION => 'standardSignIn');
         OW::getRequestHandler()->setCatchAllRequestsAttributes('base.members_only', $attributes);
         $this->addCatchAllRequestsException('base.members_only_exceptions', 'base.members_only');
     }
     //splash screen
     if ((bool) OW::getConfig()->getValue('base', 'splash_screen') && !isset($_COOKIE['splashScreen'])) {
         $attributes = array(OW_RequestHandler::CATCH_ALL_REQUEST_KEY_CTRL => 'BASE_CTRL_BaseDocument', OW_RequestHandler::CATCH_ALL_REQUEST_KEY_ACTION => 'splashScreen', OW_RequestHandler::CATCH_ALL_REQUEST_KEY_REDIRECT => true, OW_RequestHandler::CATCH_ALL_REQUEST_KEY_JS => true, OW_RequestHandler::CATCH_ALL_REQUEST_KEY_ROUTE => 'base_page_splash_screen');
         OW::getRequestHandler()->setCatchAllRequestsAttributes('base.splash_screen', $attributes);
         $this->addCatchAllRequestsException('base.splash_screen_exceptions', 'base.splash_screen');
     }
     // password protected
     if ((int) $baseConfigs['guests_can_view'] === BOL_UserService::PERMISSIONS_GUESTS_PASSWORD_VIEW && !OW::getUser()->isAuthenticated() && !isset($_COOKIE['base_password_protection'])) {
         $attributes = array(OW_RequestHandler::CATCH_ALL_REQUEST_KEY_CTRL => 'BASE_CTRL_BaseDocument', OW_RequestHandler::CATCH_ALL_REQUEST_KEY_ACTION => 'passwordProtection');
         OW::getRequestHandler()->setCatchAllRequestsAttributes('base.password_protected', $attributes);
         $this->addCatchAllRequestsException('base.password_protected_exceptions', 'base.password_protected');
     }
     // maintenance mode
     if ((bool) $baseConfigs['maintenance'] && !OW::getUser()->isAdmin()) {
         $attributes = array(OW_RequestHandler::CATCH_ALL_REQUEST_KEY_CTRL => 'BASE_CTRL_BaseDocument', OW_RequestHandler::CATCH_ALL_REQUEST_KEY_ACTION => 'maintenance', OW_RequestHandler::CATCH_ALL_REQUEST_KEY_REDIRECT => true);
         OW::getRequestHandler()->setCatchAllRequestsAttributes('base.maintenance_mode', $attributes);
         $this->addCatchAllRequestsException('base.maintenance_mode_exceptions', 'base.maintenance_mode');
     }
     try {
         OW_ApiRequestHandler::getInstance()->dispatch();
     } catch (RedirectException $e) {
         $this->redirect($e->getUrl(), $e->getRedirectCode());
     } catch (InterceptException $e) {
         OW::getRequestHandler()->setHandlerAttributes($e->getHandlerAttrs());
         $this->handleRequest();
     }
 }