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 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
|
<?php #coding: utf-8
// Step 1: APPLICATION CONSTANTS - Set the constants to use in this application.
// These constants are accessible throughout the application, even in ini
// files. We optionally set APPLICATION_PATH here in case our entry point
// isn't index.php (e.g., if required from our test suite or a script).
require_once 'constant.inc.php';
/**
* bootstrap ancêtre
* @todo à partir de ZF 1.10, faire hériter de Zend_Application_Bootstrap_Bootstrap
* @package exposehome
* @subpackage kernel
* @category bootstrap
* @author ECAROT
*
*/
abstract class Bootstrap
{
/**
* @var Zend_Controller_Front
*/
protected static $_frontController = null;
/**
* @var Zend_Registry
*/
protected static $_registry = null;
/**
* mise en place d'un système de cache
* @access private
*/
protected static function _setupCache()
{
/* if (! is_dir(GRC_TEMP_DIR)) {
mkdir(GRC_TEMP_DIR);
}
self::$_registry->set('cache', $cache);*/
}
/**
* Set up autoloading
*/
static protected function _autoload()
{
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->setFallbackAutoloader(true);
//Configure l'autoload pour inclure le module portail_citoyen et le module portail_accueil
new Zend_Application_Module_Autoloader(
array(
'namespace' => 'Portaildta_',
'basePath' => dirname(__FILE__) . '/modules/portaildta',
'resourceTypes' => array(
'library' => array(
'path' => 'library/',
'namespace' => 'Library'
),
'models' => array(
'path' => 'models/',
'namespace' => 'Model' /* sans 's' */
)
)
)
);
}
/**
* @param string $config_file_path
* @param string $section
* @access private
* @return Zend_Config_Ini
*/
protected static function _setupConfig($configFilePath, $section)
{
// CONFIGURATION - Setup the configuration object
// The Zend_Config_Ini component will parse the ini file, and resolve all of
// the values for the given section. Here we will be using the section name
// that corresponds to the APP's Environment
return new Zend_Config_Ini($configFilePath, $section);
}
/**
*
*/
/*protected static function _setupDatabase()
{
$db = Zend_Db::factory(Zend_Registry::get('configuration')->database);
Zend_Db_Table::setDefaultAdapter($db);
//$db = Zend_Db::factory($configuration->database);
//Zend_Db_Table_Abstract::setDefaultAdapter($db);
//self::$_registry->set('dbAdapter', $db);
}
*/
/**
* mise en place de la "ZFDebug toolbar"
*/
protected static function _setupDebug()
{
// seulement si on est en mode "development"
if (APPLICATION_ENV != 'development') {
return;
}
// et seulement si on n'est pas sous IE
// (car message d'erreur javascript si on est sous IE)
$req = new Zend_Controller_Request_Http();
$ua = $req->getServer('HTTP_USER_AGENT');
unset($req);
// NB : possible d'utiliser $browser = get_browser(null, true); mais nécessite un browscap.ini
if ((strpos($ua, 'Chrome') === false)
and (strpos($ua, 'Firefox') === false)
and (strpos($ua, 'Opera') === false)) {
return;
}
// toutes les conditions sont réunies, mise en place de la toolbar
$options = array(
'jquery_path' => '/js/jquery.js',
'plugins' => array(
'Variables',
'Html',
/*'Database' => array('adapter' => array('standard' => $db)),*/
'File' => array('basePath' => APPLICATION_PATH),
'Memory',
'Time',
'Registry',
/*'Cache' => array('backend' => $cache->getBackend()), */
'Exception'
)
);
$debugBar = new ZFDebug_Controller_Plugin_Debug($options);
self::$_frontController->registerPlugin($debugBar);
}
/**
* démarrage du MVC
* @param $configuration Zend_Config_Ini
* @access private
*/
protected static function _setupLayout($configuration)
{
//$layout_path['pluginClass'] = 'WinWinweb_Layout_Controller_Plugin_Layout';
Zend_Layout::startMvc($configuration);
}
/**
* définit le système de log
* @param string $file
*/
protected static function _setupLogger($file)
{
$logger = new Zend_Log();
// pour déraciner le log (écrire nulle part):
//$logger->addWriter(new Zend_Log_Writer_Null());
//$logger->addWriter(new Zend_Log_Writer_Firebug());
$logger->addWriter(new Zend_Log_Writer_Stream($file));
// choix du niveau de debuggage
$logLevel = intval(Zend_Registry::get('configuration')->logLevel);
$logger->addFilter(new Zend_Log_Filter_Priority($logLevel));
/*
EMERG 0 : Urgence : le système est inutilisable
ALERT 1 : Alerte: une mesure corrective doit être prise immédiatement
CRIT 2 : Critique : états critiques
ERR 3 : Erreur: états d'erreur
WARN 4 : Avertissement: états d'avertissement
NOTICE 5 : Notice: normal mais état significatif
INFO 6 : Information: messages d'informations
DEBUG 7 : Debug: messages de déboguages
*/
//$log->setEventItem('Memory used', memory_get_usage());
self::$_registry->set('logger', $logger);
unset($logger);
}
/**
* mise en place de l'environnement nécessaire à l'exécution
* @access private
*/
protected static function _setupRegistry()
{
self::$_registry = Zend_Registry::getInstance();
}
/**
* mise en place des routes
* @access private
*/
protected static function _setupRoute()
{
/* @var $router Zend_Controller_Router_Rewrite */
$router = self::$_frontController->getRouter();
}
} |