/**
  * Singleton method to retrieve the __FrontController instance
  *
  * @return __FrontController The singleton __FrontController instance
  */
 public static final function &getInstance()
 {
     if (self::$_instance == null) {
         self::$_instance = self::_createFrontController();
     }
     return self::$_instance;
 }
 public function bootstrap_form_submit(__UIEvent &$event)
 {
     if (__ModelProxy::getInstance()->doBootstrap(APP_DIR)) {
         $uri = __UriFactory::getInstance()->createUri()->setRoute('lion')->setController('bootstrap')->setAction('success');
         __FrontController::getInstance()->redirect($uri);
     }
 }
Ejemplo n.º 3
0
 protected function _renderComponent($enclosed_content)
 {
     $return_value = $enclosed_content;
     //if the current renderer contains a validator, register it if it's being created:
     if ($this->_register_as_validator && $this->_component instanceof __IValidator) {
         $component_to_validate = $this->_component->getComponentToValidate();
         $component_to_validate->registerValidator($this->_component);
     }
     if ($this->_component instanceof __ISubmitter && __FrontController::getInstance()->getRequestType() != REQUEST_TYPE_XMLHTTP) {
         $request = __FrontController::getInstance()->getRequest();
         $this->_component->setLastRequest($request);
     }
     //call the init event
     if ($this->_event_handler->isEventHandled('beforeRender', $this->_component->getName())) {
         $event = new __UIEvent('beforeRender', null, $this->_component);
         $this->_event_handler->handleEvent($event);
     }
     if ($this->_component_writer != null) {
         $return_value = $this->_component_writer->startRender($this->_component) . $this->_component_writer->renderContent($enclosed_content, $this->_component) . $this->_component_writer->endRender($this->_component);
     }
     //call the init event
     if ($this->_event_handler->isEventHandled('afterRender', $this->_component->getName())) {
         $event = new __UIEvent('afterRender', null, $this->_component);
         $this->_event_handler->handleEvent($event);
     }
     //last, mark the component as rendered (to avoid to be removed from the component pool if not rendered)
     $this->_event_handler->getComponentHandler()->markComponentAsRendered($this->_component->getName(), $this->_component->getIndex());
     return $return_value;
 }
 /**
  * Sends to client an async message containing all pending status change notifications
  *
  */
 public function notify()
 {
     $async_message = __AsyncMessageFactory::getInstance()->createComponentsAsyncMessage($this->_dirty_components);
     $response = __FrontController::getInstance()->getResponse();
     $response->appendContent($async_message->toJson());
     $response->flush();
 }
Ejemplo n.º 5
0
 protected function _doGetContent()
 {
     if (__FrontController::getInstance()->getRequestType() == REQUEST_TYPE_XMLHTTP || $this == __FrontController::getInstance()->getResponse()) {
         __ResponseWriterManager::getInstance()->write($this);
         __ResponseWriterManager::getInstance()->clear();
     }
     $return_value = parent::_doGetContent();
     return $return_value;
 }
 public function onAccessError()
 {
     if (__ApplicationContext::getInstance()->getPropertyContent('LION_ADMIN_AUTH_REQUIRED') == true) {
         //logout the user:
         __AuthenticationManager::getInstance()->logout();
         $uri = __UriFactory::getInstance()->createUri()->setRoute('lion')->setController('login');
         __FrontController::getInstance()->forward($uri);
     } else {
         throw __ExceptionFactory::getInstance()->createException('ERR_ACTION_PERMISSION_ERROR', array('action_code' => $this->getCode()));
     }
 }
 public function login_form_submit(__UIEvent &$event)
 {
     $login = $this->getComponent('login')->getValue();
     $password = $this->getComponent('password')->getValue();
     //authenticate the user:
     $user = __ModelProxy::getInstance()->logon($login, $password);
     //if authentication success
     if ($user != null) {
         //redirect the user to the private page:
         __FrontController::getInstance()->redirect('protectedPage.action');
     }
 }
