Esempio n. 1
0
 /**
  * Initialization Autoloader, Session, Auth, Locale,
  *
  * @return void
  */
 protected function _initAutoload()
 {
     $_startTime = microtime(1);
     //------- Define the autoloader parameters ------------
     // Define basic prefix and the base path to the resources for the default module
     $autoloader = new Zend_Application_Module_Autoloader(array('namespace' => 'Default', 'basePath' => dirname(__FILE__)));
     // Add resource loader for admin module
     $resourceLoader = new Zend_Loader_Autoloader_Resource(array('basePath' => APPLICATION_PATH . '/modules/admin', 'namespace' => 'Admin', 'resourceTypes' => array('form' => array('path' => 'forms/', 'namespace' => 'Form'))));
     //------- Create an application directory ------------
     Default_Plugin_SysBox::createAppPaths();
     //--------- Remember the configuration to register ---------
     $config = $this->_options;
     Zend_Registry::set('config', $config);
     //------- Copy users upload dir ------------
     Default_Plugin_SysBox::copyUsersUploadDir();
     //----------------- Set session ---------------
     // Start session
     Zend_Session::start();
     // Install option in order to prevent re-execution
     // Zend_Session::start() when calling (new Zend_Session_Namespace)
     Zend_Session::setOptions(array('strict' => true));
     // Obtain an instance session object for the appropriate namespace
     $Zend_Auth = new Zend_Session_Namespace('Zend_Auth');
     // Save to Registry
     Zend_Registry::set("Zend_Auth", $Zend_Auth);
     // Add a new type of resource controllers for plug-ins
     //$autoloader->addResourceType('cplugins', 'controllers/plugins', 'Controller_Plugins');
     //---- Configuring user authentication -----
     $auth = Zend_Auth::getInstance();
     $auth->setStorage(new Zend_Auth_Storage_Session());
     //------ Registering plugins ---------
     // Start 'FrontController'
     $this->bootstrap('FrontController');
     $front = Zend_Controller_Front::getInstance();
     // The plugin checks the user's access to resources
     $front->registerPlugin(new Default_Plugin_AclManager($auth));
     //------------ Configure language translation -------------
     $translate = new Zend_Translate('array', APPLICATION_PATH . '/languages/ru/My_Messages.php', 'ru');
     $translate->addTranslation(APPLICATION_PATH . '/languages/ru/Zend_Validate.php', 'ru');
     $translate->addTranslation(APPLICATION_PATH . '/languages/ru/My_Validate.php', 'ru');
     $translate->addTranslation(APPLICATION_PATH . '/languages/uk/My_Messages.php', 'uk');
     $translate->addTranslation(APPLICATION_PATH . '/languages/uk/Zend_Validate.php', 'uk');
     $translate->addTranslation(APPLICATION_PATH . '/languages/uk/My_Validate.php', 'uk');
     $translate->addTranslation(APPLICATION_PATH . '/languages/en/My_Messages.php', 'en');
     $translate->addTranslation(APPLICATION_PATH . '/languages/en/Zend_Validate.php', 'en');
     $translate->addTranslation(APPLICATION_PATH . '/languages/en/My_Validate.php', 'en');
     //------------ Configure language translation modules -------------
     $translate->addTranslation(APPLICATION_PATH . '/modules/hr/languages/ru/My_Messages.php', 'ru');
     $translate->addTranslation(APPLICATION_PATH . '/modules/hr/languages/uk/My_Messages.php', 'uk');
     $translate->addTranslation(APPLICATION_PATH . '/modules/hr/languages/en/My_Messages.php', 'en');
     // Set the default translation language
     if (!isset($Zend_Auth->translate_locale)) {
         $Zend_Auth->translate_locale = $config['user']['locale'];
     } else {
         $locale = $Zend_Auth->translate_locale;
         $newLocal = Default_Plugin_SysBox::isUpdateTranslateLocale($locale);
         if (!$newLocal === FALSE) {
             $Zend_Auth->translate_locale = $newLocal;
         }
     }
     $translate->setLocale($Zend_Auth->translate_locale);
     // Save to Registry
     Zend_Registry::set('Zend_Translate', $translate);
     //------------ Configure site localization -------------
     // Get type localization
     $paramLocal = Default_Plugin_SysBox::getLocalParam($Zend_Auth->translate_locale);
     // Set localization
     $locale = new Zend_Locale($paramLocal);
     // Set timezone
     date_default_timezone_set($config['user']['timezone']);
     // Save to Registry
     Zend_Registry::set('Zend_Locale', $locale);
     //------------ Set the color scheme of the site -------------
     if (!isset($Zend_Auth->user_scheme)) {
         $Zend_Auth->user_scheme = $config['user']['scheme'];
     } else {
         $scheme = $Zend_Auth->user_scheme;
         $newScheme = Default_Plugin_SysBox::getUserScheme($scheme);
         if ($newScheme !== $scheme) {
             $Zend_Auth->user_scheme = $newScheme;
         }
     }
     //---- Defining script execution time ----
     $infoProfiler = Default_Plugin_SysBox::Translate("Время выполнения") . " Bootstrap_initAutoload(): ";
     Default_Plugin_SysBox::profilerTime2Registry($_startTime, $infoProfiler);
     return $autoloader;
 }