enrichissement/application/Bootstrap.php

101 lines
2.8 KiB
PHP
Raw Normal View History

2012-01-13 14:35:11 +01:00
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
2013-01-28 18:31:29 +01:00
protected function _initConfig()
{
$config = new Zend_Config($this->getOptions());
Zend_Registry::set('config', $config);
return $config;
}
//Initialisation global des paramètres de vue
2012-01-13 14:35:11 +01:00
protected function _initViewSettings()
{
$this->bootstrap('view');
2013-10-29 07:54:05 +01:00
2012-01-13 14:35:11 +01:00
$view = $this->getResource('view');
$view->setEncoding('UTF-8');
2013-10-29 07:54:05 +01:00
$view->doctype('HTML5');
2012-01-13 14:35:11 +01:00
$view->headMeta()
2013-10-29 07:54:05 +01:00
->appendHttpEquiv('viewport', 'width=device-width, initial-scale=1.0')
2012-01-13 14:35:11 +01:00
->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8')
2013-10-29 07:54:05 +01:00
->appendHttpEquiv('Content-Language', 'fr-FR');
2013-01-25 17:03:09 +01:00
2012-01-15 18:43:37 +01:00
$view->headLink()
2013-12-17 10:56:59 +01:00
->appendStylesheet('/libs/bootstrap-v3.0.3/css/bootstrap.min.css', 'all');
2013-01-25 17:03:09 +01:00
2012-01-15 18:43:37 +01:00
$view->headScript()
2013-10-29 07:54:05 +01:00
->appendFile('/libs/html5shiv.js', 'text/javascript', array('conditional' => 'lt IE 9'))
->appendFile('/libs/respond.min.js', 'text/javascript', array('conditional' => 'lt IE 9'));
$view->inlineScript()
->appendFile('/libs/jquery-2.0.3.min.js', 'text/javascript')
2013-12-17 10:56:59 +01:00
->appendFile('/libs/bootstrap-v3.0.3/js/bootstrap.min.js', 'text/javascript')
2013-10-29 07:54:05 +01:00
->appendFile('/libs/ui-1.10.3/jquery-ui.min.js', 'text/javascript')
2013-10-29 11:25:57 +01:00
->appendFile('/themes/default/js/enrichissement.js', 'text/javascript');
2012-01-19 16:25:47 +01:00
2012-01-15 18:43:37 +01:00
$view->headTitle()->setSeparator(' - ');
2013-01-25 17:03:09 +01:00
2012-01-13 14:35:11 +01:00
$view->headTitle('Enrichissement de fichier');
}
protected function _initLogging()
{
2012-11-21 15:21:54 +01:00
//Firebug
$writer = new Zend_Log_Writer_Firebug();
if(APPLICATION_ENV=='production') {
$writer->setEnabled(false);
}
$logger = new Zend_Log($writer);
Zend_Registry::set('firebug', $logger);
2012-01-13 14:35:11 +01:00
}
2013-01-25 17:03:09 +01:00
2013-10-29 07:54:05 +01:00
protected function _initDb()
{
$c = new Zend_Config($this->getOptions());
try {
$db = Zend_Db::factory($c->resources->db);
$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);
}
return $db;
}
protected function _initCache()
{
if ( APPLICATION_ENV!='development' ) {
//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);
}
2012-11-21 15:21:54 +01:00
}
2012-01-13 14:35:11 +01:00
}