Ejemplo n.º 8
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;
 }
 public function startRender()
 {
     if (__FrontController::getInstance()->getRequestType() != REQUEST_TYPE_XMLHTTP) {
         if (__ApplicationContext::getInstance()->hasProperty('INCLUDE_LION_JS')) {
             $include_lion_js = __ApplicationContext::getInstance()->getPropertyContent('INCLUDE_LION_JS');
         } else {
             $include_lion_js = true;
         }
         if ($include_lion_js) {
             $local_js_lib = __ApplicationContext::getInstance()->getPropertyContent('JS_LIB_DIR');
             $lion_js_file = __UrlHelper::resolveUrl(__UrlHelper::glueUrlParts($local_js_lib, 'lion.js'));
             __FrontController::getInstance()->getResponse()->prependContent('<script language="javascript" type="text/javascript" src="' . $lion_js_file . '"></script>' . "\n", 'lion-js');
         }
     }
     $response_writer_manager = __ResponseWriterManager::getInstance();
     if ($response_writer_manager->hasResponseWriter('javascript')) {
         $javascript_response_writer = $response_writer_manager->getResponseWriter('javascript');
     } else {
         $javascript_response_writer = new __JavascriptOnDemandResponseWriter('javascript');
         $response_writer_manager->addResponseWriter($javascript_response_writer);
     }
     if (!$javascript_response_writer->hasResponseWriter('setup-client-event-handler')) {
         $setup_client_event_handler_rw = new __JavascriptOnDemandResponseWriter('setup-client-event-handler');
         $js_code = "\n" . '(__ClientEventHandler.getInstance()).setCode("' . __CurrentContext::getInstance()->getId() . '");' . "\n";
         if (__Lion::getInstance()->getRuntimeDirectives()->getDirective('DEBUG_MODE')) {
             $js_code .= "(__ClientEventHandler.getInstance()).setDebug(true);\n";
             if (__ApplicationContext::getInstance()->getPropertyContent('DEBUG_AJAX_CALLS') == true) {
                 if (strtoupper(__ApplicationContext::getInstance()->getPropertyContent('DEBUGGER')) == 'ZEND') {
                     $client_ip = $_SERVER['REMOTE_ADDR'];
                     $debug_port = __ApplicationContext::getInstance()->getPropertyContent('ZEND_DEBUG_PORT');
                     $debug_url = 'index.ajax?' . 'start_debug=1&debug_port=' . $debug_port . '&debug_fastfile=1&debug_host=' . $client_ip . '&send_sess_end=1&debug_stop=1&debug_url=1&debug_new_session=1&no_remote=1';
                     $js_code .= "(__ClientEventHandler.getInstance()).setUrl('" . $debug_url . "');\n";
                 }
             }
         }
         if (!__FrontController::getInstance() instanceof __ComponentLazyLoaderFrontController && __FrontController::getInstance()->getRequestType() == REQUEST_TYPE_HTTP) {
             $url = __FrontController::getInstance()->getRequest()->getUrl();
             $encoded_url = base64_encode(serialize($url));
             $js_code .= "(__ClientEventHandler.getInstance()).setViewCode('" . $encoded_url . "');\n";
             $flow_scope = __ApplicationContext::getInstance()->getFlowScope();
             if ($flow_scope != null) {
                 $js_code .= "(__ClientEventHandler.getInstance()).setFlowExecutionKey('" . $flow_scope->getId() . "');\n";
             }
         }
         $setup_client_event_handler_rw->addJsCode($js_code);
         $javascript_response_writer->addResponseWriter($setup_client_event_handler_rw);
     }
     parent::startRender();
 }
 public function login_form_submit(__UIEvent &$event)
 {
     //retrieve the login and password from
     //the components:
     $login = $this->getComponent('login')->getValue();
     $password = $this->getComponent('password')->getValue();
     //try to authenticate the user:
     if (__ModelProxy::getInstance()->logon($login, $password)) {
         //redirect the user to the private page:
         $private_page_uri = __UriFactory::getInstance()->createUri()->setRoute('default')->setController('protectedPage');
         __FrontController::getInstance()->forward($private_page_uri);
     } else {
         $this->getComponent('error_label')->setText('Wrong username or password');
     }
 }
 protected function _resolveAndCallRemoteService(__IRequest &$request)
 {
     $return_value = null;
     $request = __FrontController::getInstance()->getRequest();
     if ($request->hasParameter('service_name')) {
         $service_name = $request->getParameter('service_name');
         $model_proxy = __ModelProxy::getInstance();
         if ($model_proxy->isRemoteService($service_name)) {
             $model_service = $model_proxy->getModelService($service_name);
             $return_value = $model_service->callAsRemoteService($request);
         } else {
             throw __ExceptionFactory::getInstance()->createException('Service ' . $service_name . ' is not declared as remote');
         }
     }
     return $return_value;
 }
 public function closeRender()
 {
     //**After Render** remove all the components that has not been rendered
     $this->_component_handler->expireNotRenderedComponents();
     //Them, set the view code within the response:
     if ($this->_component_handler->hasPoolableComponents()) {
         $response = __FrontController::getInstance()->getResponse();
         if ($response != null) {
             if ($this->_component_handler->isDirty()) {
                 $response->addViewCode($this->_view_code, __Response::NOT_CACHEABLE);
             } else {
                 $response->addViewCode($this->_view_code, __Response::CACHEABLE);
             }
         }
     }
 }
