bootstrap("frontController"); // $frontController = Zend_Controller_Front::getInstance(); $this->_frontController = Zend_Controller_Front::getInstance(); // add the REST route for the API module only $restRoute = new Zend_Rest_Route($this->_frontController, array(), array('v1')); $this->_frontController->getRouter()->addRoute('rest', $restRoute); } protected function _initDefaultModuleAutoloader() { $loader = Zend_Loader_Autoloader::getInstance(); $loader->registerNamespace('App_'); $this->getResourceLoader() ->addResourceType('modelResource', 'models/resources', 'Resource') ->addResourceType('controllerSection', 'controllerSections', 'ControllerSection'); } protected function _initEnviromentIni() { $this->_enviroments = new Zend_Config_Ini(APPLICATION_PATH . '/configs/enviroment.ini', APPLICATION_ENV); Zend_Registry::set('ENVIROMENTS', $this->_enviroments); } protected function _initConfigIni() { //VARIABILI CONSTANTI PER TUTTO IL DOMINIO Zend_Registry::set('VARIABILE_VERSION', $this->_enviroments->get('version')); $this->_config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/config.ini', null, array('skipExtends' => true, 'allowModifications' => true)); Zend_Registry::set('config', $this->_config); } protected function _initLocale() { //Detect Browser language $browserLang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); $browserLang = ($browserLang != 'it' && $browserLang != 'en') ? 'it' : $browserLang; $locale = new Zend_Locale($browserLang); Zend_Registry::set('Zend_Locale', $locale); $this->_locale = $locale; } protected function _initLanguage() { $localeValue = 'it'; $translationPath = dirname(APPLICATION_PATH) . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR . $localeValue; $translate = new Zend_Translate('array', $translationPath, $localeValue); Zend_Registry::set('Zend_Translate', $translate); Zend_Validate_Abstract::setDefaultTranslator($translate); Zend_Form::setDefaultTranslator($translate); } protected function _initFrontControllerPlugin() { $this->_frontController->registerPlugin(new App_Controller_Plugin_Acl()); $this->_frontController->registerPlugin(new App_Controller_Plugin_LangSelector()); } protected function _initViewSettings(){ $this->bootstrap('view'); $view = $this->getResource('view'); $view->baseUrlSite = $this->_enviroments->get('baseUrlSite'); $view->version = $this->_enviroments->get('version'); } protected function _initMongoDbParms() { Zend_Registry::set('ENABLE_MONGODB', false); // per getire l'abilitazione inserire i dati necessari a mongo db connection } protected function _initDbParms() { $mySqlDbParams = $this->_enviroments->get('mysql')->get('params'); $db = new Zend_Db_Adapter_Pdo_Mysql($mySqlDbParams); Zend_Registry::set('db_adapter', $db); Zend_Db_Table_Abstract::setDefaultAdapter($db); $this->_db = $db; } protected function _initLogging() { $logger = new Zend_Log(); /**** FIREBUG DEBUG LOG ****/ // $logger->addWriter(new Zend_Log_Writer_Firebug()); /****************************/ /**** GENERAL LOG ****/ $stream = @fopen(APPLICATION_PATH . '/../log/log.txt', 'a', false); if (!$stream) { throw new Exception('Failed to open stream of log file'); } $writer = new Zend_Log_Writer_Stream($stream); $logger->addWriter($writer); Zend_Registry::set('log', $logger); /****************************/ /**** MT LOG *** $logger_mt = new Zend_Log(); $stream_mt = @fopen(APPLICATION_PATH . '/../log/log_mt.txt', 'a', false); if (!$stream_mt) { throw new Exception('Failed to open stream of mt log file'); } $writer_mt = new Zend_Log_Writer_Stream($stream_mt); $logger_mt->addWriter($writer_mt); Zend_Registry::set('log_mt', $logger_mt); /****************************/ /*** ERROR DB LOG ***/ $columnMapping = array('lvl' => 'priority', 'msg' => 'message', 'url' => 'url', 'trace' => 'trace', 'params' => 'params', 'section' => 'section','db_name'=> 'db_name','username' => 'username', 'token'=>'token'); $error_writer = new Zend_Log_Writer_Db($this->_db, 'error_log', $columnMapping); $error_logger = new Zend_Log($error_writer); Zend_Registry::set('error_log', $error_logger); /****************************/ $this->_logger = $logger; } public function _initPersonalRouter() { $router = $this->_frontController->getRouter(); $router->addRoute( 'sitemap', new Zend_Controller_Router_Route('sitemap', array( 'module' => 'default', 'controller' => 'index', 'action' => 'sitemap' ) ) ); $router->addRoute( 'it', new Zend_Controller_Router_Route('it/:action/*', array( 'module' => 'default', 'controller' => 'index', 'action' => 'index' ) ) ); $router->addRoute( 'en', new Zend_Controller_Router_Route('en/:action/*', array( 'module' => 'default', 'controller' => 'index', 'action' => 'index' ) ) ); $router->addRoute( 'language', new Zend_Controller_Router_Route('/lang/:lang', array( 'module' => 'default', 'controller' => 'index', 'action' => 'index', 'lang' => ':lang' ) ) ); $router->addRoute( 'offline', new Zend_Controller_Router_Route('/offline', array( 'controller' => 'index', 'action' => 'offline' ) ) ); $router->addRoute( 'filterpager', new Zend_Controller_Router_Route('filter/:module/:action/:page/:count/*', array( 'module' => 'admin', 'controller' => 'index' ) ) ); $router->addRoute( 'v1_login', new Zend_Controller_Router_Route('v1/login', array( 'module' => 'auth', 'controller' => 'index', 'action' => 'post' ) ) ); /*********************************************************/ } }