/** * Initialization stage, loads configuration files, sets up includes paths * and instantiates the frontController * * @return Zend_Controller_Front */ public function initialize() { // Ensure that session cookies are not available to JavaScript ini_set("session.cookie_httponly", 1); // Set the include path set_include_path(self::$_base_path . DIRECTORY_SEPARATOR . 'library' . PATH_SEPARATOR . self::$_base_path . DIRECTORY_SEPARATOR . "app" . PATH_SEPARATOR . get_include_path()); require_once "Zend/Loader/Autoloader.php"; $autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader->setFallbackAutoloader(true); $locale = new Zend_Locale(); Zend_Registry::set('Zend_Locale', $locale); /* * Create an instance of the frontcontroller */ $frontController = Zend_Controller_Front::getInstance(); if (file_exists(self::$_data_path . '/etc/config.ini')) { /* * Load the given stage from our configuration file, * and store it into the registry for later usage. */ $config = new Zend_Config_Ini(self::$_data_path . '/etc/config.ini'); Zend_Registry::set('config', $config); $frontController->throwExceptions((bool) $config->mvc->exceptions); if (PHP_SAPI != "cli") { self::$_environment = $config->mode; $frontController->registerPlugin(new Zoo_Plugin_Boot_Http(), 1); } else { $frontController->throwExceptions(true); self::$_environment = "cli"; $frontController->registerPlugin(new Zoo_Plugin_Boot_Cli(), 1); Zend_Registry::set("Zend_Locale", new Zend_Locale("en_US")); $frontController->setResponse(new Zend_Controller_Response_Cli()); } // Add plugins from plugins.ini if (file_exists(self::$_data_path . '/etc/plugins.ini')) { $pluginconfig = new Zend_Config_Ini(self::$_data_path . '/etc/plugins.ini', self::$_environment); foreach ($pluginconfig->plugins as $name => $plugin) { $pluginClass = $plugin->class; $frontController->registerPlugin(new $pluginClass(), $plugin->priority); } } if ($config->module->default) { $frontController->setDefaultModule($config->module->default); } else { $frontController->setDefaultModule('zoo'); } } else { /** * System not installed, go to staging mode, add the default module * and register the Http boot plugin */ self::$_environment = "staging"; $frontController->addControllerDirectory(self::$_base_path . "/app/Zoo/Controllers", "Zoo"); $frontController->registerPlugin(new Zoo_Plugin_Boot_Http(), 1); $frontController->setDefaultModule('Zoo'); } return $frontController; }