152 lines
4.1 KiB
PHP
152 lines
4.1 KiB
PHP
<?php
|
|
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|
{
|
|
protected function _initConfig()
|
|
{
|
|
$config = new Zend_Config($this->getOptions());
|
|
Zend_Registry::set('config', $config);
|
|
return $config;
|
|
}
|
|
|
|
//Initialisation global des paramètres de vue
|
|
protected function _initViewSettings()
|
|
{
|
|
$this->bootstrap('view');
|
|
$view = $this->getResource('view');
|
|
$view->setEncoding('UTF-8');
|
|
$view->headTitle()->setSeparator(' - ');
|
|
$view->headTitle('Extranet Scores & Décisions');
|
|
}
|
|
|
|
protected function _initRouter()
|
|
{
|
|
$this->bootstrap('frontController');
|
|
$front = $this->getResource('frontController');
|
|
$router = $front->getRouter();
|
|
$localauthRoute = new Zend_Controller_Router_Route('localauth/', array(
|
|
'controller' => 'user',
|
|
'action' => 'login'
|
|
));
|
|
$fichierRoute = new Zend_Controller_Router_Route('fichier/:action/:fichier', array(
|
|
'controller' => 'fichier',
|
|
'fichier' => '',
|
|
));
|
|
$printRoute = new Zend_Controller_Router_Route('editer/:action/:fichier', array(
|
|
'controller' => 'print',
|
|
'fichier' => '',
|
|
));
|
|
|
|
$router->addRoute('localauth', $localauthRoute);
|
|
$router->addRoute('fichier', $fichierRoute);
|
|
$router->addRoute('print', $printRoute);
|
|
return $router;
|
|
}
|
|
|
|
protected function _initTranslate()
|
|
{
|
|
$registry = Zend_Registry::getInstance();
|
|
|
|
$translate = new Zend_Translate(
|
|
array(
|
|
'adapter' => 'gettext',
|
|
'content' => APPLICATION_PATH . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR . 'fr.mo',
|
|
'locale' => 'fr',
|
|
'scan' => Zend_Translate::LOCALE_DIRECTORY
|
|
)
|
|
);
|
|
|
|
$translate->addTranslation(
|
|
array(
|
|
'content' => APPLICATION_PATH . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR . 'en.mo',
|
|
'locale' => 'en',
|
|
'scan' => Zend_Translate::LOCALE_DIRECTORY
|
|
)
|
|
);
|
|
|
|
$registry->set('Zend_Translate', $translate);
|
|
return $registry;
|
|
}
|
|
|
|
protected function _initLogging()
|
|
{
|
|
//Firebug
|
|
$writer = new Zend_Log_Writer_Firebug();
|
|
if(APPLICATION_ENV=='production') {
|
|
$writer->setEnabled(false);
|
|
}
|
|
$logger = new Zend_Log($writer);
|
|
Zend_Registry::set('firebug', $logger);
|
|
|
|
//ChromePHP - a voir comment désactiver
|
|
require_once 'Vendors/ChromePHP/ChromePhp.php';
|
|
|
|
//Application Logger en Production
|
|
$AppLogger = new Zend_Log();
|
|
if (APPLICATION_ENV == 'production')
|
|
{
|
|
$Mail = new Zend_Mail();
|
|
$Mail->setFrom('production@scores-decisions.com')
|
|
->addTo('supportdev@scores-decisions.com');
|
|
$AppMailWriter = new Zend_Log_Writer_Mail($Mail);
|
|
$AppMailWriter->setSubjectPrependText('ERREUR');
|
|
$AppMailWriter->addFilter(Zend_Log::ERR);
|
|
$AppLogger->addWriter($AppMailWriter);
|
|
}
|
|
/* Remove as it's not use
|
|
$c = Zend_Registry::get('config');
|
|
$path = $c->profil->path->data.'/log';
|
|
$AppFileWriter = new Zend_Log_Writer_Stream($path.'/application.log');
|
|
$AppFileWriter->addFilter(Zend_Log::ERR);
|
|
$AppLogger->addWriter($AppFileWriter);
|
|
*/
|
|
Zend_Registry::set('log', $AppLogger);
|
|
}
|
|
|
|
protected function _initDb()
|
|
{
|
|
$c = Zend_Registry::get('config');
|
|
try {
|
|
$db = Zend_Db::factory($c->profil->db->sdv1);
|
|
$db->getConnection();
|
|
} catch ( Exception $e ) {
|
|
if (APPLICATION_ENV == 'development') {
|
|
echo '<pre>'; print_r($e); echo '</pre>';
|
|
} else {
|
|
echo "Le service rencontre actuellement un problème technique.";
|
|
}
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* Set the default adapter to use with all model
|
|
*/
|
|
Zend_Db_Table::setDefaultAdapter($db);
|
|
|
|
/**
|
|
* Set Firebug Database profiler
|
|
*/
|
|
if (APPLICATION_ENV == 'development') {
|
|
$profiler = new Zend_Db_Profiler_Firebug('All DB Queries');
|
|
$profiler->setEnabled(true);
|
|
$db->setProfiler($profiler);
|
|
}
|
|
}
|
|
|
|
protected function _initCache()
|
|
{
|
|
//MetadataCache pour la base de données
|
|
$frontendOptions = array(
|
|
'lifetime' => 28800,
|
|
'automatic_serialization' => true
|
|
);
|
|
$backendOptions = array();
|
|
$cache = Zend_Cache::factory('Core','Apc', $frontendOptions, $backendOptions);
|
|
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
|
|
|
|
//Cache pour les données de la base à stocker
|
|
|
|
}
|
|
|
|
}
|
|
|