Ejemplo n.º 1
0
 function initialize()
 {
     // OS is Windows?
     if (substr(PHP_OS, 0, 3) == 'WIN') {
         self::$path_seperator = ";";
     }
     // set paths
     self::$app_path = ZNAP_ROOT . '/app';
     self::$controllers_path = self::$app_path . '/controllers';
     self::$helpers_path = self::$app_path . '/helpers';
     self::$models_path = self::$app_path . '/models';
     self::$prefs_path = self::$app_path . '/preferences';
     self::$snippets_path = self::$app_path . '/snippets';
     self::$snippet_helpers_path = self::$helpers_path . '/snippet_helpers';
     // display mode path
     if (ZNAP_MODE != 'web' && is_dir(self::$app_path . '/views-' . ZNAP_MODE)) {
         self::$views_path = self::$app_path . '/views-' . ZNAP_MODE;
     } else {
         self::$views_path = self::$app_path . '/views';
     }
     // set more paths
     self::$layouts_path = self::$views_path . '/__layouts';
     self::$errors_path = self::$views_path . '/__errors';
     self::$errors_default_path = self::$views_path . '/__errors/default';
     self::$snippet_views_path = self::$views_path . '/__snippets';
     self::$snippet_layouts_path = self::$views_path . '/__snippets/__layouts';
     self::$config_path = ZNAP_ROOT . '/config';
     self::$environments_path = self::$config_path . '/environments';
     self::$strings_path = self::$config_path . '/strings';
     self::$tmp_path = ZNAP_ROOT . '/tmp';
     self::$cache_path = self::$tmp_path . '/cache';
     self::$lib_path = ZNAP_ROOT . '/libs';
     self::$log_path = ZNAP_ROOT . '/logs';
     self::$public_path = ZNAP_ROOT . '/public';
     self::$vendor_path = ZNAP_ROOT . '/vendor';
     self::$shell_scripts_path = ZNAP_LIB_ROOT . '/shell_scripts';
     // logging setup
     if (ZNAP_ENABLE_LOGGING && !defined('ZNAP_SHELL_SCRIPT')) {
         ini_set('log_errors', 'On');
     } else {
         ini_set('log_errors', 'Off');
     }
     if (ZNAP_INTERNAL_LOGGING && !defined('ZNAP_SHELL_SCRIPT')) {
         ini_set('error_log', self::$log_path . '/' . ZNAP_ENV . '.log');
     }
     if (ZNAP_ENV == 'development') {
         // display errors in browser in development mode for easy debugging
         ini_set('display_errors', 'On');
         // ini_set('error_reporting', 'E_ALL'); //FIXME using ini_set() to change "error_reporting" stops error messages from displaying
     } else {
         // hide errors from browser if not in development mode
         ini_set('display_errors', 'Off');
     }
     // setup include paths
     ini_set('include_path', '.' . self::$path_seperator . ZNAP_LIB_ROOT . self::$path_seperator . ZNAP_LIB_ROOT . '/shell_scripts' . self::$path_seperator . self::$lib_path . self::$path_seperator . ini_get('include_path'));
     // load the zynapse libs
     require_once 'session.php';
     require_once 'preferences.php';
     // require_once('input_filter.php'); //TODO require InputFilter class when (if ever) it is created
     require_once 'active_record.php';
     require_once 'action_controller.php';
     require_once 'snippet_controller.php';
     require_once 'action_view.php';
     require_once 'dispatcher.php';
     require_once 'inflector.php';
     require_once 'router.php';
     require_once 'timer.php';
     require_once 'znap_error.php';
     if (defined('ZNAP_SHELL_SCRIPT')) {
         require_once 'shell_script.php';
     }
     // load and set database configuration
     if (file_exists(self::$config_path . '/database.php')) {
         include_once self::$config_path . '/database.php';
         if (!empty($database_settings)) {
             ActiveRecord::$settings = $database_settings;
         }
     }
     // set url prefix path if needed
     if (defined('URL_PREFIX')) {
         Znap::$url_prefix = URL_PREFIX;
     }
     // load default strings
     require_once 'strings.php';
     self::$strings = $strings;
     unset($strings);
     // load app's global strings
     if (is_file(self::$strings_path . '/_global.php')) {
         require_once self::$strings_path . '/_global.php';
         if (!empty($strings)) {
             self::$strings = $strings;
             unset($strings);
         }
     }
     // initialize preference system
     self::$prefs = new PreferenceCollection(array(self::$prefs_path, self::$tmp_path));
     self::$prefs->read('_internals');
     self::$prefs->read('application');
     self::$prefs->read('cache', true, self::$tmp_path);
     // initialize the App class - read the comment on the class for more info
     App::initialize();
 }