Ejemplo n.º 13
0
 public function resolveEvent()
 {
     if ($this->_event == null) {
         $request = __FrontController::getInstance()->getRequest();
         if ($request->hasParameter('event')) {
             $event_json_string = stripslashes($request->getParameter('event'));
             $event = json_decode($event_json_string, true);
             $component_id = $event['componentId'];
             $event_name = $event['eventName'];
             $extra_info = $event['extraInfo'];
             if (__ComponentPool::getInstance()->hasComponent($component_id)) {
                 $component = __ComponentPool::getInstance()->getComponent($component_id);
                 //create the event instance:
                 $this->_event = new __UIEvent($event_name, $extra_info, $component);
             }
         }
     }
     return $this->_event;
 }
Ejemplo n.º 14
0
 public function startRender(__IComponent &$component)
 {
     $component_id = $component->getId();
     $component_properties = $component->getProperties();
     foreach ($component_properties as $property => $value) {
         $property = strtolower($property);
         if ($property != 'runat') {
             $properties[] = $property . '="' . $value . '"';
         }
     }
     $properties[] = 'id="' . $component_id . '"';
     $properties[] = 'name="' . $component->getName() . '"';
     $properties[] = 'action = "' . __UriContainerWriterHelper::resolveUrl($component) . '"';
     $properties[] = 'method="' . strtoupper($component->getMethod()) . '"';
     if ($component->getVisible() == false) {
         $properties[] = 'style = "display : none;"';
     }
     $url = __FrontController::getInstance()->getRequest()->getUrl();
     $encoded_url = base64_encode(serialize($url));
     $form_code = '<form ' . join(' ', $properties) . ' onSubmit="return (__ClientEventHandler.getInstance()).handleSubmit(this);">' . "\n";
     $request_submit_code = __ContextManager::getInstance()->getApplicationContext()->getPropertyContent('REQUEST_SUBMIT_CODE');
     $form_code .= '<input type="HIDDEN" name="' . $request_submit_code . '" value="' . $component_id . '"></input>' . "\n";
     $form_code .= '<input type="HIDDEN" name="viewCode" value="' . $encoded_url . '"></input>' . "\n";
     $flow_executor = __FlowExecutor::getInstance();
     if ($flow_executor->hasActiveFlowExecution()) {
         $active_flow_execution = $flow_executor->getActiveFlowExecution();
         $request_flow_execution_key = __ApplicationContext::getInstance()->getPropertyContent('REQUEST_FLOW_EXECUTION_KEY');
         $form_code .= '<input type="HIDDEN" name="' . $request_flow_execution_key . '" value="' . $active_flow_execution->getId() . '"></input>' . "\n";
         $current_state = $active_flow_execution->getCurrentState();
         if ($current_state != null) {
             $request_flow_state_id = __ApplicationContext::getInstance()->getPropertyContent('REQUEST_FLOW_STATE_ID');
             $form_code .= '<input type="HIDDEN" name="' . $request_flow_state_id . '" value="' . $current_state->getId() . '"></input>' . "\n";
         }
     }
     $hidden_parameters = $component->getHiddenParameters();
     foreach ($hidden_parameters as $hidden_parameter_name => $hidden_parameter_value) {
         if (strtoupper($hidden_parameter_name) != strtoupper($request_submit_code) && strtoupper($hidden_parameter_name) != 'CLIENTENDPOINTVALUES') {
             $form_code .= '<input type="HIDDEN" name="' . $hidden_parameter_name . '" value="' . htmlentities($hidden_parameter_value) . '"></input>' . "\n";
         }
     }
     return $form_code;
 }
 public function preExecute()
 {
     $request = __FrontController::getInstance()->getRequest();
     if ($request->hasParameter('page')) {
         $this->_page = $request->getParameter('page');
         $doc_file = LION_DIR . DIRECTORY_SEPARATOR . 'documentation' . DIRECTORY_SEPARATOR . $this->_doc_directory . DIRECTORY_SEPARATOR . $this->_page . '.html';
         if (is_file($doc_file) && is_readable($doc_file)) {
             $doc_content = file_get_contents($doc_file);
             $doc_content = preg_replace('/(href=\\"(?!http).+?)\\.html/', '$1.lion', $doc_content);
             $doc_content = preg_replace('/src\\="(\\.\\.\\/)*images/', 'src="' . __UrlHelper::resolveUrl('resources/documentation/images'), $doc_content);
             $this->_doc_content = $doc_content;
             if (preg_match('/\\<h1\\>([^<]+)\\<\\/h1\\>/', $doc_content, $matched)) {
                 $title = $matched[1];
                 $title = str_replace('Class:', 'Class ', $title);
                 $request->addParameter('header::title', $title);
             }
         }
     }
     parent::preExecute();
 }
 public function negociateLocale()
 {
     $front_controller = __FrontController::getInstance();
     $request = $front_controller->getRequest();
     $app_name = md5(__ApplicationContext::getInstance()->getPropertyContent('APP_NAME'));
     if ($request != null && $request->hasCookie('__LOCALE__' . $app_name)) {
         $locale_code = $request->getCookie('__LOCALE__' . $app_name);
         $return_value = new __Locale($locale_code);
     } else {
         if (key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER)) {
             $http_accept_language = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
         }
         if (!empty($http_accept_language)) {
             //by default:
             if (class_exists('Locale')) {
                 $accepted_locale = Locale::acceptFromHttp($http_accept_language);
                 $candidate_language = Locale::getPrimaryLanguage($accepted_locale);
             } else {
                 $accepted_languages = preg_split('/,/', $http_accept_language);
                 $candidate_language = $this->_getLanguageIsoCode($accepted_languages[0]);
             }
         }
         if (isset($candidate_language) && __I18n::getInstance()->isSupportedLanguage($candidate_language)) {
             $primary_language = $candidate_language;
         } else {
             $primary_language = __I18n::getInstance()->getDefaultLanguageIsoCode();
         }
         $return_value = new __Locale($primary_language);
         $auth_cookie = new __Cookie('__LOCALE__' . $app_name, $primary_language, session_cache_expire() * 60, '/');
         $response = __FrontController::getInstance()->getResponse();
         if ($response != null) {
             $response->addCookie($auth_cookie);
         }
     }
     return $return_value;
 }
