public function &createResponse($request_type = null)
 {
     $return_value = null;
     if ($request_type == null) {
         $request_type = __Client::getInstance()->getRequestType();
     }
     switch ($request_type) {
         case REQUEST_TYPE_COMMAND_LINE:
             $response_class = __CurrentContext::getInstance()->getPropertyContent('COMMAND_LINE_RESPONSE_CLASS');
             break;
         case REQUEST_TYPE_XMLHTTP:
             $response_class = __CurrentContext::getInstance()->getPropertyContent('XML_HTTP_RESPONSE_CLASS');
             break;
         default:
             $response_class = __CurrentContext::getInstance()->getPropertyContent('HTTP_RESPONSE_CLASS');
             break;
     }
     if (class_exists($response_class)) {
         $return_value = new $response_class();
     }
     if (!$return_value instanceof __IResponse) {
         __ExceptionFactory::getInstance()->createException('Wrong response class: ' . $response_class . '. The response class must implement the __IResponse');
     }
     return $return_value;
 }
 /**
  * This method receives a path to access to an instance and returns a reference to the instance.
  * 
  * i.e., <emphasis>authenticationManager.authenticatedUser.username</emphasis> will be resolved as:
  * <code>
  * 
  * $authentication_manager = __CurrentContext::getInstance()
  *                           ->getInstance('authenticationManager');
  * 
  * $authenticated_user = $authentication_manager
  *                           ->getAuthenticatedUser();
  * 
  * $username = $authenticated_user->getUsername();
  * 
  * </code>
  *
  * @param unknown_type $instance_dir
  * @return unknown
  */
 public function &resolveInstance($instance_dir)
 {
     if (strpos($instance_dir, '.') !== false) {
         $root_instance_name = trim(substr($instance_dir, 0, strpos($instance_dir, '.')));
         if (!__CurrentContext::getInstance()->hasInstance($root_instance_name)) {
             throw __ExceptionFactory::getInstance()->createException('ERR_INSTANCE_ID_NOT_FOUND', array($root_instance_name));
         }
         $current_instance = __CurrentContext::getInstance()->getContextInstance($root_instance);
         $instance_dir = trim(substr($instance_dir, strpos($instance_dir, '.') + 1));
         while (strpos($instance_dir, '.') !== false) {
             $property_name = trim(substr($instance_dir, 0, strpos($instance_dir, '.')));
             $getter_method = 'get' . ucfirst($property_name);
             if (method_exists($current_instance, $getter_method)) {
                 $current_instance = $current_instance->{$getter_method}();
             } else {
                 throw __ExceptionFactory::getInstance()->createException('ERR_GETTER_NOT_FOUND_FOR_PROPERTY', array(get_class($current_instance), $property_name));
             }
         }
     } else {
         $root_instance_name = trim($instance_dir);
         if (!__CurrentContext::getInstance()->hasInstance($current_instance_name)) {
             throw __ExceptionFactory::getInstance()->createException('ERR_INSTANCE_NOT_FOUND', array($root_instance_name));
         }
         $current_instance = __CurrentContext::getInstance()->getInstance($root_instance_name);
     }
     return $current_instance;
 }
 public function __construct($context_id = null)
 {
     if ($context_id == null) {
         $context_id = __CurrentContext::getInstance()->getContextId();
     }
     $this->_context_id = $context_id;
     parent::__construct();
 }
 public function __construct(&$raiser_object, $event_type, $context_id = null)
 {
     parent::__construct($raiser_object, $event_type);
     if ($context_id == null) {
         $context_id = __CurrentContext::getInstance()->getContextId();
     }
     $this->_context_id = $context_id;
 }
 public function __construct($event_type, __Callback &$callback, $context_id = null)
 {
     parent::__construct($event_type, $callback);
     if ($context_id == null) {
         $context_id = __CurrentContext::getInstance()->getContextId();
     }
     $this->_context_id = $context_id;
 }
 private function __construct()
 {
     $session = __CurrentContext::getInstance()->getSession();
     if ($session->hasData('__UIBindingManager::_ui_bindings')) {
         $this->_ui_bindings =& $session->getData('__UIBindingManager::_ui_bindings');
     } else {
         $session->setData('__UIBindingManager::_ui_bindings', $this->_ui_bindings);
     }
 }
 private function __construct()
 {
     $session = __CurrentContext::getInstance()->getSession();
     if ($session->hasData('__ServerBindingChannel::_binding_codes')) {
         $this->_binding_codes =& $session->getData('__ServerBindingChannel::_binding_codes');
     } else {
         $session->setData('__ServerBindingChannel::_binding_codes', $this->_binding_codes);
     }
 }
 private function __construct()
 {
     $session = __CurrentContext::getInstance()->getSession();
     if ($session->hasData('__ComponentPool::_components')) {
         $this->_components =& $session->getData('__ComponentPool::_components');
     } else {
         $session->setData('__ComponentPool::_components', $this->_components);
     }
 }
 private function __construct()
 {
     $session = __CurrentContext::getInstance()->getSession();
     if ($session->hasData('__ComponentHandlerManager::_component_handlers')) {
         $this->_component_handlers =& $session->getData('__ComponentHandlerManager::_component_handlers');
     } else {
         $session->setData('__ComponentHandlerManager::_component_handlers', $this->_component_handlers);
     }
 }
