2013-11-05 12:18:30 +01:00
|
|
|
<?php
|
|
|
|
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|
|
|
{
|
|
|
|
protected function _initConfig()
|
|
|
|
{
|
|
|
|
$config = new Zend_Config($this->getOptions());
|
|
|
|
Zend_Registry::set('config', $config);
|
|
|
|
|
2015-07-03 15:28:52 +02:00
|
|
|
define('MYSQL_HOST', $config->profil->db->metier->params->host);
|
|
|
|
define('MYSQL_USER', $config->profil->db->metier->params->username);
|
|
|
|
define('MYSQL_PASS', $config->profil->db->metier->params->password);
|
|
|
|
define('MYSQL_DEFAULT_DB', 'jo');
|
|
|
|
define('MYSQL_SQL_LOG', 'NONE');
|
|
|
|
|
2016-01-25 15:51:07 +01:00
|
|
|
define('DOC_WEB_LOCAL' , $config->profil->path->shared.'/files/');
|
2015-07-03 15:28:52 +02:00
|
|
|
define('DOC_WEB_URL' , '/fichier/');
|
2016-01-25 15:53:34 +01:00
|
|
|
define('LOG_PATH' , $config->profil->path->shared.'/log');
|
2015-07-03 15:28:52 +02:00
|
|
|
|
|
|
|
// Entreprise
|
|
|
|
define('SPHINX_ENT_HOST', $config->profil->sphinx->ent->host);
|
|
|
|
define('SPHINX_ENT_PORT', intval($config->profil->sphinx->ent->port));
|
|
|
|
define('SPHINX_ENT_VERSION', $config->profil->sphinx->ent->version);
|
|
|
|
|
|
|
|
// Dirigeants
|
|
|
|
define('SPHINX_DIR_HOST', $config->profil->sphinx->dir->host);
|
|
|
|
define('SPHINX_DIR_PORT', intval($config->profil->sphinx->dir->port));
|
|
|
|
define('SPHINX_DIR_VERSION', $config->profil->sphinx->dir->version);
|
|
|
|
|
|
|
|
// Historique
|
|
|
|
define('SPHINX_HISTO_HOST', $config->profil->sphinx->histo->host);
|
|
|
|
define('SPHINX_HISTO_PORT', intval($config->profil->sphinx->histo->port));
|
|
|
|
define('SPHINX_HISTO_VERSION', $config->profil->sphinx->histo->version);
|
|
|
|
|
|
|
|
// Actionnaire
|
|
|
|
define('SPHINX_ACT_HOST', $config->profil->sphinx->act->host);
|
|
|
|
define('SPHINX_ACT_PORT', intval($config->profil->sphinx->act->port));
|
|
|
|
define('SPHINX_ACT_VERSION', $config->profil->sphinx->act->version);
|
|
|
|
|
|
|
|
//Old
|
|
|
|
define('SPHINX_HOST', $config->profil->sphinx->ent->host);
|
|
|
|
define('SPHINX_PORT', intval($config->profil->sphinx->ent->port));
|
|
|
|
|
|
|
|
define('INFOGREFFE_DISPO_WEB', false);
|
|
|
|
define('INFOGREFFE_DISPO_WS', false);
|
|
|
|
define('INFOGREFFE_WS_URL', 'https://webservices.infogreffe.fr/WSContextInfogreffe/INFOGREFFE');
|
|
|
|
define('INFOGREFFE_WS_USER', '85000109');
|
|
|
|
define('INFOGREFFE_WS_PASS', '166');
|
2013-11-05 12:18:30 +01:00
|
|
|
|
|
|
|
return $config;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Initialisation global des paramètres de vue
|
|
|
|
protected function _initViewSettings()
|
|
|
|
{
|
|
|
|
$this->bootstrap('view');
|
2013-11-05 14:13:59 +01:00
|
|
|
|
2013-11-05 12:18:30 +01:00
|
|
|
$view = $this->getResource('view');
|
|
|
|
$view->setEncoding('UTF-8');
|
|
|
|
$view->doctype('HTML5');
|
2013-11-05 14:13:59 +01:00
|
|
|
|
2013-11-05 12:18:30 +01:00
|
|
|
$view->headMeta()
|
2014-01-16 11:47:25 +01:00
|
|
|
->appendName('viewport', 'width=device-width, initial-scale=1.0')
|
|
|
|
->appendHttpEquiv('X-UA-Compatible', 'IE=edge')
|
2013-11-05 12:18:30 +01:00
|
|
|
->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8')
|
|
|
|
->appendHttpEquiv('Content-Language', 'fr-FR');
|
2013-11-05 14:13:59 +01:00
|
|
|
|
2014-03-10 17:26:06 +01:00
|
|
|
//Favicon - Touch icon for iOS 2.0+ and Android 2.1+
|
|
|
|
$view->headLink()->headLink(array(
|
|
|
|
'rel' => 'apple-touch-icon-precomposed',
|
|
|
|
'href' => '/favicon-152.png'
|
|
|
|
));
|
|
|
|
//Favicon - targeted to any additional png size
|
|
|
|
$view->headLink()->headLink(array(
|
|
|
|
'rel' => 'icon',
|
|
|
|
'type' => 'image/png',
|
|
|
|
'href' => '/favicon-32.png'
|
|
|
|
));
|
|
|
|
$view->headLink()->headLink(array(
|
|
|
|
'rel' => 'shortcut icon',
|
|
|
|
'type' => 'image/x-icon',
|
|
|
|
'href' => '/favicon.ico')
|
|
|
|
);
|
|
|
|
|
2013-11-05 12:18:30 +01:00
|
|
|
$view->headLink()
|
2016-01-25 16:50:31 +01:00
|
|
|
->appendStylesheet('/libs/bootstrap-3.3.6/css/bootstrap.min.css', 'all')
|
2013-11-05 14:13:59 +01:00
|
|
|
->appendStylesheet('/themes/default/css/docs.css', 'all')
|
|
|
|
->appendStylesheet('/themes/default/css/main.css', 'all');
|
|
|
|
|
|
|
|
$view->headScript()
|
2014-05-14 08:46:30 +02:00
|
|
|
->appendFile('/libs/html5shiv.min.js', 'text/javascript', array('conditional' => 'lt IE 9'))
|
2014-01-16 11:47:25 +01:00
|
|
|
->appendFile('/libs/respond.min.js', 'text/javascript', array('conditional' => 'lt IE 9'))
|
2016-01-25 16:50:31 +01:00
|
|
|
->appendFile('/libs/jquery-1.12.0.min.js', 'text/javascript')
|
|
|
|
->appendFile('/libs/bootstrap-3.3.6/js/bootstrap.min.js', 'text/javascript');
|
2013-11-05 14:13:59 +01:00
|
|
|
|
2013-11-05 12:18:30 +01:00
|
|
|
$view->headTitle()->setSeparator(' - ');
|
2013-11-05 14:13:59 +01:00
|
|
|
$view->headTitle('Web Service API - Scores & Decisions');
|
2013-11-05 12:18:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function _initRouter()
|
|
|
|
{
|
|
|
|
$this->bootstrap('frontController');
|
|
|
|
$front = $this->getResource('frontController');
|
|
|
|
$router = $front->getRouter();
|
|
|
|
|
|
|
|
//Lire les services disponibles et créer les routes
|
|
|
|
$services = require_once APPLICATION_PATH . '/../library/WsScore/ServicesConfig.php';
|
|
|
|
foreach( $services 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);
|
|
|
|
|
|
|
|
$route = new Zend_Controller_Router_Route('jsonrpc/'.$section.'/:version', array(
|
|
|
|
'controller' => 'jsonrpc',
|
|
|
|
'action' => 'index',
|
|
|
|
'service' => $section,
|
|
|
|
'version' => '',
|
|
|
|
));
|
|
|
|
$router->addRoute('jsonrpc-'.$section, $route);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Route pour WS Clients
|
|
|
|
$route = new Zend_Controller_Router_Route('clients/:client/:version', array(
|
|
|
|
'controller' => 'service',
|
|
|
|
'action' => 'index',
|
|
|
|
'service' => 'clients',
|
|
|
|
'client' => '',
|
|
|
|
'version' => ''
|
|
|
|
));
|
|
|
|
$router->addRoute('client', $route);
|
|
|
|
|
|
|
|
$fichierRoute = new Zend_Controller_Router_Route('fichier/:action/:fichier', array(
|
|
|
|
'controller' => 'fichier',
|
|
|
|
'fichier' => '',
|
|
|
|
));
|
|
|
|
$router->addRoute('fichier', $fichierRoute);
|
|
|
|
return $router;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function _initDb()
|
|
|
|
{
|
|
|
|
$c = Zend_Registry::get('config');
|
|
|
|
try {
|
|
|
|
$db = Zend_Db::factory($c->profil->db->metier);
|
|
|
|
} 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|