Ejemplo n.º 17
0
 public function &getActiveFlowExecution()
 {
     if ($this->_active_flow_execution == null) {
         $request_flow_execution_key = __ApplicationContext::getInstance()->getPropertyContent('REQUEST_FLOW_EXECUTION_KEY');
         $request = __FrontController::getInstance()->getRequest();
         if ($request->hasParameter($request_flow_execution_key)) {
             $flow_execution_key = $request->getParameter($request_flow_execution_key);
             if ($this->hasFlowExecution($flow_execution_key)) {
                 $this->_active_flow_execution = $this->getFlowExecution($flow_execution_key);
             }
         }
     }
     return $this->_active_flow_execution;
 }
Ejemplo n.º 18
0
 public function displayError(Exception $exception)
 {
     if ($exception instanceof __LionException) {
         $error_title = $exception->getErrorTitle();
     } else {
         $error_title = 'Core Error';
     }
     $error_message = $exception->getMessage();
     $error_code = $exception->getCode();
     $message = new __AsyncMessage();
     $message->getHeader()->setStatus(__AsyncMessageHeader::ASYNC_MESSAGE_STATUS_ERROR);
     if (__Lion::getInstance()->getRuntimeDirectives()->getDirective('DEBUG_MODE')) {
         $message->getHeader()->setMessage("{$error_title} ({$error_code}):\n{$error_message}");
     }
     __FrontController::getInstance()->getResponse()->addContent($message->toJson());
     __FrontController::getInstance()->getResponse()->flush();
     exit;
 }
 /**
  * This method is just executed on case the user has not
  * the required permission to execute this controller
  * 
  */
 public function onAccessError()
 {
     //we're going to redirect users without permission
     //to the login page
     __FrontController::getInstance()->redirect('login.action');
 }
