/** * Updates client end-point with values received from request: * * @param __IRequest $request * @param __IResponse $response */ public function preFilter(__IRequest &$request, __IResponse &$response) { //update client end-points with values received from request: $request_component_values = __ContextManager::getInstance()->getApplicationContext()->getPropertyContent('REQUEST_CLIENT_ENDPOINT_VALUES'); if ($request->hasParameter($request_component_values)) { $values = $request->getParameter($request_component_values); if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) { $scape_chars = array('\\n', '\\r', '\\t'); $double_scape_chars = array('\\\\n', '\\\\r', '\\\\t'); $values = str_replace($scape_chars, $double_scape_chars, $values); $values = stripslashes($values); } $client_values = json_decode($values, true); if (is_array($client_values)) { $ui_binding_manager = __UIBindingManager::getInstance(); foreach ($client_values as $id => $value) { if ($ui_binding_manager->hasUIBinding($id)) { $ui_binding_manager->getUIBinding($id)->getClientEndPoint()->setValue($value); } else { if ($request->hasParameter('viewCode')) { $view_code = $request->getParameter('viewCode'); __ComponentLazyLoader::loadView($view_code); if ($ui_binding_manager->hasUIBinding($id)) { $ui_binding_manager->getUIBinding($id)->getClientEndPoint()->setValue($value); } else { throw __ExceptionFactory::getInstance()->createException('Can not sync component status between client and server'); } } } } } } }
/** * Returns the singleton instance of __ContextManager class * * @return __ContextManager The singleton instance of __ContextManager class */ public static function &getInstance() { if (self::$_instance == null) { self::$_instance = new __ContextManager(); } return self::$_instance; }
private function __construct() { $view_definitions = __ContextManager::getInstance()->getCurrentContext()->getConfiguration()->getSection('configuration')->getSection('view-definitions'); if (is_array($view_definitions)) { $this->_view_definitions =& $view_definitions; } }
private function __construct() { $component_tags = __ContextManager::getInstance()->getCurrentContext()->getConfiguration()->getSection('configuration')->getSection('ui-component-tags'); if (is_array($component_tags)) { $this->_component_tags = $component_tags; } }
/** * Switch the context to lion admin application, just in case the REQUEST_LION_ADMIN_AREA parameter is present within the request * * @param __IRequest $request * @param __IResponse $response */ public function preFilter(__IRequest &$request, __IResponse &$response) { $admin_area_parameter = __ApplicationContext::getInstance()->getPropertyContent('REQUEST_LION_ADMIN_AREA'); if ($request->hasParameter($admin_area_parameter) && __ApplicationContext::getInstance()->getPropertyContent('LION_ADMIN_ENABLED') == true) { __ContextManager::getInstance()->createContext("LION_ADMIN_AREA", ADMIN_DIR); __ContextManager::getInstance()->switchContext("LION_ADMIN_AREA"); } }
/** * Protected getter for singleton instances * * @param string $instance_id The instance id to retrieve the instance from current {@link __Context} instance * @return object The requested instance */ protected static function &getSingleton($instance_id) { $return_value = null; if (__ContextManager::getInstance()->getCurrentContext()->hasInstance($instance_id)) { $return_value = __ContextManager::getInstance()->getCurrentContext()->getInstance($instance_id); } return $return_value; }
public function setControllerCode($controller_code) { if ($this->_controller_code_variable != null) { $this->_url_pattern->setVariableValue($this->_controller_code_variable, $controller_code); } else { $request_controller_code = __ContextManager::getInstance()->getApplicationContext()->getPropertyContent('REQUEST_CONTROLLER_CODE'); $this->addParameter($request_controller_code, $controller_code); } }
/** * Constructor method */ private function __construct() { $configuration = __ContextManager::getInstance()->getCurrentContext()->getConfiguration(); if ($configuration != null) { $configuration_section = __ContextManager::getInstance()->getCurrentContext()->getConfiguration()->getSection('configuration'); if ($configuration_section != null) { $this->_error_table = $configuration_section->getSection('errors'); } } }
public function &loadAnonymousUser() { $return_value = new __User(); //If there is not need to authenticate the user, will set the admin role: if (__ContextManager::getInstance()->getContext('LION_ADMIN_AREA')->getPropertyContent('LION_ADMIN_AUTH_REQUIRED') == false) { $admin_role = __RoleManager::getInstance()->getRole('ADMIN'); $return_value->addRole($admin_role); } $return_value->setCredentials(new __AnonymousCredentials()); return $return_value; }
public function startup() { $cache = __CurrentContext::getInstance()->getCache(); $this->_permissions = $cache->getData('__PermissionManager::_permissions'); if ($this->_permissions == null) { $permissions = __ContextManager::getInstance()->getCurrentContext()->getConfiguration()->getSection('configuration')->getSection('permission-definitions'); if (is_array($permissions)) { $this->_permissions =& $permissions; } $cache->setData('__PermissionManager::_permissions', $this->_permissions); } }
public function &doProcess(__ConfigurationSection &$section) { $languages = array(__ContextManager::getInstance()->getCurrentContext()->getPropertyContent('DEFAULT_LANG_ISO_CODE') => true); $subsections = $section->getSections(); foreach ($subsections as &$subsection) { if (strtoupper($subsection->getName()) == 'LANGUAGE') { $languages[$subsection->getProperty('#text')->getContent()] = true; } } $return_value = array_keys($languages); return $return_value; }
public function startup() { $cache = __CurrentContext::getInstance()->getCache(); $this->_roles = $cache->getData('__RoleManager::_roles'); if ($this->_roles == null) { $roles = __ContextManager::getInstance()->getCurrentContext()->getConfiguration()->getSection('configuration')->getSection('role-definitions'); if (is_array($roles)) { $this->_roles =& $roles; } $cache->setData('__RoleManager::_roles', $this->_roles); } }
public function headerAction() { $application_in_edition = __ResourceManager::getInstance()->getResource('APPLICATION_IN_EDITION')->setParameters(array('app_name' => __ContextManager::getInstance()->getApplicationContext()->getPropertyContent('APP_NAME'))); $model_and_view = new __ModelAndView('header'); $model_and_view->application_in_edition = $application_in_edition; if (__ApplicationContext::getInstance()->getPropertyContent('LION_ADMIN_AUTH_REQUIRED') == true) { $model_and_view->logout_access = true; } else { $model_and_view->logout_access = false; } return $model_and_view; }
/** * Loads the associated context's configuration * * @return __Configuration The {@link __Configuration} instance as a result of reading the context configuration file */ public function &loadConfiguration($context_configuration_file = null) { $return_value = null; $cache = __ApplicationContext::getInstance()->getCache(); $configuration_info = $cache->getData('configuration_' . $this->_context_id); if (is_array($configuration_info)) { $return_value = $configuration_info['configuration']; //by default //It's important to note that configuration changes are detected on DEBUG_MODE enabled: if (__Lion::getInstance()->getRuntimeDirectives()->getDirective('DEBUG_MODE')) { $configuration_files = $configuration_info['configuration_files']; $configuration_locators = $configuration_info['configuration_locators']; if ($this->_configurationHasChanged($configuration_files, $configuration_locators)) { //clear the session + the cache: __ContextManager::getInstance()->getContext($this->_context_id)->getSession()->clear(); __ContextManager::getInstance()->getContext($this->_context_id)->getCache()->clear(); $return_value = null; } } } if ($return_value == null) { //read the configuration: $this->_configuration_files_mtimes = array(); $this->_configuration_locators = array(); if ($context_configuration_file == null) { $context_configuration_file = __ContextManager::getInstance()->getContext($this->_context_id)->getBaseDir() . DIRECTORY_SEPARATOR . 'config.xml'; } if (is_readable($context_configuration_file) && is_file($context_configuration_file)) { $return_value = $this->loadConfigurationFile($context_configuration_file); //$return_value = $this->_parseIncludes($return_value, dirname($context_configuration_file)); } else { $return_value = $this->createConfiguration(); } $return_value->merge($this->_loadDefaultContextConfiguration()); //save the new configuration into the cache: $configuration_info = array(); $configuration_info['configuration'] = $return_value; $configuration_info['configuration_files'] = $this->_configuration_files_mtimes; $configuration_info['configuration_locators'] = $this->_configuration_locators; $cache->setData('configuration_' . $this->_context_id, $configuration_info); } else { $configuration_directives = $return_value->getSection('configuration')->getSection('configuration-directives'); if ($configuration_directives != null) { $this->_readConfigurationDirectives($configuration_directives); } } 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; }
private function _parseValue($value) { $return_value = trim($value); if (strpos($return_value, 'const:') === 0) { $constant_name = trim(substr($return_value, 6)); if (defined($constant_name)) { $return_value = constant($constant_name); } else { $return_value = $constant_name; } } if (strpos($return_value, 'prop:') === 0) { $property_name = trim(substr($return_value, 5)); $return_value = __ContextManager::getInstance()->getCurrentContext()->getPropertyContent($property_name); if ($return_value == null) { $return_value = $property_name; } } return $return_value; }
/** * 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'); } }
/** * Return a reference to the current active {@link __Context} instance * * @return __Context The current active {@link __Context} instance */ public static function &getInstance() { return __ContextManager::getInstance()->getCurrentContext(); }
/** * Returns the submit code (if it has been specified as a parameter) associated to * the current request * * @todo remove this method * * @return string The submit code */ public function getSubmitCode() { return $this->getParameter(__ContextManager::getInstance()->getApplicationContext()->getPropertyContent('REQUEST_SUBMIT_CODE')); }
/** * This method loads all the session level resources for an specific language. * Note that action specific resources are loaded dinamically by each resource dictionary * * @param string The language iso code to load resources from */ private function loadResources($language_iso_code = null) { $context = __ContextManager::getInstance()->getContext($this->_context_id); if ($language_iso_code == null) { $language_iso_code = __I18n::getInstance()->getLocale()->getLanguageIsoCode(); } if ($this->_resource_table->hasLanguage($language_iso_code) == false) { //Now will iterate throught the Resources, appending all in the return array foreach ($this->_resource_providers[PERSISTENCE_LEVEL_SESSION] as &$resource_provider) { $this->_resource_table->addResources($resource_provider->loadResources($language_iso_code), $language_iso_code); } } }
/** * This method returns the __Context instance that contains the current __Configuration. * * @return __Context */ public function &getContext() { $return_value = __ContextManager::getInstance()->getContext($this->_context_id); return $return_value; }
/** * 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'); } }
public function &getContext() { return __ContextManager::getInstance()->getContext($this->_context_id); }
protected function _calculateUriComponents() { $route = __RouteManager::getInstance()->getValidRouteForUrl($this->_relative_url); if ($route == null) { throw new Exception('Route not found matching url: ' . $this->_relative_url); } $this->setRouteId($route->getId()); $this->setFlowId($route->getFlowId()); $url_variable_values = array(); $variables_matched = array(); if (preg_match('/' . $route->getUrlRegularExpression() . '/', $this->_relative_url, $variables_matched)) { $variables_order = $route->getVariablesOrder(); $total_variables_matched = count($variables_matched); for ($i = 1; $i < $total_variables_matched; $i++) { $url_variable_values[$variables_order[$i - 1]] = $variables_matched[$i]; } //Now will instantiate a valid front controller for the current request: $front_controller_class = $route->getFrontControllerClass(); if ($front_controller_class != null) { if (key_exists($front_controller_class, $url_variable_values)) { $this->setFrontControllerClass($url_variable_values[$front_controller_class]); } else { $this->setFrontControllerClass($front_controller_class); } } $request_parameters = $route->getParameters($url_variable_values); $action_identity = $route->getActionIdentity(); if ($action_identity != null) { $request_action_code = __ContextManager::getInstance()->getApplicationContext()->getPropertyContent('REQUEST_ACTION_CODE'); if (!in_array($action_identity->getActionCode(), $variables_order)) { $this->setActionCode($action_identity->getActionCode()); $request_parameters[$request_action_code] = $action_identity->getActionCode(); } else { if (key_exists($action_identity->getActionCode(), $url_variable_values)) { $this->setActionCode($url_variable_values[$action_identity->getActionCode()]); $request_parameters[$request_action_code] = $url_variable_values[$action_identity->getActionCode()]; } } $request_controller_code = __ContextManager::getInstance()->getApplicationContext()->getPropertyContent('REQUEST_CONTROLLER_CODE'); if (!in_array($action_identity->getControllerCode(), $variables_order)) { $this->setControllerCode($action_identity->getControllerCode()); $request_parameters[$request_controller_code] = $action_identity->getControllerCode(); } else { if (key_exists($action_identity->getControllerCode(), $url_variable_values)) { $this->setControllerCode($url_variable_values[$action_identity->getControllerCode()]); $request_parameters[$request_controller_code] = $url_variable_values[$action_identity->getControllerCode()]; } } } $this->setParameters($request_parameters); } }
/** * Return a reference to the application {@link __Context} instance * * @return __Context The application {@link __Context} instance */ public static function &getInstance() { return __ContextManager::getInstance()->getApplicationContext(); }
public function __construct() { $this->_resource_class = __ContextManager::getInstance()->getCurrentContext()->getPropertyContent('DEFAULT_RESOURCE_CLASS'); $this->_highlight_resources = __ApplicationContext::getInstance()->getPropertyContent('HIGHLIGHT_I18N_RESOURCES'); }