Example #10
0
 protected function _reset()
 {
     $this->_action_identity = new __ActionIdentity();
     $this->_protocol = HTTP_PROTOCOL;
     $this->_route_id = __CurrentContext::getInstance()->getPropertyContent('DEFAULT_ROUTE');
     $this->_parameters = array();
     $this->_relative_url = null;
     $this->_dirty = false;
     $this->_front_controller_class = __ContextManager::getInstance()->getCurrentContext()->getConfiguration()->getPropertyContent('HTTP_FRONT_CONTROLLER_CLASS');
 }
 public function getFrontControllerClass()
 {
     $return_value = null;
     if ($this->_uri != null) {
         $return_value = $this->_uri->getFrontControllerClass();
     }
     if ($return_value == null) {
         $return_value = __CurrentContext::getInstance()->getPropertyContent('HTTP_FRONT_CONTROLLER_CLASS');
     }
     return $return_value;
 }
 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);
     }
 }
Example #13
0
 protected function _loadSupportedLanguages()
 {
     $context = __CurrentContext::getInstance();
     $this->_default_language_iso_code = $context->getPropertyContent('DEFAULT_LANG_ISO_CODE');
     $supported_languages = $context->getConfiguration()->getSection('configuration')->getSection('supported-languages');
     if (is_array($supported_languages)) {
         $this->_supported_languages =& $supported_languages;
     } else {
         $this->_supported_languages = array($this->_default_language_iso_code);
     }
 }
 private function __construct()
 {
     $session = __CurrentContext::getInstance()->getSession();
     if ($session->hasData('__EventHandlerManager::_event_handlers')) {
         //do not remove the '&'. For any unknown reason, without the & the event handlers are not assigned by reference
         $this->_event_handlers =& $session->getData('__EventHandlerManager::_event_handlers');
     } else {
         $this->_event_handlers = array();
         $session->setData('__EventHandlerManager::_event_handlers', $this->_event_handlers);
     }
 }
 /**
  * This is the constructor method of the __ModelProxy.
  * First time a __ModelProxy instance is created, it loads the model's service xml specification (lazy load)
  *
  */
 public function __construct()
 {
     $cache = __CurrentContext::getInstance()->getCache();
     $model_service_definitions = $cache->getData('__ModelProxy::_model_service_definitions');
     if ($model_service_definitions == null) {
         $model_service_definitions = __CurrentContext::getInstance()->getConfiguration()->getSection('configuration')->getSection('model-services');
         $cache->setData('__ModelProxy::_model_service_definitions', $model_service_definitions);
     }
     if ($model_service_definitions != null) {
         $this->_model_service_definitions =& $model_service_definitions;
     }
 }
 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 __construct($context_id = null)
 {
     if ($context_id == null) {
         $this->_context_id = __CurrentContext::getInstance()->getContextId();
     } else {
         if (__ContextManager::getInstance()->hasContext($context_id)) {
             $this->_context_id = $context_id;
         } else {
             throw new __ConfigurationException('Context not found for specified identifier: ' . $context_id);
         }
     }
 }
 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 getSearchDirs()
 {
     $return_value = array();
     $template_dir_property = __CurrentContext::getInstance()->getPropertyContent('TEMPLATES_DIR');
     $template_dirs_array = explode(',', $template_dir_property);
     foreach ($template_dirs_array as $template_dir) {
         $template_dir = __PathResolver::resolvePath($template_dir);
         if ($template_dir != null) {
             $return_value[] = $template_dir;
         }
     }
     return $return_value;
 }