Ejemplo n.º 20
0
 /**
  * Starts the Lion engine. 
  * 
  * This method is called automatically by just including the current file.
  *
  */
 public final function startup()
 {
     if ($this->_started == false) {
         $this->_started = true;
         $this->_status = self::STATUS_LOADING;
         $this->_startupLionCore();
         __ContextManager::getInstance()->createApplicationContext();
         $this->_status = self::STATUS_RUNNING;
         if (LION_AUTODISPATCH_CLIENT_REQUEST == true) {
             __FrontController::getInstance()->dispatchClientRequest();
         }
     } else {
         throw __ExceptionFactory::getInstance()->createException('ERR_LION_ENGINE_ALREADY_STARTED');
     }
 }
 /**
  * This method is just executed on case the user has not
  * the required permission to execute this controller
  * 
  */
 public function onAccessError()
 {
     //we're going to redirect users without permission to the login page
     $uri = __UriFactory::getInstance()->createUri()->setController("login");
     __FrontController::getInstance()->forward($uri);
 }
Ejemplo n.º 22
0
 public function &getRequestScope()
 {
     $return_value = __FrontController::getInstance()->getRequest();
     return $return_value;
 }
 protected function _canRefresh()
 {
     $return_value = false;
     //by default
     //only refresh if at least it has been set a controller or action:
     if ($this->_controller != null || $this->_action != null) {
         if ($this->_dirty == true) {
             //if dirty, refresh!
             $return_value = true;
         } else {
             if (__FrontController::getInstance()->getRequestType() != REQUEST_TYPE_XMLHTTP && $this->_autorefresh == true && !$this->_refreshed) {
                 $return_value = true;
             }
         }
     }
     return $return_value;
 }
 /**
  * Dispatch an action. If the action code is not specified, it will be used the default (ACTION_CODE_ON_ACTION_NOT_SPECIFIED).
  * 
  * If the default one does not correspond with any action controller method (remember that the method name is the action code 
  * with the suffix 'Action'), the ACTION_CODE_ON_ACTION_NOT_FOUND will be used instead of.<br>
  * <br>
  * The dispatch method, once has the action controller, performes the following tasks:<br>
  * <p>1. Call to {@link __ActionController::preProcess} method in order to execute a 'pre-logic' before the execution of the action controller logic (i.e. check preconditions, execute another action, ...)<br>
  * <p>2. Call to the action method in order to execute the action logic. The action method should return a {@link __ModelAndView} instance.
  *    In that case, the __ActionDispatcher will resolve a {@link __View} and will execute it (by calling to the {@link __View::execute} method).<br>
  * <p>3. Finally, call to {@link __ActionController::postProcess} method in order to execute a 'post-logic' (i.e. check postconditions, execute another action, ...)<br>
  * <br>
  * The {@link preProcess} and {@link postProcess} methods can be specialized in subclasses in order to define concrete actions and behaviors.<br>
  * 
  *
  * @param string $action_controller The action controller code (aka the module code)
  * @param string $action_code The action to execute.
  * @param __IRequest &$request The request
  * @param __IResponse &$response The response
  * @return mixed The response or the value returned by the controller if it's not a {@link __ModelAndView}
  */
 public function &dispatch(__ActionIdentity $action_identity, __IRequest &$request = null, __IResponse &$response = null)
 {
     $return_value =& $response;
     //by default we'll return the response
     $this->_pushRequest($request);
     $this->_pushResponse($response);
     $this->_pushActionIdentity($action_identity);
     //get the __ActionController class:
     $controller_code = $action_identity->getControllerCode();
     $action_code = $action_identity->getActionCode();
     $action_controller = __ActionControllerResolver::getInstance()->getActionController($controller_code);
     if ($action_controller instanceof __IActionController) {
         $resource_manager = __ApplicationContext::getInstance()->getResourceManager();
         $action_controller_I18n_resources = $resource_manager->loadActionResources($action_identity);
         $front_controller_request = __FrontController::getInstance()->getRequest();
         if ($front_controller_request != null) {
             $valid_request_method = $action_controller->getValidRequestMethod();
             if (($valid_request_method & $front_controller_request->getMethod()) == 0) {
                 throw __ExceptionFactory::getInstance()->createException('ERR_INVALID_REQUEST_METHOD', array($action_identity->getControllerCode()));
             }
         }
         //1. Execute the action's pre-logic:
         $action_controller->preExecute();
         //2. Execute the action logic:
         $controller_result = $action_controller->execute($action_code);
         if ($controller_result instanceof __ModelAndView) {
             $view = $controller_result->getView();
             if ($view == null) {
                 $view_code = $controller_result->getViewCode();
                 if ($view_code == null) {
                     $view_code = $action_code ? $action_code : $controller_code;
                 }
                 $view = __ViewResolver::getInstance()->getView($view_code);
             }
             if ($view instanceof __View) {
                 $model = $controller_result->getModel();
                 //assign the model
                 $view->assign($model->toArray());
                 //assign I18n resources
                 $view->assign($action_controller_I18n_resources);
                 $response = $this->getResponse();
                 $response->appendContent($view->execute());
             }
         } else {
             $return_value =& $controller_result;
         }
         //3. Finally will execute the action's post-logic:
         $action_controller->postExecute();
     }
     $this->_popActionIdentity();
     $this->_popResponse();
     $this->_popRequest();
     return $return_value;
 }
