2010-08-30 07:49:44 +00:00
|
|
|
<?php
|
|
|
|
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|
|
|
{
|
|
|
|
//Initialisation global des paramètres de vue
|
|
|
|
protected function _initViewSettings()
|
|
|
|
{
|
|
|
|
$this->bootstrap('view');
|
|
|
|
$view = $this->getResource('view');
|
|
|
|
$view->setEncoding('UTF-8');
|
|
|
|
$view->doctype('XHTML1_STRICT');
|
|
|
|
$view->headMeta()
|
|
|
|
->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8')
|
|
|
|
->appendHttpEquiv('Content-Language', 'fr-FR');
|
2011-02-03 17:11:26 +00:00
|
|
|
$view->headLink()
|
2010-12-13 16:54:04 +00:00
|
|
|
->appendStylesheet('/styles/reset.css', 'all')
|
2010-09-20 15:08:45 +00:00
|
|
|
->appendStylesheet('/styles/main.css', 'all');
|
2011-02-03 17:11:26 +00:00
|
|
|
$view->headScript()->appendFile('/scripts/jquery.js', 'text/javascript');
|
|
|
|
$view->headScript()->appendFile('/scripts/scripts.js', 'text/javascript');
|
2011-09-09 15:40:19 +00:00
|
|
|
$view->headTitle()->setSeparator(' - ');
|
2011-10-10 13:15:48 +00:00
|
|
|
$view->headTitle('WebService Scores & Decisions');
|
2010-08-30 07:49:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Initialisation global des paramètres de log
|
2010-09-08 13:21:57 +00:00
|
|
|
protected function _initLogging()
|
|
|
|
{
|
|
|
|
require_once 'Zend/Log.php';
|
|
|
|
require_once 'Zend/Mail.php';
|
2010-10-26 13:21:59 +00:00
|
|
|
$WsLogger = new Zend_Log();
|
2010-11-05 10:05:06 +00:00
|
|
|
$WsFileWriter = new Zend_Log_Writer_Stream(LOG_PATH.'/wsentreprise.log');
|
2010-09-14 16:36:59 +00:00
|
|
|
$WsFileWriter->addFilter(Zend_Log::INFO);
|
|
|
|
$WsLogger->addWriter($WsFileWriter);
|
2010-10-26 13:21:59 +00:00
|
|
|
if (APPLICATION_ENV == 'production')
|
|
|
|
{
|
|
|
|
$WsMail = new Zend_Mail();
|
|
|
|
$WsMail->setFrom('production@scores-decisions.com')
|
|
|
|
->addTo('mricois@scores-decisions.com');
|
|
|
|
$WsMailWriter = new Zend_Log_Writer_Mail($WsMail);
|
|
|
|
$WsMailWriter->setSubjectPrependText('ERREUR');
|
|
|
|
$WsMailWriter->addFilter(Zend_Log::ERR);
|
|
|
|
$WsLogger->addWriter($WsMailWriter);
|
|
|
|
}
|
2010-09-14 16:36:59 +00:00
|
|
|
Zend_Registry::set('WsLogger', $WsLogger);
|
2010-08-30 07:49:44 +00:00
|
|
|
}
|
|
|
|
|
2010-12-07 15:46:10 +00:00
|
|
|
protected function _initNavigation()
|
|
|
|
{
|
|
|
|
$view = $this->bootstrap('layout')->getResource('layout')->getView();
|
2011-02-08 09:27:36 +00:00
|
|
|
|
|
|
|
//@todo : gérer les versions et les clients
|
|
|
|
|
2010-12-07 15:46:10 +00:00
|
|
|
$menu = array(
|
|
|
|
array(
|
|
|
|
'label' => 'Accueil',
|
|
|
|
'controller' => 'index',
|
|
|
|
'action' => 'index',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'label' => 'Documentation',
|
|
|
|
'controller' => 'documentation',
|
|
|
|
'action' => 'index',
|
|
|
|
'pages' => array(
|
2011-02-03 17:11:26 +00:00
|
|
|
array(
|
2011-06-10 10:09:09 +00:00
|
|
|
'label' => 'Entreprise',
|
2011-02-03 17:11:26 +00:00
|
|
|
'controller' => 'documentation',
|
|
|
|
'action' => 'index',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'label' => 'Code erreurs/messages',
|
|
|
|
'controller' => 'documentation',
|
|
|
|
'action' => 'erreur',
|
|
|
|
),
|
2010-12-07 15:46:10 +00:00
|
|
|
array(
|
|
|
|
'label' => 'Exemples',
|
|
|
|
'controller' => 'documentation',
|
|
|
|
'action' => 'exemples',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2010-12-13 16:54:04 +00:00
|
|
|
array(
|
2010-12-14 10:36:48 +00:00
|
|
|
'label' => 'Démonstration',
|
2010-12-13 16:54:04 +00:00
|
|
|
'controller' => 'demo',
|
|
|
|
'action' => 'index',
|
|
|
|
),
|
2010-12-07 15:46:10 +00:00
|
|
|
);
|
|
|
|
$view->navigation(new Zend_Navigation($menu));
|
|
|
|
}
|
|
|
|
|
2010-10-26 13:21:59 +00:00
|
|
|
protected function _initDb(){}
|
2011-02-03 14:04:40 +00:00
|
|
|
|
|
|
|
protected function _initRouter()
|
|
|
|
{
|
|
|
|
$this->bootstrap('frontController');
|
|
|
|
$front = $this->getResource('frontController');
|
|
|
|
$router = $front->getRouter();
|
2011-04-26 08:52:46 +00:00
|
|
|
|
2011-10-12 12:43:49 +00:00
|
|
|
//Lire les services disponibles et créer les routes
|
|
|
|
$services = new Zend_Config_Ini('WsScore/Services.ini');
|
|
|
|
foreach( $services->toArray() as $section => $params ){
|
|
|
|
if ($params['actif']) {
|
|
|
|
$route = new Zend_Controller_Router_Route($section.'/:version', array(
|
|
|
|
'controller' => 'service',
|
|
|
|
'action' => 'index',
|
|
|
|
'service' => $section,
|
|
|
|
'version' => '',
|
|
|
|
));
|
|
|
|
$router->addRoute($section, $route);
|
|
|
|
}
|
|
|
|
}
|
2011-02-03 14:04:40 +00:00
|
|
|
|
2011-04-26 08:52:46 +00:00
|
|
|
//Route pour WS Clients
|
2011-02-07 17:02:09 +00:00
|
|
|
$route = new Zend_Controller_Router_Route('clients/:client/:version', array(
|
2011-10-10 13:15:48 +00:00
|
|
|
'controller' => 'service',
|
2011-04-26 08:52:46 +00:00
|
|
|
'action' => 'index',
|
2011-10-10 13:15:48 +00:00
|
|
|
'service' => 'clients',
|
2011-04-26 08:52:46 +00:00
|
|
|
'client' => '',
|
|
|
|
'version' => ''
|
2011-02-07 17:02:09 +00:00
|
|
|
));
|
|
|
|
$router->addRoute('client', $route);
|
2011-02-03 14:04:40 +00:00
|
|
|
|
|
|
|
return $router;
|
|
|
|
}
|
2011-08-15 19:53:03 +00:00
|
|
|
|
|
|
|
protected function _initWsDebug()
|
|
|
|
{
|
|
|
|
$autoloader = Zend_Loader_Autoloader::getInstance();
|
|
|
|
$autoloader->registerNamespace('WsDebug');
|
|
|
|
|
|
|
|
$options = array(
|
|
|
|
'plugins' => array(
|
|
|
|
'Exception',
|
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
$debug = new WsDebug_Controller_Plugin_Debug($options);
|
|
|
|
|
|
|
|
$this->bootstrap('frontController');
|
|
|
|
$frontController = $this->getResource('frontController');
|
|
|
|
$frontController->registerPlugin($debug);
|
|
|
|
}
|
2011-02-03 14:04:40 +00:00
|
|
|
|
2010-08-30 07:49:44 +00:00
|
|
|
}
|
|
|
|
|