public function &bresourceAction()
 {
     $model_and_view = new __ModelAndView('resource');
     $resource_id = __ActionDispatcher::getInstance()->getRequest()->getParameter('resource_id');
     $model_and_view->addObject('resource_id', $resource_id);
     return $model_and_view;
 }
 /**
  * This method return a singleton instance of __ActionDispatcher instance
  *
  * @return __ActionDispatcher a reference to the current __ActionDispatcher instance
  */
 public static function &getInstance()
 {
     if (self::$_instance == null) {
         self::$_instance = new __ActionDispatcher();
     }
     return self::$_instance;
 }
 public function defaultAction()
 {
     //Will force a logout in the user:
     __AuthenticationManager::getInstance()->logout();
     //Now will process the index action (will render the login page)
     __ActionDispatcher::getInstance()->dispatch(new __ActionIdentity('index'));
     //No views will be returned by this action:
     return null;
 }
 public function defaultAction()
 {
     $request = __ActionDispatcher::getInstance()->getRequest();
     if ($request->hasParameter('component_id')) {
         $component_id = $request->getParameter('component_id');
         $component_pool = __ComponentPool::getInstance();
         if ($component_pool->hasComponent($component_id)) {
             $component = $component_pool->getComponent($component_id);
             $response = $component->handleCallback($request);
             print $response;
         }
     }
 }