Ejemplo n.º 25
0
 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;
 }
Ejemplo n.º 26
0
 protected function _resolveScopeAttributeValue($attribute, $scope)
 {
     $return_value = null;
     switch ($scope) {
         case __FlowDefinition::SCOPE_FLOW:
             $return_value = $this->getVar($attribute);
             break;
         case __FlowDefinition::SCOPE_REQUEST:
             $request = __FrontController::getInstance()->getRequest();
             if ($request->hasParameter($attribute)) {
                 $return_value = $request->getParameter($attribute);
             }
             break;
         case __FlowDefinition::SCOPE_SESSION:
             $session = __ApplicationContext::getInstance()->getSession();
             if ($session->hasData($attribute)) {
                 $return_value = $session->getData($attribute);
             }
             break;
         default:
             throw __ExceptionFactory::getInstance()->createException('Unknown flow scope ' . $scope);
             break;
     }
     return $return_value;
 }
Ejemplo n.º 27
0
 public function readClientRequest()
 {
     $this->_readGlobalRequestParameters();
     $request_url = $this->_getRequestUrl();
     if ($request_url != null) {
         $uri = __UriFactory::getInstance()->createUri($request_url);
         $this->setUri($uri);
         if ($uri instanceof __Uri) {
             $route = $uri->getRoute();
             if ($route != null && $route instanceof __Route) {
                 $route_id_to_redirect_to = $route->getRouteIdToRedirectTo();
                 //check if need to redirect to any route:
                 if (!empty($route_id_to_redirect_to)) {
                     $uri = __UriFactory::getInstance()->createUri()->setRoute($route_id_to_redirect_to)->setParameters($this->toArray(REQMETHOD_GET));
                     $empty_request = __RequestFactory::getInstance()->createRequest();
                     $redirection_code = $route->getRedirectionCode();
                     __FrontController::getInstance()->redirect($uri, $empty_request, $redirection_code);
                 }
                 //also check if the current route allowes only SSL:
                 if ($route->getOnlySSL() && HTTP_PROTOCOL != 'https') {
                     $empty_request = __RequestFactory::getInstance()->createRequest();
                     $url = "https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
                     __FrontController::getInstance()->redirect($url, $empty_request, 302);
                 }
             }
         }
     }
 }
Ejemplo n.º 28
0
 /**
  * This method adds a new __Locale to the internal collection of locales, and set it as the default locale
  *
  * @param Locale The locale to set
  * @return boolean true if the locale has been setted successfully, else false
  */
 public function setLocale(__Locale &$locale)
 {
     $this->_locale =& $locale;
     if (__Client::getInstance()->getRequestType() == REQUEST_TYPE_HTTP) {
         $app_name = md5(__ApplicationContext::getInstance()->getPropertyContent('APP_NAME'));
         $auth_cookie = new __Cookie('__LOCALE__' . $app_name, $locale->getCode(), session_cache_expire() * 60, '/');
         $response = __FrontController::getInstance()->getResponse();
         $response->addCookie($auth_cookie);
     }
 }