public function defaultAction() { $return_value = null; $request = __FrontController::getInstance()->getRequest(); $application_context = __ApplicationContext::getInstance(); $request_flow_execution_key = $application_context->getPropertyContent('REQUEST_FLOW_EXECUTION_KEY'); if ($request->hasParameter($request_flow_execution_key)) { $flow_execution_key = $request->getParameter($request_flow_execution_key); $request_flow_event_id = $application_context->getPropertyContent('REQUEST_FLOW_EVENT_ID'); $request_flow_state_id = $application_context->getPropertyContent('REQUEST_FLOW_STATE_ID'); $flow_executor = __FlowExecutor::getInstance(); //sync with the current state sent from client: if ($request->hasParameter($request_flow_state_id)) { $flow_execution = $flow_executor->getActiveFlowExecution(); if ($flow_execution != null) { $flow_state_id = $request->getParameter($request_flow_state_id); if ($flow_execution->isStateVisited($flow_state_id)) { $current_state = $flow_execution->getCurrentState(); if ($current_state != null && $current_state->getId() != $flow_state_id) { $state = $flow_execution->goToState($flow_state_id); if ($state != null && !$request->hasParameter($request_flow_event_id)) { $application_context = __ApplicationContext::getInstance(); $request_flow_execution_key = $application_context->getPropertyContent('REQUEST_FLOW_EXECUTION_KEY'); $flow_execution_key = $request->getParameter($request_flow_execution_key); $this->_executeControllerAssociatedToState($state, $flow_executor, $flow_execution_key); } } } else { throw __ExceptionFactory::getInstance()->createException('Flow state not yet visited: ' . $flow_state_id); } } } //checks flow event: if ($request->hasParameter($request_flow_event_id)) { $flow_event_id = $request->getParameter($request_flow_event_id); $state = $flow_executor->resume($flow_execution_key, $flow_event_id); if ($state != null) { $this->_executeControllerAssociatedToState($state, $flow_executor, $flow_execution_key); } } else { if ($flow_executor->hasFlowExecution($flow_execution_key)) { $return_value = $flow_executor->getResponse($flow_execution_key); $return_value->setBufferControl(true); //let also the browser cache the page $return_value->addHeader('Cache-Control: private, max-age=10800, pre-check=10800'); $return_value->addHeader('Pragma: private'); $return_value->addHeader("Expires: " . date(DATE_RFC822, strtotime("+2 day"))); } else { //start a new flow and redirect the user to the very first step: $this->startFlowAction(); } } } return $return_value; }
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 &getFlowScope() { return __FlowExecutor::getInstance()->getActiveFlowExecution(); }