odea/application/Bootstrap.php

99 lines
2.9 KiB
PHP
Raw Permalink Normal View History

2012-02-02 18:29:14 +01:00
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
2012-12-06 17:51:14 +01:00
protected function _initConfig()
{
$config = new Zend_Config($this->getOptions());
Zend_Registry::set('config', $config);
return $config;
}
2012-12-06 17:51:14 +01:00
protected function _initViewSettings()
2012-02-02 18:29:14 +01:00
{
$this->bootstrap('view');
2012-05-01 11:42:19 +02:00
2013-12-02 08:19:35 +01:00
$view = $this->getResource('view');
2012-02-02 18:29:14 +01:00
$view->setEncoding('UTF-8');
2012-12-06 17:51:14 +01:00
$view->doctype('HTML5');
2013-12-02 08:19:35 +01:00
$pathStyle = '/themes/default/styles';
$pathScript = '/themes/default/scripts';
2012-05-01 11:42:19 +02:00
2012-02-02 18:29:14 +01:00
$view->headMeta()
2014-08-20 21:20:25 +02:00
->appendName('viewport', 'width=device-width, initial-scale=1.0')
->appendHttpEquiv('X-UA-Compatible', 'IE=edge')
->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8')
->appendHttpEquiv('Content-Language', 'fr-FR');
2012-05-01 11:42:19 +02:00
$view->headLink()
2015-03-18 16:47:04 +01:00
->appendStylesheet('/libs/bootstrap-3.3.4/css/bootstrap.min.css', 'all')
2015-03-18 16:52:00 +01:00
->appendStylesheet('/libs/ui-1.11.3/themes/smoothness/jquery-ui.min.css', 'all')
2012-05-01 11:42:19 +02:00
->appendStylesheet($pathStyle.'/main.css', 'all');
2012-02-02 18:29:14 +01:00
$view->headScript()
2014-08-08 12:20:42 +02:00
->appendFile('/libs/html5shiv.min.js', 'text/javascript', array('conditional' => 'lt IE 9'))
2014-06-17 20:52:17 +02:00
->appendFile('/libs/respond.min.js', 'text/javascript', array('conditional' => 'lt IE 9'))
2015-01-22 17:32:27 +01:00
->appendFile('/libs/jquery-2.1.3.min.js', 'text/javascript')
2015-03-18 16:47:04 +01:00
->appendFile('/libs/bootstrap-3.3.4/js/bootstrap.min.js', 'text/javascript')
2015-03-27 14:00:14 +01:00
->appendFile('/libs/ui-1.11.3/jquery-ui.min.js', 'text/javascript');
2012-05-01 11:42:19 +02:00
2012-02-15 11:40:34 +01:00
$view->headTitle()->setSeparator(' - ');
2012-02-02 18:29:14 +01:00
$view->headTitle('Odea');
}
2012-05-01 11:42:19 +02:00
2012-02-02 18:29:14 +01:00
protected function _initLogging()
{
2012-07-30 09:48:19 +02:00
//Firebug
2012-02-02 18:29:14 +01:00
$writer = new Zend_Log_Writer_Firebug();
2012-07-30 09:48:19 +02:00
if(APPLICATION_ENV=='production') {
$writer->setEnabled(false);
}
2012-02-02 18:29:14 +01:00
$logger = new Zend_Log($writer);
Zend_Registry::set('firebug', $logger);
}
2012-05-01 11:42:19 +02:00
2012-02-02 18:29:14 +01:00
protected function _initDb()
{
2012-12-06 17:51:14 +01:00
$c = new Zend_Config($this->getOptions());
try {
$db = Zend_Db::factory($c->profil->db->metier);
2012-02-02 18:29:14 +01:00
Zend_Db_Table::setDefaultAdapter ($db);
} catch ( Exception $e ) {
2012-07-30 09:48:19 +02:00
if (APPLICATION_ENV == 'development') {
print_r($e);
} else {
2012-12-06 17:51:14 +01:00
echo "Le service est actuellement indisponible.";
2012-07-30 09:48:19 +02:00
}
exit;
}
/**
* Set the default adapter to use with all model
*/
Zend_Db_Table::setDefaultAdapter($db);
2012-07-30 09:48:19 +02:00
/**
* Set Firebug Database profiler
*/
if (APPLICATION_ENV == 'development') {
$profiler = new Zend_Db_Profiler_Firebug('All DB Queries');
$profiler->setEnabled(true);
$db->setProfiler($profiler);
2012-02-02 18:29:14 +01:00
}
}
2012-05-01 11:42:19 +02:00
protected function _initCache()
{
//MetadataCache pour la base de données
$frontendOptions = array(
'lifetime' => 14400,
'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
}
2012-05-03 21:06:09 +02:00
}