Example #20
0
 public final function getEventHandlerClass()
 {
     if ($this->_event_handler_class != null && class_exists($this->_event_handler_class)) {
         $return_value = $this->_event_handler_class;
     } else {
         if ($this->_code != null && class_exists($this->_code . 'EventHandler')) {
             $return_value = $this->_code . 'EventHandler';
         } else {
             $return_value = __CurrentContext::getInstance()->getPropertyContent('DEFAULT_EVENT_HANDLER_CLASS');
         }
     }
     return $return_value;
 }
 public function startRender(__IComponent &$component)
 {
     $this->_component =& $component;
     $return_value = $this->_generateStartMenuEngine();
     $configuration_file = 'config/menu.xml';
     //by default
     if (!empty($this->_component->configuration)) {
         $configuration_file = $this->_component->configuration;
     }
     $configuration = __CurrentContext::getInstance()->getConfigurationLoader()->loadConfigurationFile($configuration_file);
     $return_value .= $this->_loadMenuItem($configuration->getSection('menu_pc'));
     $return_value .= $this->_generateEndMenuEngine();
     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();
 }
 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);
         }
     }
 }
 public static function resolvePath($path, $base_dir = null)
 {
     if ($base_dir == null) {
         $current_context = __CurrentContext::getInstance();
         if ($current_context != null) {
             $base_dir = $current_context->getBaseDir();
         } else {
             $base_dir = APP_DIR;
         }
     }
     if (preg_match('/^\\//', $path) || preg_match('/^\\w+:/', $path)) {
         $return_value = $path;
     } else {
         $return_value = rtrim($base_dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . ltrim($path, DIRECTORY_SEPARATOR);
     }
     return $return_value;
 }
 protected function _getStartRenderCode()
 {
     $return_value = '';
     if (count($this->_component_specs) > 0) {
         $component_render_class = __CurrentContext::getInstance()->getPropertyContent('DEFAULT_COMPONENT_RENDER_CLASS');
         $return_value .= "<?php\n";
         $return_value .= 'if ($_smarty_tpl->parent == null && !key_exists("__Lion_component_render_' . $this->_view_code . '__", $_smarty_tpl->parent->tpl_vars)) {' . "\n";
         $return_value .= '    $mark_as_root_template_' . $this->_view_code . " = true; \n";
         $return_value .= "}\n";
         $return_value .= '$component_render_' . $this->_view_code . ' = new ' . $component_render_class . '($_smarty_tpl->getVariable("__view_code__")->value);' . "\n";
         $return_value .= '$component_render_' . $this->_view_code . "->startRender();\n";
         $return_value .= '$_smarty_tpl->tpl_vars["__Lion_component_render_' . $this->_view_code . '__"] = new Smarty_variable(true);' . "\n";
         $return_value .= '$component_specs_' . $this->_view_code . ' = unserialize(base64_decode("' . base64_encode(serialize($this->_component_specs)) . '"));' . "\n";
         $return_value .= "?>\n";
     }
     return $return_value;
 }
 public static function resolveValue($value)
 {
     $return_value = trim($value);
     if (preg_match('/\\$\\{([^\\}]+)\\}/', $value, $values_matched)) {
         $property_name = $values_matched[1];
         if (__CurrentContext::getInstance()->hasProperty($property_name)) {
             $property_value = __CurrentContext::getInstance()->getPropertyContent($property_name);
         } else {
             if (key_exists(strtoupper($property_name), self::$_setting_values)) {
                 $property_value = self::$_setting_values[$property_name];
             } else {
                 throw new __ConfigurationException('Unknown property ' . $property_name . '. Make sure that it has been parsed before used.');
             }
         }
         $return_value = str_replace('${' . $property_name . '}', $property_value, $return_value);
     } else {
         if (strpos($return_value, 'const:') === 0) {
             $constant_name = trim(substr($return_value, 6));
             if (defined($constant_name)) {
                 $return_value = constant($constant_name);
             } else {
                 throw new __ConfigurationException('Unknown constant ' . $constant_name);
             }
         } else {
             if (strpos($return_value, 'prop:') === 0) {
                 $property_name = trim(substr($return_value, 5));
                 if (__CurrentContext::getInstance()->hasProperty($property_name)) {
                     $return_value = __CurrentContext::getInstance()->getPropertyContent($property_name);
                 } else {
                     throw new __ConfigurationException('Unknown property ' . $property_name . '. Make sure that it has been parsed before used.');
                 }
             } else {
                 if (strtoupper($return_value) == 'TRUE') {
                     $return_value = true;
                 } else {
                     if (strtoupper($return_value) == 'FALSE') {
                         $return_value = false;
                     }
                 }
             }
         }
     }
     return $return_value;
 }
 public function execute($action_code = null)
 {
     if ($action_code == null) {
         if (method_exists($this, $this->getCode() . 'Action')) {
             $action_code = $this->getCode();
         } else {
             $action_code = __CurrentContext::getInstance()->getPropertyContent('DEFAULT_ACTION_CODE');
         }
     }
     if (!method_exists($this, $action_code . 'Action')) {
         throw __ExceptionFactory::getInstance()->createException('ERR_ACTION_NOT_SUPPORTED_BY_CONTROLLER', array(get_class($this), $action_code));
     }
     $model_and_view = call_user_func_array(array($this, $action_code . 'Action'), array());
     return $model_and_view;
 }
Example #28
0
 public function __Route()
 {
     $this->_front_controller_class = __CurrentContext::getInstance()->getPropertyContent('HTTP_FRONT_CONTROLLER_CLASS');
     $this->_action_identity = new __ActionIdentity();
 }
 /**
  * This method performs the call to the selected model service.
  *
  * @param array A set of parameters to send in the service call (optional, if not defined, the specified in the constructor call will be used by default)
  * @return mixed The value returned by the model service
  * @exception __ModelException if a non-existent service is trying to called
  */
 public function &call(array &$parameters = null)
 {
     $return_value = null;
     $this->_validate();
     try {
         if ($this->_cache) {
             $service_id = md5($this->_class . '::' . $this->_service . '::' . serialize($parameters));
             $cache = __ApplicationContext::getInstance()->getCache();
             $data = $cache->getData($service_id, $this->_cache_ttl);
             if ($data !== null) {
                 return $data;
             }
         }
         if ($this->_class != null) {
             $class_name = $this->_class;
             $model_instance = new $class_name();
         } else {
             if ($this->_instance != null) {
                 $model_instance = __CurrentContext::getInstance()->getContextInstance($this->_instance);
                 if ($model_instance == null) {
                     throw __ExceptionFactory::getInstance()->createException('Unknown context instance: ' . $this->_instance);
                 }
             } else {
                 throw __ExceptionFactory::getInstance()->createException('Unknown model receiver to dispatch the model service ' . $this->_service);
             }
         }
         $return_value = call_user_func_array(array($model_instance, $this->_service), $parameters);
         if ($this->_cache) {
             $cache->setData($service_id, $return_value, $this->_cache_ttl);
         }
     } catch (Exception $e) {
         if ($e instanceof __LionException) {
             throw $e;
         } else {
             throw new __ModelException($e->getMessage(), $e->getCode());
         }
     }
     return $return_value;
 }
 /**
  * Get the session
  *
  * @param string $context_id
  * @return __Session
  */
 public function &getSession($context_id = null)
 {
     if ($context_id == null) {
         $context_id = __CurrentContext::getInstance()->getContextId();
     }
     if (!key_exists($context_id, $this->_sessions)) {
         if (!$this->isSessionStarted()) {
             $this->startSession();
         }
         $session = new __Session($context_id);
         $this->_sessions[$context_id] =& $session;
     }
     return $this->_sessions[$context_id];
 }