Example #1
0
 public static function encoding()
 {
     if (is_null(static::$encoding)) {
         static::$encoding = Config::app('encoding');
     }
     return static::$encoding;
 }
Example #2
0
 /**
  * Initializes the framework.
  * This can only be called once.
  *
  * @access public
  * @return void
  */
 public static function init($config)
 {
     if (static::$initialized) {
         throw new \FuelException("You can't initialize Fuel more than once.");
     }
     // BC FIX FOR APPLICATIONS <= 1.6.1, makes Redis_Db available as Redis,
     // like it was in versions before 1.7
     class_exists('Redis', false) or class_alias('Redis_Db', 'Redis');
     static::$_paths = array(APPPATH, COREPATH);
     // Is Fuel running on the command line?
     static::$is_cli = (bool) defined('STDIN');
     \Config::load($config);
     // Start up output buffering
     static::$is_cli or ob_start(\Config::get('ob_callback', null));
     if (\Config::get('caching', false)) {
         \Finder::instance()->read_cache('FuelFileFinder');
     }
     static::$profiling = \Config::get('profiling', false);
     static::$profiling and \Profiler::init();
     // set a default timezone if one is defined
     try {
         static::$timezone = \Config::get('default_timezone') ?: date_default_timezone_get();
         date_default_timezone_set(static::$timezone);
     } catch (\Exception $e) {
         date_default_timezone_set('UTC');
         throw new \PHPErrorException($e->getMessage());
     }
     static::$encoding = \Config::get('encoding', static::$encoding);
     MBSTRING and mb_internal_encoding(static::$encoding);
     static::$locale = \Config::get('locale', static::$locale);
     if (!static::$is_cli) {
         if (\Config::get('base_url') === null) {
             \Config::set('base_url', static::generate_base_url());
         }
     }
     // Run Input Filtering
     \Security::clean_input();
     \Event::register('fuel-shutdown', 'Fuel::finish');
     // Always load classes, config & language set in always_load.php config
     static::always_load();
     // Load in the routes
     \Config::load('routes', true);
     \Router::add(\Config::get('routes'));
     // Set locale, log warning when it fails
     if (static::$locale) {
         setlocale(LC_ALL, static::$locale) or logger(\Fuel::L_WARNING, 'The configured locale ' . static::$locale . ' is not installed on your system.', __METHOD__);
     }
     static::$initialized = true;
     // fire any app created events
     \Event::instance()->has_events('app_created') and \Event::instance()->trigger('app_created', '', 'none');
     if (static::$profiling) {
         \Profiler::mark(__METHOD__ . ' End');
     }
 }
Example #3
0
 /**
  * Get the appliction.encoding without needing to request it from Config::get() each time.
  *
  * @return string
  */
 protected static function encoding()
 {
     return static::$encoding ?: (static::$encoding = Config::get('application.encoding'));
 }
Example #4
0
 /**
  * Initializes the framework.  This can only be called once.
  *
  * @access	public
  * @return	void
  */
 public static function init($config)
 {
     if (static::$initialized) {
         throw new \FuelException("You can't initialize Fuel more than once.");
     }
     static::$_paths = array(APPPATH, COREPATH);
     // Is Fuel running on the command line?
     static::$is_cli = (bool) defined('STDIN');
     \Config::load($config);
     // Start up output buffering
     ob_start(\Config::get('ob_callback', null));
     static::$profiling = \Config::get('profiling', false);
     if (static::$profiling) {
         \Profiler::init();
         \Profiler::mark(__METHOD__ . ' Start');
     }
     static::$cache_dir = \Config::get('cache_dir', APPPATH . 'cache/');
     static::$caching = \Config::get('caching', false);
     static::$cache_lifetime = \Config::get('cache_lifetime', 3600);
     if (static::$caching) {
         \Finder::instance()->read_cache('Fuel::paths');
     }
     // set a default timezone if one is defined
     static::$timezone = \Config::get('default_timezone') ?: date_default_timezone_get();
     date_default_timezone_set(static::$timezone);
     static::$encoding = \Config::get('encoding', static::$encoding);
     MBSTRING and mb_internal_encoding(static::$encoding);
     static::$locale = \Config::get('locale', static::$locale);
     if (!static::$is_cli) {
         if (\Config::get('base_url') === null) {
             \Config::set('base_url', static::generate_base_url());
         }
     }
     // Run Input Filtering
     \Security::clean_input();
     \Event::register('shutdown', 'Fuel::finish');
     // Always load classes, config & language set in always_load.php config
     static::always_load();
     // Load in the routes
     \Config::load('routes', true);
     \Router::add(\Config::get('routes'));
     // Set locale, log warning when it fails
     if (static::$locale) {
         setlocale(LC_ALL, static::$locale) or logger(\Fuel::L_WARNING, 'The configured locale ' . static::$locale . ' is not installed on your system.', __METHOD__);
     }
     static::$initialized = true;
     // fire any app created events
     \Event::instance()->has_events('app_created') and \Event::instance()->trigger('app_created', '', 'none');
     if (static::$profiling) {
         \Profiler::mark(__METHOD__ . ' End');
     }
 }
