Пример #1
0
 /**
  * Initializes the core.
  * @return bool
  */
 public static function initialize()
 {
     if (self::$_init) {
         // Do not allow to execution twice
         return false;
     }
     self::$_init = true;
     // Determine if we are running in a Windows environment
     self::$is_win = DIRECTORY_SEPARATOR === '\\';
     // Load the logger
     self::$log = Log::instance();
     // Load the default configuration files
     self::$config = Config::instance()->attach(new Config_File());
     // Load the i18n class
     self::$i18n = I18n::instance();
     // Enable debug log
     if (self::$log_debug) {
         self::$log->attach(new Log_File(APPPATH . 'data/log/debug'), array('EXIDO_DEBUG_LOG'));
         self::$log->add('EXIDO_DEBUG_LOG', 'Initialize framework');
     }
     // Enable error log
     if (self::$log_error) {
         self::$log->attach(new Log_File(APPPATH . 'data/log/error'), array('EXIDO_ERROR_LOG'));
     }
     // Determine if we are running in a command line environment
     self::$is_cli = PHP_SAPI === 'cli';
     // Check if we have an Ajax request
     self::$is_xml = Input::instance()->isXmlRequest();
     // Load helpers
     Helper::load('lang', 'uri');
     // Check if we can use gZIP compression
     self::$use_gzip = strstr(Input::instance()->server('HTTP_ACCEPT_ENCODING'), "gzip") !== false and extension_loaded("zlib");
     // Start output buffering
     ob_start(array(__CLASS__, 'outputBuffer'));
     // Save buffering level
     self::$_buffer_level = ob_get_level();
     Event::add('system.routing', array('Router', 'getUri'));
     Event::add('system.routing', array('Router', 'initialize'));
     Event::add('system.execute', array(__CLASS__, 'instance'));
     Event::add('system.shutdown', array(__CLASS__, 'shutdown'));
     return true;
 }