finish(); } /** * Check if the application is initialized * @return bool */ public static function initialized() { return !is_null(self :: $root_directory_path); } /** * Check if a specific configuration variable is set * * @param string $key The configuration variable key * @return bool **/ public static function isset($key) { return Config::isset($key, self :: $options) || (Config::loaded() && Config::isset($key)); } /** * Get a specific option value * * @param string $key The configuration variable key * @param mixed $default The default value to return if configuration variable * is not set (Default : null) * @param string $cast The type of expected value. The configuration variable * value will be cast as this type. Could be : bool, int, * float or string. (Optional, default : raw value) * @param bool $split If true, $cast is 'array' and value retreived from configuration * is a string, split the value by comma (optional, default: true) * @return mixed The configuration variable value **/ public static function get($key, $default=null, $cast=null, $split=true) { $default = self :: get_default($key, $default, $cast, $split); return Config::get( $key, Config::loaded()?Config::get($key, $default, $cast, $split):$default, $cast, $split, self :: $options ); } /** * Get a specific option default value * * @param string $key The configuration variable key * @param mixed $default Default value provided by context * (optional, priority if not nul, default : null) * @param string $cast The type of expected value. The configuration variable * default value will be cast as this type. Could be : bool, int, * float or string. (Optional, default : raw value) * @param bool $split If true, $cast is 'array' and value retreived from configuration * is a string, split the value by comma (optional, default: true) * @return mixed The configuration variable default value **/ public static function get_default($key, $default=null, $cast=null, $split=true) { if (!is_null($default)) return $default; return Config::get( "default.$key", $default, $cast, $split, self :: $options ); } /** * Get list of keys of a specific option * * @param string $key The configuration variable key * * @return array An array of the keys of a specific option **/ public static function keys($key) { $value = self :: get($key); return (is_array($value)?array_keys($value):array()); } /** * Set a specific option value * * @param string $key The configuration variable key * @param mixed $value The configuration variable value * @return boolean **/ public static function set($key, $value) { if (Config::isset($key, self :: $options)) return Config::set($key, $value, self :: $options); return Config::set($key, $value); } /** * Retreive application root directory path * @return string|null */ public static function root_directory_path() { return self :: $root_directory_path?self :: $root_directory_path:'.'; } /** * Default homepage handler * @param UrlRequest $request * @return void */ public static function handle_homepage($request) { if (Tpl::initialized()) Tpl :: display("homepage.tpl", I18n::_("Hello world !")); else echo "