Example #5
0
 /**
  * Initializes the framework.  This can only be called once.
  *
  * @access	public
  * @return	void
  */
 public static function init($config)
 {
     \Config::load($config);
     if (static::$initialized) {
         throw new \Fuel_Exception("You can't initialize Fuel more than once.");
     }
     register_shutdown_function('fuel_shutdown_handler');
     set_exception_handler('fuel_exception_handler');
     set_error_handler('fuel_error_handler');
     // Start up output buffering
     ob_start(\Config::get('ob_callback', null));
     static::$profiling = \Config::get('profiling', false);
     if (static::$profiling) {
         \Profiler::init();
         \Profiler::mark(__METHOD__ . ' Start');
     }
     static::$cache_dir = \Config::get('cache_dir', APPPATH . 'cache/');
     static::$caching = \Config::get('caching', false);
     static::$cache_lifetime = \Config::get('cache_lifetime', 3600);
     if (static::$caching) {
         static::$path_cache = static::cache('Fuel::path_cache');
     }
     // set a default timezone if one is defined
     static::$timezone = \Config::get('default_timezone') ?: date_default_timezone_get();
     date_default_timezone_set(static::$timezone);
     // set the encoding and locale to use
     static::$encoding = \Config::get('encoding', static::$encoding);
     static::$locale = \Config::get('locale', static::$locale);
     static::$_paths = array(APPPATH, COREPATH);
     if (!static::$is_cli) {
         if (\Config::get('base_url') === null) {
             \Config::set('base_url', static::generate_base_url());
         }
         \Uri::detect();
     }
     // Run Input Filtering
     \Security::clean_input();
     static::$env = \Config::get('environment');
     \Event::register('shutdown', 'Fuel::finish');
     //Load in the packages
     foreach (\Config::get('always_load.packages', array()) as $package => $path) {
         is_string($package) and $path = array($package => $path);
         static::add_package($path);
     }
     // Load in the routes
     \Config::load('routes', true);
     \Router::add(\Config::get('routes'));
     // Set  locale
     static::$locale and setlocale(LC_ALL, static::$locale);
     // Always load classes, config & language set in always_load.php config
     static::always_load();
     static::$initialized = true;
     if (static::$profiling) {
         \Profiler::mark(__METHOD__ . ' End');
     }
 }
