public function getLanguageFile($language_iso_code, __ActionIdentity $action_identity = null) { if ($action_identity != null) { $filename = $action_identity->getControllerCode() . '.ini'; } else { $filename = $this->_filename; } $return_value = $this->_language_dir . DIRECTORY_SEPARATOR . $language_iso_code . DIRECTORY_SEPARATOR . $filename; return $return_value; }
public function setActionIdentity(__ActionIdentity $action_identity) { //if the controller code is dynamic, meaning that it's a variable: if ($this->_controller_code_variable != null) { $this->setControllerCode($action_identity->getControllerCode()); } //if the action code is dynamic, meaning that it's a variable: if ($this->_action_code_variable != null) { $this->setActionCode($action_identity->getActionCode()); } }
protected function &_createRoute(__ConfigurationSection &$section) { $route = new __Route(); $route->setId($section->getAttribute('id')); if ($section->hasAttribute('supercache')) { $route->setSuperCache(__ConfigurationValueResolver::toBool($section->getAttribute('supercache'))); } else { if ($section->hasAttribute('cache')) { $route->setCache(__ConfigurationValueResolver::toBool($section->getAttribute('cache'))); } } if ($section->hasAttribute('order')) { $route->setOrder($section->getAttribute('order')); } if ($section->hasAttribute('if-parameter')) { $route->setIfParameter($section->getAttribute('if-parameter')); } if ($section->hasAttribute('cache-ttl')) { $cache_ttl = $section->getAttribute('cache-ttl'); if (is_numeric($cache_ttl)) { $cache_ttl = (int) $cache_ttl; } $route->setCacheTtl($cache_ttl); } if ($section->hasAttribute('only-ssl')) { $only_ssl = __ConfigurationValueResolver::toBool($section->getAttribute('only-ssl')); $route->setOnlySSL($only_ssl); } if ($section->hasAttribute('redirect-to')) { $route_to_redirect_to = $section->getAttribute('redirect-to'); if ($section->hasAttribute('redirection-code')) { $redirection_code = $section->getAttribute('redirection-code'); } else { $redirection_code = 302; } $route->setRouteToRedirectTo($route_to_redirect_to, $redirection_code); } $url_regular_expression = $section->getAttribute('uri-pattern'); $route->setUrlPattern($url_regular_expression); $var_patterns = array(); preg_match_all('/\\$[_A-Za-z][_A-Za-z0-9]*/', $url_regular_expression, $var_order); foreach ($var_order[0] as $varpattern_name) { $varpattern_section = $section->getSection('variable', null, array('name' => $varpattern_name)); if ($varpattern_section != null) { $varpattern = $varpattern_section->getAttribute('var-pattern'); $var_patterns[$varpattern_name] = $varpattern; } } $route->setVariablePatterns($var_patterns); $sub_sections = $section->getSections(); foreach ($sub_sections as &$sub_section) { switch ($sub_section->getName()) { case 'parameter': $route->addFixedParameter($sub_section->getAttribute('name'), $sub_section->getAttribute('value')); break; case 'if-isset': $variable = $sub_section->getAttribute('variable'); $parameter_sections = $sub_section->getSections(); $parameters = array(); foreach ($parameter_sections as $parameter_section) { $parameters[$parameter_section->getAttribute('name')] = $parameter_section->getAttribute('value'); } $route->addIfIssetCondition($variable, $parameters); break; case 'if-equals': $variable = $sub_section->getAttribute('variable'); $value = $sub_section->getAttribute('value'); $parameter_sections = $sub_section->getSections(); $parameters = array(); foreach ($parameter_sections as $parameter_section) { $parameters[$parameter_section->getAttribute('name')] = $parameter_section->getAttribute('value'); } $route->addIfEqualsCondition($variable, $value, $parameters); break; case 'front-controller': $route->setFrontControllerClass($sub_section->getAttribute('class')); break; case 'flow': $route->setFlowId($sub_section->getAttribute('id')); break; case 'action': $action_identity = new __ActionIdentity(); if ($sub_section->hasAttribute('controller')) { $action_identity->setControllerCode($sub_section->getAttribute('controller')); } if ($sub_section->hasAttribute('code')) { $action_identity->setActionCode($sub_section->getAttribute('code')); } else { if ($sub_section->hasAttribute('action')) { $action_identity->setActionCode($sub_section->getAttribute('action')); } } $route->setActionIdentity($action_identity); break; } } //resolves route components before caching to avoid repeating this calculation on each request $route->resolveRouteComponents(); return $route; }
/** * Enter description here... * * @return __ActionIdentity */ public function getActionIdentity() { $return_value = new __ActionIdentity(); if ($this->hasParameter(__ApplicationContext::getInstance()->getPropertyContent('REQUEST_CONTROLLER_CODE'))) { $return_value->setControllerCode($this->getParameter(__ApplicationContext::getInstance()->getPropertyContent('REQUEST_CONTROLLER_CODE'))); } if ($this->hasParameter(__ApplicationContext::getInstance()->getPropertyContent('REQUEST_ACTION_CODE'))) { $return_value->setActionCode($this->getParameter(__ApplicationContext::getInstance()->getPropertyContent('REQUEST_ACTION_CODE'))); } return $return_value; }
public function getActionIdentity() { $return_value = null; $request_flow_execution_key = __ApplicationContext::getInstance()->getPropertyContent('REQUEST_FLOW_EXECUTION_KEY'); if ($this->hasParameter($request_flow_execution_key)) { $return_value = new __ActionIdentity(); $return_value->setController('flowController'); $return_value->setAction('default'); } else { $flow_id = $this->getFlowId(); if ($flow_id != null) { $return_value = new __ActionIdentity(); $return_value->setController('flowController'); $return_value->setAction('startFlow'); } } if ($return_value == null) { $return_value = parent::getActionIdentity(); } return $return_value; }
protected function _parseActionNode(__ConfigurationSection &$flow_section) { $return_value = null; if ($flow_section->hasAttribute('controller')) { $return_value = new __ActionIdentity(); $return_value->setControllerCode($flow_section->getAttribute('controller')); if ($flow_section->hasAttribute('action')) { $return_value->setActionCode($flow_section->getAttribute('action')); } } return $return_value; }
public function loadActionResources(__ActionIdentity $action_identity, $language_iso_code = null) { if ($language_iso_code == null) { $language_iso_code = __I18n::getInstance()->getLocale()->getLanguageIsoCode(); } $controller_code = $action_identity->getControllerCode(); $cache = __ApplicationContext::getInstance()->getCache(); $action_resources_key = '__ActionResources__' . $language_iso_code . '__' . $controller_code; $action_resources = $cache->getData($action_resources_key); if ($action_resources == null) { $action_resources = array(); $action_controller_definition = __ActionControllerResolver::getInstance()->getActionControllerDefinition($controller_code); $I18n_resource_groups = $action_controller_definition->getI18nResourceGroups(); if (count($I18n_resource_groups) == 0) { $I18n_resource_groups[] = $controller_code; } foreach ($I18n_resource_groups as $I18n_resource_group) { $resources_group_to_load = new __ActionIdentity($I18n_resource_group); foreach ($this->_resource_providers[PERSISTENCE_LEVEL_ACTION] as &$resource_provider) { $action_resources = $resource_provider->loadResources($language_iso_code, $resources_group_to_load) + $action_resources; } } $cache->setData($action_resources_key, $action_resources); } if (!key_exists($controller_code, $this->_loaded_action_codes)) { $this->_resource_table->addActionResources($action_resources, $action_identity, $language_iso_code); $this->_loaded_action_codes[$controller_code] = true; } return $action_resources; }