1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
private $_acl = null;
private $_auth = null;
private $_role = null;
protected function _initView()
{
error_reporting(E_ERROR | E_WARNING | E_PARSE);
$view = new Zend_View();
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
'ViewRenderer'
);
$viewRenderer->setView($view);
return $view;
}
protected function _initAutoload()
{
Zend_Controller_Action_HelperBroker::addPrefix('Sheraf_Controller_Action_Helpers');
new Zend_Application_Module_Autoloader(array(
'namespace' => 'Sheraf',
'basePath' => APPLICATION_PATH,
));
}
protected function _initCache()
{
$aFrontendConf = array ('lifetime' => 345600, 'automatic_seralization' => true);
$aBackendConf = array ('cache_dir' => APPLICATION_PATH . '/cache/');
$oCache = Zend_Cache::factory('Core','File',$aFrontendConf,$aBackendConf);
$oCache->setOption('automatic_serialization', true);
Zend_Locale::setCache($oCache);
Zend_Translate::setCache($oCache);
}
protected function _initSession()
{
Zend_Registry::set('langue', $session = new Zend_Session_Namespace('langue'));
Zend_Registry::set('session', $session = new Zend_Session_Namespace('session'));
Zend_Registry::set('inscription', $session = new Zend_Session_Namespace('inscription'));
Zend_Controller_Front::getInstance()->registerPlugin(new Sheraf_Controller_Plugin_Session());
}
public function _initTranslate()
{
$langue = Zend_Registry::get('langue');
if(is_null($langue->data))
{
$locale = new Zend_Locale('fr');
}
else
{
$locale = $langue->data;
}
Zend_Registry::set('Zend_Locale', $locale);
$translate = new Zend_Translate('Gettext', APPLICATION_PATH . '/languages/lang_'.$locale.'.mo', $locale, array('disableNotices' => true,'logUntranslated' => false));
Zend_Registry::set('Zend_Translate', $translate);
$translateForm = new Zend_Translate('array', APPLICATION_PATH . '/languages/validate.php');
$translateForm->setLocale($locale);
Zend_Form::setDefaultTranslator($translate);
}
protected function _initAcl()
{
$this->_acl = new Sheraf_Acl(APPLICATION_PATH . '/configs/acl.ini');
Zend_Registry::set('acl', $this->_acl);
$this->_auth = Zend_Auth::getInstance();
Zend_Registry::set('auth', $this->_auth);
if ($this->_auth->hasIdentity()) $this->_role = $this->_auth->getStorage()->read()->Role;
else $this->_role = 'Guest';
Zend_Registry::set('role', $this->_role);
Zend_Controller_Front::getInstance()->registerPlugin(new Sheraf_Controller_Plugin_Auth($this->_acl, $this->_auth));
}
protected function _initDb ()
{
if ($this->hasPluginResource('db')) {
$resource = $this->getPluginResource('db');
$db = $resource->init();
$db->query("SET NAMES 'UTF8'");
return $db;
}
}
} |
Partager