Example #6
0
 /**
  * Constructor, create a new Date object using the information passed
  *
  * @param  string|int           $time      date/time as a UNIX timestamp or a string
  * @param  string|DateTimeZone  $timezone  timezone $time is in
  * @param  array                $config    any custom configuration for this object
  *
  * @throws  Exception  if the time passed is not valid
  */
 public function __construct($time = "now", $timezone = null, array $config = array())
 {
     // any GMT offset defined?
     if (isset($config['gmtOffset'])) {
         static::$gmtOffset = $config['gmtOffset'];
     }
     // any encoding defined?
     if (isset($config['encoding'])) {
         static::$encoding = strtoupper($config['encoding']);
     }
     // do we have a default timezone?
     if (isset($config['defaultTimezone'])) {
         static::defaultTimezone($config['defaultTimezone']);
     } else {
         static::defaultTimezone(date_default_timezone_get());
     }
     // any custom format patterns?
     if (isset($config['patterns']) and is_array($config['patterns'])) {
         static::$patterns = $config['patterns'];
     }
     // default to current time if none is given
     if ($time === null or $time === 'now') {
         $time = '@' . strval(time() + static::$gmtOffset);
     } elseif (is_numeric($time)) {
         $time = '@' . $time;
     }
     // construct the datetime object
     if ($time instanceof DateTime) {
         $this->datetime = $time;
     } else {
         // if timezone is given as a string, convert it
         if (is_string($timezone)) {
             $timezone = new DateTimeZone($timezone);
         } elseif ($timezone === null) {
             $timezone = static::defaultTimezone();
         }
         $this->datetime = new DateTime($time, $timezone);
         static::$lastErrors = DateTime::getLastErrors();
         // make sure the objects timezone is ok,
         // some formats default to UTC, no matter what timezone is passed
         $this->datetime->setTimezone($timezone);
     }
 }
 /**
  * Sets encoding and collate
  * @param string $encoding
  * @param string $collate
  * @return void
  */
 public static function setEncoding($encoding, $collate)
 {
     static::$encoding = $encoding;
     static::$collate = $collate;
 }
Example #8
0
 /**
  * Initializes the framework.  This can only be called once.
  *
  * @access	public
  * @return	void
  */
 public static function init($config)
 {
     if (static::$initialized) {
         throw new \FuelException("You can't initialize Fuel more than once.");
     }
     static::$_paths = array(APPPATH, COREPATH);
     // Is Fuel running on the command line?
     static::$is_cli = (bool) defined('STDIN');
     \Config::load($config);
     // Start up output buffering
     ob_start(\Config::get('ob_callback', null));
     static::$profiling = \Config::get('profiling', false);
     if (static::$profiling) {
         \Profiler::init();
         \Profiler::mark(__METHOD__ . ' Start');
     }
     static::$cache_dir = \Config::get('cache_dir', APPPATH . 'cache/');
     static::$caching = \Config::get('caching', false);
     static::$cache_lifetime = \Config::get('cache_lifetime', 3600);
     if (static::$caching) {
         \Finder::instance()->read_cache('Fuel::paths');
     }
     // set a default timezone if one is defined
     static::$timezone = \Config::get('default_timezone') ?: date_default_timezone_get();
     date_default_timezone_set(static::$timezone);
     static::$encoding = \Config::get('encoding', static::$encoding);
     MBSTRING and mb_internal_encoding(static::$encoding);
     static::$locale = \Config::get('locale', static::$locale);
     if (!static::$is_cli) {
         if (\Config::get('base_url') === null) {
             \Config::set('base_url', static::generate_base_url());
         }
     }
     // Run Input Filtering
     \Security::clean_input();
     \Event::register('shutdown', 'Fuel::finish');
     //Load in the packages
     foreach (\Config::get('always_load.packages', array()) as $package => $path) {
         is_string($package) and $path = array($package => $path);
         \Package::load($path);
     }
     // Always load classes, config & language set in always_load.php config
     static::always_load();
     // Load in the routes
     \Config::load('routes', true);
     \Router::add(\Config::get('routes'));
     // Set  locale
     static::$locale and setlocale(LC_ALL, static::$locale);
     static::$initialized = true;
     if (static::$profiling) {
         \Profiler::mark(__METHOD__ . ' End');
     }
 }
Example #9
0
 /**
  * Get the appliction.encoding without needing to request it from Config::get() each time.
  *
  * @return string
  */
 protected static function encoding()
 {
     return static::$encoding ?: (static::$encoding = 'UTF-8');
 }
Example #10
0
 /**
  * Set encoding
  *
  * @param string $encoding
  * @return void
  */
 public static function setEncoding($encoding)
 {
     static::$encoding = $encoding;
 }