Ejemplo n.º 1
0
 /**
  * Sets the initial variables, checks if we need to process the css
  * and then sends whichever file to the browser.
  *
  * @return void
  */
 public static function setup($config)
 {
     /**
      * Choose whether to show or hide errors
      */
     if (SCAFFOLD_PRODUCTION === false) {
         ini_set('display_errors', true);
         error_reporting(E_ALL & ~E_STRICT);
     } else {
         ini_set('display_errors', false);
         error_reporting(0);
     }
     /**
      * Define contstants for system paths for easier access.
      */
     if (!defined('SCAFFOLD_SYSPATH') && !defined('SCAFFOLD_DOCROOT')) {
         define('SCAFFOLD_SYSPATH', self::fix_path($config['system']));
         define('SCAFFOLD_DOCROOT', $config['document_root']);
         define('SCAFFOLD_URLPATH', str_replace(SCAFFOLD_DOCROOT, '', SCAFFOLD_SYSPATH));
     }
     /**
      * Add include paths for finding files
      */
     Scaffold::add_include_path(SCAFFOLD_SYSPATH, SCAFFOLD_DOCROOT);
     /**
      * Tell the cache where to save files and for how long to keep them for
      */
     Scaffold_Cache::setup(Scaffold::fix_path($config['cache']), $config['cache_lifetime']);
     /**
      * The level at which logged messages will halt processing and be thrown as errors
      */
     self::$error_threshold = $config['error_threshold'];
     /**
      * Disabling flags allows for quicker processing
      */
     if ($config['disable_flags'] === true) {
         self::$flags = false;
     }
     /**
      * Tell the log where to save it's files. Set it to automatically save the log on exit
      */
     if ($config['enable_log'] === true) {
         // START - Modified by Webligo Developments
         if ($config['log_path']) {
             Scaffold_Log::log_directory($config['log_path']);
         } else {
             Scaffold_Log::log_directory(SCAFFOLD_SYSPATH . 'logs');
         }
         // END - Modified by Webligo Developments
         //Scaffold_Log::log_directory(SCAFFOLD_SYSPATH.'logs');
         Scaffold_Event::add('system.shutdown', array('Scaffold_Log', 'save'));
     }
     /**
      * Load each of the modules
      */
     foreach (Scaffold::list_files(SCAFFOLD_SYSPATH . 'modules') as $module) {
         $name = basename($module);
         $module_config = SCAFFOLD_SYSPATH . 'config/' . $name . '.php';
         if (file_exists($module_config)) {
             unset($config);
             include $module_config;
             self::$config[$name] = $config;
         }
         self::add_include_path($module);
         if ($controller = Scaffold::find_file($name . '.php', false, true)) {
             require_once $controller;
             self::$modules[$name] = new $name();
         }
     }
     /**
      * Module Initialization Hook
      * This hook allows modules to load libraries and create events
      * before any processing is done at all. 
      */
     self::hook('initialize');
     /**
      * Create the shutdown event
      */
     Scaffold_Event::add('system.shutdown', array('Scaffold', 'shutdown'));
 }