bootstrap( 'view' ); $view = $this->getResource( 'view' ); $view->doctype( 'XHTML1_STRICT' ); } /** * Autoload models * * @return Zend_Application_Module_Autoloader */ protected function _initAutoload() { $moduleLoader = new Zend_Application_Module_Autoloader( array( 'namespace' => '', 'basePath' => APPLICATION_PATH ) ); return $moduleLoader; } /** * Initialize autoloader for CPC libraries * * @return void */ protected function _initAutoloaderNamespace() { $autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader->registerNamespace('Cpc_'); } /** * Initialize modules * * @return void */ protected function _initModules() { // Ensure front controller instance is present $this->bootstrap( 'frontController' ); // Get frontController resource $this->_front = $this->getResource( 'frontController' ); $this->_front->addModuleDirectory( APPLICATION_PATH . '/modules' ); $this->_front->setDefaultModule( APPLICATION_DEFAULT_MODULE ); $this->_front->registerPlugin( new Cpc_Plugin_Modulesetup() ); } /** * Initialize and setup baseUrl * * @return void */ protected function _initBaseUrl() { // Get baseurl $baseUrl = str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']); // This is a fix for those who are using mod_userdir on apache or acessing this via symlinks $dirname = dirname( $_SERVER['SCRIPT_NAME'] ) .'/'; $pos = strpos( $_SERVER['REQUEST_URI'] , $dirname ); if ( $pos !== false ) { $baseUrl = substr( $_SERVER['REQUEST_URI'] , 0 , $pos ) . $baseUrl; } // Set baseUrl on front controller $this->_front->setBaseUrl( $baseUrl ); // Set baseUrl on view $view = $this->getResource( 'view' ); $view->baseUrl = $baseUrl; $config = new Zend_Config_Ini( dirname( __FILE__ ) . '/configs/application.ini', APPLICATION_ENV ); if ( $config->modrewrite ) { $view->siteUrl = $baseUrl; } else { $view->siteUrl = $baseUrl .'index.php/'; } } /** * Initialize database * * @return void */ protected function _initDb() { $config = new Zend_Config_Ini( dirname( __FILE__ ) . '/configs/application.ini', APPLICATION_ENV ); $db = Zend_Db::factory( $config->database ); Zend_Db_Table::setDefaultAdapter( $db ); Zend_Registry::set( 'db', $db ); } /** * Initialize Locale and Translation * * @return void */ protected function _initLocale() { $locale = new Zend_Locale(); Zend_Registry::set( 'Zend_Locale', $locale ); $language = $locale->getLanguage(); $translationFile = LANGUAGE_PATH . DIRECTORY_SEPARATOR . $language . '.php'; // If file for this language doesn't exist, fall back to english if ( !file_exists( $translationFile ) ) { $language = 'en'; $translationFile = LANGUAGE_PATH . DIRECTORY_SEPARATOR . 'en.php'; } $translate = new Zend_Translate( 'array', $translationFile, $language ); Zend_Registry::set( 'Zend_Translate', $translate ); } /** * Initialize Zend Session * * @return void */ protected function _initSession() { Zend_Session::start(); } /** * Add SmartClient view helpers as it is used on most CPC projects. * Remember to copy the files from SCZF to the library folder. * * @return void */ protected function _initSmartClient() { // Add SmartClient Helpers $this->bootstrap( 'view' ); $view = $this->getResource( 'view' ); $view->addHelperPath( 'SmartClient/Helper' , 'SmartClient_Helper' ); $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer(); $viewRenderer->setView( $view ); Zend_Controller_Action_HelperBroker::addHelper( $viewRenderer ); } }