protected function _saveAnnotations()
 {
     if (__Lion::getInstance()->getRuntimeDirectives()->getDirective('DEBUG_MODE') == false) {
         $cache = __ApplicationContext::getInstance()->getCache();
         $cache->setData('annotations', $this->_annotations);
     }
 }
 private function _printLionInfo()
 {
     echo 'Lion framework ' . LION_VERSION_NUMBER . ' (built: ' . LION_VERSION_BUILD_DATE . ")\n";
     echo "\n";
     echo "Runtime Directives\n";
     echo "------------------\n";
     $lion_directives = __Lion::getInstance()->getRuntimeDirectives()->getDirectives();
     $runtime_directives_values = array();
     foreach ($lion_directives as $key => $value) {
         if (is_bool($value)) {
             if ($value) {
                 $value = 'true';
             } else {
                 $value = 'false';
             }
         }
         echo "{$key}: {$value}\n";
     }
     echo "\nApplication Settings\n";
     echo "--------------------\n";
     $configuration = __ApplicationContext::getInstance()->getConfiguration();
     $settings = $configuration->getSettings();
     $setting_values = array();
     foreach ($settings as $key => $setting) {
         $value = $configuration->getPropertyContent($key);
         if (is_bool($value)) {
             if ($value) {
                 $value = 'true';
             } else {
                 $value = 'false';
             }
         }
         echo "{$key}: {$value}\n";
     }
 }
 /**
  * Resolves an url depending on the specified base. 
  * If no base is specified, the APP_URL_PATH will be used as base.
  * 
  * Note: Absolute url won't be altered.
  * The same if applicable to an url starting with the '/' character if no base is specified.
  * 
  * i.e.
  * <code>
  * echo __UrlHelper::resolveUrl('path/to/foo.php', 'base/url/');
  * --> /base/url/path/to/foo.php
  * 
  * echo __UrlHelper::resolveUrl('path/to/foo.php', 'http://domain.com/');
  * --> http://domain.com/path/to/foo.php
  * 
  * echo __UrlHelper::resolveUrl('path/to/foo.php');
  * --> /base/url/path/to/foo.php (being APP_URL_PATH = "/base/url/")
  * 
  * echo __UrlHelper::resolveUrl('/path/to/foo.php');
  * --> /path/to/foo.php
  * </code>
  * 
  * @param string $url The url to resolve to
  * @param string $base A base path to apply to
  * @return string The resultant url
  */
 public static function resolveUrl($url, $base = null)
 {
     if (preg_match('/^\\w+\\:\\/\\//', $url)) {
         return $url;
     } else {
         if (!empty($base)) {
             $return_value = self::glueUrlParts($base, $url);
             if (!preg_match('/^\\w+\\:\\/\\//', $return_value)) {
                 $return_value = '/' . $return_value;
             }
         } else {
             if (substr($url, 0, 1) != '/') {
                 if (defined("APP_URL_PATH")) {
                     $url_path = APP_URL_PATH;
                 } else {
                     $url_path = __ApplicationContext::getInstance()->getPropertyContent('APP_URL_PATH');
                 }
                 $return_value = '/' . self::glueUrlParts($url_path, $url);
             } else {
                 $return_value = $url;
             }
         }
     }
     return $return_value;
 }
 public function defaultAction()
 {
     $model_and_view = new __ModelAndView('logon');
     $request = __Client::getInstance()->getRequest();
     //Check credentials:
     $login = $request->getParameter('login');
     $password = $request->getParameter('password');
     $user_identity = new __UsernameIdentity();
     $user_identity->setUsername($login);
     $credentials = new __PasswordCredentials();
     $credentials->setPassword($password);
     try {
         $result_logon = __AuthenticationManager::getInstance()->logon($user_identity, $credentials);
     } catch (__SecurityException $e) {
         $result_logon = false;
         $error_message = $e->getMessage();
     }
     if ($result_logon == false) {
         //Now will include smarty as ORS template engine:
         if ($error_message == '') {
             $error_message = __ResourceManager::getInstance()->getResource('ERR_LOGON_ERROR')->getValue();
         }
         $model_and_view->errorMsg = $error_message;
     } else {
         if ($request->getParameter('destination_page')) {
             $model_and_view->redirectPage = $request->GetParameter('destination_page');
         } else {
             $model_and_view->redirectPage = __UriFactory::getInstance()->createUri()->setActionCode('index')->addParameter(__ApplicationContext::getInstance()->getPropertyContent('REQUEST_LION_ADMIN_AREA'), 1)->getUrl();
         }
     }
     //Return the view code to use:
     return $model_and_view;
 }
 public function defaultAction()
 {
     $model_and_view = new __ModelAndView('login');
     $welcome_to_lion = __ResourceManager::getInstance()->getResource('WELCOME_TO_LION_LABEL')->setParameters(array(__ApplicationContext::getInstance()->getPropertyContent('APP_NAME')))->getValue();
     $model_and_view->welcome_to_lion = $welcome_to_lion;
     return $model_and_view;
 }