Exemplo n.º 5
0
 public function displayError(Exception $exception)
 {
     $request = $this->_getRequest($exception);
     $action_identity = new __ActionIdentity('yourOwnErrorControllerCodeHere');
     $response = __FrontController::getInstance()->getResponse();
     if ($response != null) {
         $response->clear();
         $response = __ActionDispatcher::getInstance()->dispatch($action_identity, $request, $response);
         $response->flushAll();
     } else {
         print "Unknown Error";
     }
     exit;
 }
 /**
  * This method dispatch the current request
  * 
  * @param __IRequest &$request The request to process to
  * @param __IResponse &$response The instance to set the response to
  *
  */
 public function processRequest(__IRequest &$request, __IResponse &$response)
 {
     //resolve action identity from request
     $action_identity = $request->getActionIdentity();
     //resolve the action controller associated to the given action identity
     $controller_definition = __ActionControllerResolver::getInstance()->getActionControllerDefinition($action_identity->getControllerCode());
     //check if action controller is requestable
     if ($controller_definition instanceof __ActionControllerDefinition && $controller_definition->isRequestable()) {
         __HistoryManager::getInstance()->addRequest($request);
         //last, execute the action controller
         __ActionDispatcher::getInstance()->dispatch($action_identity);
     } else {
         throw __ExceptionFactory::getInstance()->createException('ERR_ACTION_NON_REQUESTABLE');
     }
 }
 protected function &defaultAction()
 {
     $request = __ActionDispatcher::getInstance()->getRequest();
     $error_parameters = array();
     //1. If REQUEST_ERROR_CODE has been found on request:
     if ($request->hasParameter(__ApplicationContext::getInstance()->getPropertyContent('REQUEST_ERROR_CODE'))) {
         $error_code = $request->getParameter(__ApplicationContext::getInstance()->getPropertyContent('REQUEST_ERROR_CODE'));
         switch ($error_code) {
             case 55601:
                 $error_parameters[] = $request->getUri()->getAbsoluteUrl();
                 break;
         }
     } else {
         $error_code = __ExceptionFactory::getInstance()->getErrorTable()->getErrorCode('ERR_UNKNOW_ERROR');
     }
     throw __ExceptionFactory::getInstance()->createException($error_code, $error_parameters);
 }
 protected function _executeControllerAssociatedToState(__FlowState $state, __FlowExecutor &$flow_executor, $flow_execution_key)
 {
     try {
         $action_identity = $state->getActionIdentity();
         $response = __ActionDispatcher::getInstance()->dispatch($action_identity);
         if ($response instanceof __IResponse) {
             $flow_executor->setResponse($response);
             $response->clear();
             //redirect via 303 because of the redirect after submit pattern (alwaysRedirectOnPause)
             $request = __FrontController::getInstance()->getRequest();
             $uri = $request->getUri();
             //add the flow execution key parameter:
             $application_context = __ApplicationContext::getInstance();
             $request_flow_execution_key = $application_context->getPropertyContent('REQUEST_FLOW_EXECUTION_KEY');
             $request_flow_state_id = $application_context->getPropertyContent('REQUEST_FLOW_STATE_ID');
             $uri->addParameter($request_flow_execution_key, $flow_execution_key);
             $uri->addParameter($request_flow_state_id, $state->getId());
             $empty_request = __RequestFactory::getInstance()->createRequest();
             __FrontController::getInstance()->redirect($uri, $empty_request, 303);
         } else {
             if ($response instanceof __FlowEvent) {
                 $fc_response = __FrontController::getInstance()->getResponse();
                 $fc_response->clear();
                 //clear the response content (to avoid decorator lateral issues)
                 $state = $flow_executor->resume($flow_execution_key, $response->getEventName());
                 if ($state != null) {
                     $application_context = __ApplicationContext::getInstance();
                     $action_identity = $state->getActionIdentity();
                     $this->_executeControllerAssociatedToState($state, $flow_executor, $flow_execution_key);
                 }
             }
         }
     } catch (Exception $e) {
         if ($flow_executor->isExceptionHandled($e)) {
             //$state = $flow_executor->handleException($flow_execution_key, $e);
             //if($state != null) {
             //    $this->_executeControllerAssociatedToState($flow_executor, $state);
             //}
         } else {
             throw $e;
         }
     }
     return $response;
 }
 /**
  * This method dispatch the current request
  *
  */
 public function processRequest(__IRequest &$request, __IResponse &$response)
 {
     $action_identity = $request->getActionIdentity();
     $controller_code = $action_identity->getControllerCode();
     //in case we haven't define any controller, will use the commandline controller from lion admin:
     if (empty($controller_code)) {
         //switch to lion admin area:
         __ContextManager::getInstance()->createContext("LION_ADMIN_AREA", ADMIN_DIR);
         __ContextManager::getInstance()->switchContext("LION_ADMIN_AREA");
         //execute the commandline controller:
         $action_identity->setControllerCode('commandline');
     }
     $controller_definition = __ActionControllerResolver::getInstance()->getActionControllerDefinition($action_identity->getControllerCode());
     //check if action controller is requestable
     if ($controller_definition instanceof __ActionControllerDefinition && $controller_definition->isRequestable()) {
         __ActionDispatcher::getInstance()->dispatch($action_identity);
     } else {
         throw __ExceptionFactory::getInstance()->createException('ERR_ACTION_NON_REQUESTABLE');
     }
 }
 public final function __construct($view_code)
 {
     $this->_view_code = $view_code;
     $this->_renderers_stack = new __Stack();
     $this->_properties_stack = new __Stack();
     if (__ComponentHandlerManager::getInstance()->hasComponentHandler($view_code)) {
         $this->_first_time_execution = false;
         $this->_component_handler = __ComponentHandlerManager::getInstance()->getComponentHandler($view_code);
     } else {
         $this->_component_handler = __ComponentHandlerManager::getInstance()->createComponentHandler($view_code);
     }
     $this->_event_handler = __EventHandlerManager::getInstance()->getEventHandler($view_code);
     $request = __ActionDispatcher::getInstance()->getRequest();
     if ($request != null) {
         if ($request->hasParameter('PARENT_VIEW_CODE')) {
             $this->_event_handler->setParentViewCode($request->getParameter('PARENT_VIEW_CODE'));
         }
         if ($request->hasParameter('ACTIONBOX_ID')) {
             $this->_event_handler->setContainerActionBoxId($request->getParameter('ACTIONBOX_ID'));
         }
     }
 }
 /**
  * Executes the action associated to the current actionbox, setting the
  * result to the actionbox response.
  * 
  * If autorefresh property is set to true (default value), the actionbox will be executed in each non-ajax request
  * even if no new control values has been set (same action, same controller and same parameters)
  * 
  * @see __ActionBoxComponent::getResponse
  *
  */
 public function executeAction($force_execution = false)
 {
     if ($force_execution || $this->_canRefresh()) {
         $action_identity = new __ActionIdentity($this->_controller, $this->_action);
         $request = new __HttpRequest();
         $request->fromArray($this->_parameters);
         $request->addParameter('PARENT_VIEW_CODE', $this->getViewCode());
         $request->addParameter('ACTIONBOX_ID', $this->getId());
         $response = new __HttpResponse();
         $response = __ActionDispatcher::getInstance()->dispatch($action_identity, $request, $response);
         $response_content = $response->getContent();
         if ($this->_latest_response != $response_content) {
             $this->_latest_response = $response_content;
             $this->_synchronize_client = true;
         }
         $this->_dirty = false;
         $this->_refreshed = true;
     }
 }
Exemplo n.º 12
0
 public function postExecute()
 {
     __ActionDispatcher::getInstance()->dispatch(new __ActionIdentity('decorator', 'footerI18n'));
 }
 public function processRequest(__IRequest &$request, __IResponse &$response)
 {
     __ActionDispatcher::getInstance()->dispatch(new __ActionIdentity('resource'));
 }