extranet/application/Bootstrap.php

159 lines
5.3 KiB
PHP
Raw Normal View History

2010-11-22 13:50:12 +01:00
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
2010-11-22 13:50:12 +01:00
//Initialisation global des paramètres de vue
protected function _initViewSettings()
{
2011-01-11 09:43:13 +01:00
$this->bootstrap('view');
2010-11-22 13:50:12 +01:00
$view = $this->getResource('view');
/*
* Si on détecte un périphérique mobile alors on charge
* les bons scripts
$theme = 'mobile';
$path = realpath(APPLICATION_PATH.'/views/'.$theme);
$view = new Zend_View();
$view->addBasePath($path);
*/
2011-01-05 10:59:49 +01:00
$theme = 'default';
2011-04-01 14:14:40 +02:00
$pathStyle = '/themes/'.$theme.'/styles';
$pathScript = '/themes/'.$theme.'/scripts';
2010-11-22 13:50:12 +01:00
$view->setEncoding('UTF-8');
$view->doctype('XHTML1_STRICT');
$view->headMeta()
->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8')
->appendHttpEquiv('Content-Language', 'fr-FR');
2011-09-13 10:58:41 +02:00
$view->headLink()
->headLink(array('rel' => 'favicon', 'type' => 'image/png', 'href' => '/favicon.png'));
2011-09-22 15:15:24 +02:00
$view->headLink()
->headLink(array('rel' => 'shortcut icon', 'type' => 'image/x-icon', 'href' => '/favicon.ico'));
2011-04-01 14:14:40 +02:00
$view->headLink()
->appendStylesheet($pathStyle.'/reset.css', 'all')
->appendStylesheet($pathStyle.'/main.css', 'all')
->appendStylesheet($pathStyle.'/menu.css', 'all')
->appendStylesheet($pathStyle.'/ie6.css', 'all', 'lte IE 6')
2011-08-30 09:11:39 +02:00
->appendStylesheet($pathStyle.'/jquery-ui.css', 'all')
->appendStylesheet($pathStyle.'/jquery.qtip.css', 'all');
$useJsNotMinify = false;
$pathScriptPlus = '';
if ($useJsNotMinify) {
$pathScriptPlus = '/notminify';
}
$view->headScript()
->appendFile($pathScript.$pathScriptPlus.'/jquery.js', 'text/javascript')
->appendFile($pathScript.$pathScriptPlus.'/jquery.bgiframe.js', 'text/javascript')
->appendFile($pathScript.$pathScriptPlus.'/jquery-ui.js', 'text/javascript')
->appendFile($pathScript.$pathScriptPlus.'/jquery-ui-i18n.js', 'text/javascript')
->appendFile($pathScript.$pathScriptPlus.'/jquery.qtip.js', 'text/javascript')
->appendFile($pathScript.'/growl.js', 'text/javascript')
->appendFile($pathScript.'/script.js', 'text/javascript');
2011-01-07 18:16:07 +01:00
$view->headTitle()->setSeparator(' - ');
2010-11-22 13:50:12 +01:00
$view->headTitle('Extranet Scores & Décisions');
}
2011-12-02 10:32:20 +01:00
2011-01-05 10:59:49 +01:00
protected function _initRouter()
{
$this->bootstrap('frontController');
$front = $this->getResource('frontController');
$router = $front->getRouter();
2011-04-28 12:24:53 +02:00
$localauthRoute = new Zend_Controller_Router_Route('localauth/', array(
'controller' => 'user',
'action' => 'login'
2011-01-05 10:59:49 +01:00
));
$fichierRoute = new Zend_Controller_Router_Route('fichier/:action/:fichier', array(
2011-04-28 12:24:53 +02:00
'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);
2011-01-05 10:59:49 +01:00
return $router;
}
protected function _initLogging()
{
2011-09-27 11:13:13 +02:00
//Firebug
2011-01-07 18:16:07 +01:00
$writer = new Zend_Log_Writer_Firebug();
2011-09-27 11:13:13 +02:00
if(APPLICATION_ENV=='production') {
$writer->setEnabled(false);
}
2011-01-07 18:16:07 +01:00
$logger = new Zend_Log($writer);
Zend_Registry::set('firebug', $logger);
2011-09-27 11:13:13 +02:00
//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);
}
$configuration = Zend_Registry::get('configuration');
$path = $configuration->path->data.'/'.$configuration->path->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 _initZFDebug()
{
2011-09-27 11:13:13 +02:00
$zfdebug = false; //@todo : Mettre dans la configuration
if (APPLICATION_ENV != 'production' && $zfdebug == true)
{
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('ZFDebug');
$options = array(
'plugins' => array(
'Variables',
'File' => array('base_path' => APPLICATION_PATH . '../' ),
'Memory',
'Time',
'Exception')
);
# Instantiate the database adapter and setup the plugin.
# Alternatively just add the plugin like above and rely on the autodiscovery feature.
if ($this->hasPluginResource('db')) {
$this->bootstrap('db');
$db = $this->getPluginResource('db')->getDbAdapter();
$options['plugins']['Database']['adapter'] = $db;
}
# Setup the cache plugin
if ($this->hasPluginResource('cache')) {
$this->bootstrap('cache');
$cache = $this->getPluginResource('cache')->getDbAdapter();
$options['plugins']['Cache']['backend'] = $cache->getBackend();
2011-09-27 11:13:13 +02:00
}
$debug = new ZFDebug_Controller_Plugin_Debug($options);
$this->bootstrap('frontController');
$frontController = $this->getResource('frontController');
$frontController->registerPlugin($debug);
}
2011-01-07 18:16:07 +01:00
}
2011-04-28 12:24:53 +02:00
protected function _initSession()
{
Zend_Session::start();
}
2010-11-22 13:50:12 +01:00
}