示例#6
0
 public function saveResults()
 {
     __ApplicationContext::getInstance()->getCache()->setData('__SiteMap::pages__', $this->_pages);
     __ApplicationContext::getInstance()->getCache()->setData('__SiteMap::routes__', $this->_routes);
     __ApplicationContext::getInstance()->getCache()->setData('__SiteMap::connection_matrix__', $this->_connection_matrix);
     __ApplicationContext::getInstance()->getCache()->setData('__SiteMap::last_update__', $this->_last_update);
     __ApplicationContext::getInstance()->getCache()->setData('__SiteMap::external_links__', $this->_external_links);
 }
 /**
  * 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");
     }
 }
 public function clearAction()
 {
     __ApplicationContext::getInstance()->getSession()->destroy();
     __ModelProxy::getInstance()->clearCache();
     $mav = new __ModelAndView('confirmation');
     $mav->title = 'Cache cleared!';
     return $mav;
 }
 public function addJsFileRef($js_file, $use_local_js_lib = true)
 {
     if ($use_local_js_lib == true) {
         $local_js_lib = __ApplicationContext::getInstance()->getPropertyContent('JS_LIB_DIR');
         $js_file = __UrlHelper::resolveUrl(__UrlHelper::glueUrlParts($local_js_lib, $js_file));
     } else {
         $js_file = __UrlHelper::resolveUrl($js_file);
     }
     $this->_js_files[] = '"' . $js_file . '"';
 }
 public function &process(__ConfigurationSection &$section)
 {
     $cache = __ApplicationContext::getInstance()->getCache();
     $return_value = $cache->getData($this->_id);
     if ($return_value == null) {
         $return_value = $this->doProcess($section);
         $cache->setData($this->_id, $return_value);
     }
     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()));
     }
 }
 private function __construct()
 {
     $session = __ApplicationContext::getInstance()->getSession();
     $session_flows = '__WebFlowManager::' . __CurrentContext::getInstance()->getContextId() . '::_flows';
     if ($session->hasData($session_flows)) {
         $this->_flow_definitions = $session->getData($session_flows);
     } else {
         $this->_flow_definitions = __CurrentContext::getInstance()->getConfiguration()->getSection('configuration')->getSection('webflow');
         $session->setData($session_flows, $this->_flow_definitions);
     }
 }
 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;
 }
 /**
  * This method returns a concrete resource identified by an id.
  *
  * @param string $resource_id The id of the resource to load to
  * @param string $language_iso_code The language that you want to retrieve the resource from. If omitted, the current one will be taken from the execution
  * @return __ResourceBase The requested resource
  */
 public function getResource($resource_id, $language_iso_code)
 {
     $language_iso_code = strtoupper($language_iso_code);
     $return_value = null;
     if (key_exists($language_iso_code, $this->_resources) && key_exists($resource_id, $this->_resources[$language_iso_code])) {
         $return_value = $this->_resources[$language_iso_code][$resource_id];
     } else {
         $default_resource_class = __ApplicationContext::getInstance()->getPropertyContent('DEFAULT_RESOURCE_CLASS');
         $return_value = new $default_resource_class();
         $return_value->setKey($resource_id);
         $return_value->setValue("??[" . $resource_id . "]??");
     }
     return $return_value;
 }
    public function startRender(__IComponent &$component)
    {
        $properties = array();
        $component_id = $component->getId();
        $date_format = $component->getDateFormat();
        $datebox_button_id = $component_id . '_calbutton';
        if (__ResponseWriterManager::getInstance()->hasResponseWriter('datebox')) {
            $jod_response_writer = __ResponseWriterManager::getInstance()->getResponseWriter('datebox');
            $jod_setup_response_writer = $jod_response_writer->getResponseWriter('datebox-setup');
        } else {
            $jod_response_writer = new __JavascriptOnDemandResponseWriter('datebox');
            $jod_response_writer->addCssFileRef('jscalendar/calendar-green.css');
            $jod_response_writer->addJsFileRef('jscalendar/calendar.js');
            $jod_response_writer->addLoadCheckingVariable('Calendar');
            $jod_language_response_writer = new __JavascriptOnDemandResponseWriter('datebox-language');
            $jod_language_response_writer->addJsFileRef('jscalendar/lang/calendar-en.js');
            $jod_language_response_writer->addLoadCheckingVariable('Calendar._DN');
            $jod_response_writer->addResponseWriter($jod_language_response_writer);
            $jod_setup_response_writer = new __JavascriptOnDemandResponseWriter('datebox-setup');
            $jod_setup_response_writer->addJsFileRef('jscalendar/calendar-setup.js');
            $jod_setup_response_writer->addLoadCheckingVariable('Calendar.setup');
            $jod_language_response_writer->addResponseWriter($jod_setup_response_writer);
            $javascript_rw = __ResponseWriterManager::getInstance()->getResponseWriter('javascript');
            $javascript_rw->addResponseWriter($jod_response_writer);
        }
        $js_code = <<<CODESET
Calendar.setup({
\tinputField:"{$component_id}",
\tifFormat:"{$date_format}",
\tbutton:"{$datebox_button_id}",
\tshowsTime:false
});
CODESET;
        $jod_setup_response_writer->addJsCode($js_code);
        $component_properties = $component->getProperties();
        foreach ($component_properties as $property => $value) {
            $properties[] = $property . '="' . $value . '"';
        }
        $properties[] = 'type="text"';
        $properties[] = 'id="' . $component->getId() . '"';
        $properties[] = 'name="' . $component->getName() . '"';
        $properties[] = 'value="' . $component->getValue() . '"';
        if ($component->getVisible() == false) {
            $properties[] = 'style = "display : none;"';
        }
        $local_js_lib = __ApplicationContext::getInstance()->getPropertyContent('JS_LIB_DIR');
        $calendar_image_url = __UrlHelper::resolveUrl('jscalendar/calendar.gif', $local_js_lib);
        $return_value = '<input onchange="this.fire(\'lion:validate\');" ' . implode(' ', $properties) . '>&nbsp;<input type="image" src="' . $calendar_image_url . '"  id="' . $datebox_button_id . '" width="16" height="16" border="0">';
        return $return_value;
    }
 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();
 }
 /**
  * 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;
 }
 private static 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) {
         $return_value = __ApplicationContext::getInstance()->getPropertyContent(trim(substr($return_value, 5)));
     }
     return $return_value;
 }
 public final function execute()
 {
     if ($this->_template_file == null) {
         throw __ExceptionFactory::getInstance()->createException('ERR_TEMPLATE_NOT_DEFINED');
     }
     //Locate the template File
     $template_file = $this->locateTemplateFile($this->_template_file);
     $this->setCompileDir(__PathResolver::resolvePath(__ApplicationContext::getInstance()->getPropertyContent('TEMPLATES_COMPILE_DIR'), __ApplicationContext::getInstance()->getBaseDir()));
     //setup filters:
     //- The component filter is the filter in charge of parse the template for components.
     //  Is just available on __TemplateEngineView classes:
     $component_filter = new __ComponentFilter();
     $this->addFilter($component_filter);
     //render the ui:
     return $this->templatize($template_file);
 }
 public function startup()
 {
     $cache = __CurrentContext::getInstance()->getCache();
     $cache_routes_key = '__RouteManager::' . __CurrentContext::getInstance()->getContextId() . '::_routes';
     $routes = $cache->getData($cache_routes_key);
     if ($routes != null) {
         $this->_routes = $routes;
     } else {
         $routes = __ApplicationContext::getInstance()->getConfiguration()->getSection('configuration')->getSection('routes');
         $filters = __ApplicationContext::getInstance()->getConfiguration()->getSection('configuration')->getSection('filters');
         if (is_array($routes)) {
             uasort($routes, array($this, 'cmp'));
             $this->_routes = $routes;
             if (is_array($filters)) {
                 foreach ($filters as $route_id => $filter_chain) {
                     if ($route_id != '*') {
                         if (key_exists($route_id, $this->_routes)) {
                             $route =& $this->_routes[$route_id];
                             $route->setFilterChain($filter_chain);
                             unset($route);
                         } else {
                             throw __ExceptionFactory::getInstance()->createException('ERR_UNKNOW_ROUTE_ID', array($route_id));
                         }
                     }
                     unset($filter_chain);
                 }
                 if (key_exists('*', $filters)) {
                     $global_filters =& $filters['*'];
                     foreach ($global_filters as &$global_filter) {
                         foreach ($this->_routes as &$route) {
                             if (!$route->hasFilterChain()) {
                                 $filter_chain = new __FilterChain();
                                 $route->setFilterChain($filter_chain);
                                 unset($filter_chain);
                             }
                             $route->getFilterChain()->addFilter($global_filter);
                             unset($route);
                         }
                         unset($global_filter);
                     }
                     unset($global_filters);
                 }
             }
             $cache->setData($cache_routes_key, $this->_routes);
         }
     }
 }
 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);
 }
 private function __construct()
 {
     $session = __ApplicationContext::getInstance()->getSession();
     $this->_requests =& $session->getData('__HistoryManager::_requests');
     if ($this->_requests === null) {
         $this->_requests = array();
         $session->setData('__HistoryManager::_requests', $this->_requests);
     } else {
         if (key_exists('current_request', $this->_requests)) {
             if (key_exists('last_request', $this->_requests)) {
                 $this->_requests['previous_request'] = $this->_requests['last_request'];
                 unset($this->_requests['last_request']);
             }
             $this->_requests['last_request'] =& $this->_requests['current_request'];
             unset($this->_requests['current_request']);
         }
     }
 }
 public function &loadUser(__IUserIdentity $user_identity)
 {
     $return_value = null;
     if ($user_identity instanceof __AnonymousIdentity) {
         return $this->loadAnonymousUser();
     } else {
         if ($user_identity instanceof __UsernameIdentity) {
             $login = $user_identity->getUsername();
             if ($login == __ApplicationContext::getInstance()->getPropertyContent('LION_ADMIN_LOGIN')) {
                 $return_value = new __User();
                 $credentials = new __PasswordCredentials();
                 $credentials->setPassword(__ApplicationContext::getInstance()->getPropertyContent('LION_ADMIN_PASSWORD'));
                 $return_value->setCredentials($credentials);
                 $return_value->addRole(__RoleManager::getInstance()->getRole('admin'));
             }
         }
     }
     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 defaultAction()
 {
     $mav = new __ModelAndView('settings');
     try {
         $mav->lion_version = LION_VERSION_NUMBER;
         $mav->lion_build_date = LION_VERSION_BUILD_DATE;
         $mav->lion_build_changelist = LION_VERSION_CHANGE_LIST;
         $configuration = __ApplicationContext::getInstance()->getConfiguration();
         $settings = $configuration->getSettings();
         $setting_values = array();
         foreach ($settings as $key => $setting) {
             $value = $configuration->getPropertyContent($key);
             if (is_bool($value)) {
                 if ($value) {
                     $value = 'true';
                 } else {
                     $value = 'false';
                 }
             }
             $setting_values[] = array('name' => $key, 'value' => $value);
         }
         $mav->settings = $setting_values;
         $lion_directives = __Lion::getInstance()->getRuntimeDirectives()->getDirectives();
         $runtime_directives_values = array();
         foreach ($lion_directives as $key => $value) {
             if (is_bool($value)) {
                 if ($value) {
                     $value = 'true';
                 } else {
                     $value = 'false';
                 }
             }
             $runtime_directives_values[] = array('name' => $key, 'value' => $value);
         }
         $mav->runtime_directives = $runtime_directives_values;
     } catch (Exception $e) {
         $mav->status = 'ERROR';
     }
     return $mav;
 }
 protected function _setResponseToCache(__IRequest &$request, __IResponse &$response)
 {
     $uri = $request->getUri();
     if ($uri != null) {
         $route = $uri->getRoute();
         if ($route != null) {
             if ($route->getCache()) {
                 //only cache anonymous view:
                 if ($response->isCacheable()) {
                     $response_snapshot = new __ResponseSnapshot($response);
                     $cache = __ApplicationContext::getInstance()->getCache();
                     $cache->setData('responseSnapshot::' . $request->getUniqueCode(), $response_snapshot, $route->getCacheTtl());
                 }
             } else {
                 if ($route->getSuperCache()) {
                     //only cache anonymous view:
                     if ($response->isCacheable()) {
                         $target_url_components = parse_url($uri->getAbsoluteUrl());
                         $path = $target_url_components['path'];
                         $dir = dirname($path);
                         $file = basename($path);
                         $response_content = $response->getContent() . "\n<!-- supercached -->";
                         $cache_ttl = $route->getCacheTtl();
                         $server_dir = $_SERVER['DOCUMENT_ROOT'] . $dir;
                         if (is_dir($server_dir) && is_writable($server_dir)) {
                             $file_handler = fopen($server_dir . DIRECTORY_SEPARATOR . $file, "w+");
                             fputs($file_handler, $response_content);
                             fclose($file_handler);
                         } else {
                             $exception = __ExceptionFactory::getInstance()->createException('Directory not found to supercache: ' . $server_dir);
                             __ErrorHandler::getInstance()->logException($exception);
                         }
                     }
                 }
             }
         }
     }
 }
 public function getActionControllerDefinition($action_controller_code)
 {
     $return_value = null;
     if (!empty($action_controller_code)) {
         $cache = __ApplicationContext::getInstance()->getCache();
         $controller_definition_cache_key = '__ActionControllerDefinitions__' . $action_controller_code;
         $return_value = $cache->getData($controller_definition_cache_key);
         if ($return_value == null) {
             $action_controller_code = strtoupper(trim($action_controller_code));
             if (key_exists($action_controller_code, $this->_controller_definitions['static_rules'])) {
                 $return_value = $this->_controller_definitions['static_rules'][$action_controller_code];
             } else {
                 foreach ($this->_controller_definitions['dynamic_rules'] as &$controller_definition) {
                     if ($controller_definition->isValidForControllerCode($action_controller_code)) {
                         $return_value = $controller_definition;
                     }
                 }
             }
             $cache->setData($controller_definition_cache_key, $return_value);
         }
     }
     return $return_value;
 }
 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;
 }
示例#29
0
<?php

//get the session:
$session = __ApplicationContext::getInstance()->getSession();
//if a data already exists in session
if ($session->hasData('data')) {
    //get data from session
    $data = $session->getData('data');
} else {
    //retrieve data from database:
    $data = eg_retrieve_data_from_database();
    //store data to session once, so next time won't be needed to
    //get it from the database but from the session:
    $session->setData('data', $data);
}
示例#30
0
 /**
  * Gets a singleton DaoManager context instance
  *
  * @return DaoManager
  */
 public static function &getInstance()
 {
     return __ApplicationContext::getInstance()->getContextInstance('daoManager');
 }