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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected $_front;
protected $_view;
protected function _initDoctype()
{
$this->bootstrap('view');
$view = $this->getResource('view');
$view->doctype('XHTML1_STRICT');
}
protected function _initDefaultNamespace()
{
$this->bootstrap('frontcontroller');
$front = $this->getResource('frontcontroller');
$defaultModule = $front->getControllerDirectory($front->getDefaultModule());
new Zend_Application_Module_Autoloader(array(
'namespace' => '',
'basePath' => APPLICATION_PATH . $defaultModule,
));
}
protected function _initSession()
{
}
protected function _initApplication()
{
$this->bootstrap('FrontController');
$front = $this->getResource('FrontController');
$front->throwExceptions(false);
$front->addModuleDirectory(APPLICATION_PATH . '/modules');
}
protected function _initAutoload()
{
$this->bootstrap("frontController");
$front = $this->frontController;
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->setFallbackAutoloader(true);
$modules = $front->getControllerDirectory();
$default = $front->getDefaultModule();
foreach (array_keys($modules) as $module) {
if ($module === $default) {
continue;
}
$autoloader->pushAutoloader(new Zend_Application_Module_Autoloader(array(
"namespace" => ucwords($module),
"basePath" => $front->getModuleDirectory($module),
)));
}
$autoloader->registerNamespace('Utility_');
$autoloader->suppressNotFoundWarnings(true);
return $autoloader;
}
protected function _initViewController()
{
$this->bootstrap('view');
$this->bootstrap('FrontController');
$this->_view = $this->getResource('view');
$this->_front = $this->getResource('FrontController');
}
protected function _initLayout(){
$layout = explode('/', $_SERVER['REQUEST_URI']);
if(in_array('admin', $layout)){
$layout_dir = 'admin';
}else{
$layout_dir = 'default';
}
Zend_Layout::startMvc(array('layoutPath'=> APPLICATION_PATH . "/modules/$layout_dir/layouts"));
$helperPath = APPLICATION_PATH . "/modules/$layout_dir/views/helpers";
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->setView( $this->_view );
$this->_view->addHelperPath($helperPath, 'Helper_');
}
protected function _initAuth()
{
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
//$username = utf8_encode($auth->getIdentity()->lastNameUser) . ' ' . strtoupper( substr( utf8_encode($auth->getIdentity()->firstNameUser), 0, 1 ) ) . '.';
//$logoutLink = $helperUrl->url( array ('action' => 'deconnexion', 'controller' => 'index' ) );
//die("connecte");
} else {
//die("deconnecte");
}
}
public function _initAcl()
{
$this->bootstrap("frontController");
$front = $this->frontController;
$acl = new Admin_Model_Acl( APPLICATION_PATH . '/configs/acl.ini' ) ;
$front->registerPlugin( new Admin_Model_Auth( $acl ) ) ;
}
/**
* @return Zend_Navigation
* + init the session language to choose the right xml
*/
protected function _initNavigation()
{
if(!isset($_SESSION['lang']) OR empty($_SESSION['lang'])) $_SESSION['lang'] = 'fr';
if($_SESSION['lang'] == 'en')
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation-en.xml', 'nav');
elseif($_SESSION['lang'] == 'es')
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation-es.xml', 'nav');
else
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');
$navigation = new Zend_Navigation($config);
//Zend_Registry::set('Zend_Navigation', $navigation);
$this->_view->navigation($navigation);
/**
* background site management
*/
$iNbrBg = 6;
if(!isset($_SESSION['bg']))
$_SESSION['bg'] = rand(1,$iNbrBg);
}
} |
Partager