PHP-CS-Fixer

This commit is contained in:
Michael RICOIS 2016-11-29 15:10:11 +01:00
parent 9eea8297f2
commit eae820245e
18 changed files with 1266 additions and 1288 deletions

View File

@ -9,7 +9,7 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
define('MYSQL_HOST', $config->profil->db->metier->params->host); define('MYSQL_HOST', $config->profil->db->metier->params->host);
define('MYSQL_USER', $config->profil->db->metier->params->username); define('MYSQL_USER', $config->profil->db->metier->params->username);
define('MYSQL_PASS', $config->profil->db->metier->params->password); define('MYSQL_PASS', $config->profil->db->metier->params->password);
define('LOG_PATH' , $config->profil->path->shared.'/log'); define('LOG_PATH', $config->profil->path->shared.'/log');
// Entreprise // Entreprise
define('SPHINX_ENT_HOST', $config->profil->sphinx->ent->host); define('SPHINX_ENT_HOST', $config->profil->sphinx->ent->host);
@ -39,155 +39,159 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
} }
//Initialisation global des paramètres de vue //Initialisation global des paramètres de vue
protected function _initViewSettings() protected function _initViewSettings()
{ {
$this->bootstrap('view'); $this->bootstrap('view');
$view = $this->getResource('view'); $view = $this->getResource('view');
$view->setEncoding('UTF-8'); $view->setEncoding('UTF-8');
$view->doctype('HTML5'); $view->doctype('HTML5');
$view->headMeta() $view->headMeta()
->appendName('viewport', 'width=device-width, initial-scale=1.0') ->appendName('viewport', 'width=device-width, initial-scale=1.0')
->appendHttpEquiv('X-UA-Compatible', 'IE=edge') ->appendHttpEquiv('X-UA-Compatible', 'IE=edge')
->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8') ->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8')
->appendHttpEquiv('Content-Language', 'fr-FR'); ->appendHttpEquiv('Content-Language', 'fr-FR');
//Favicon - Touch icon for iOS 2.0+ and Android 2.1+ //Favicon - Touch icon for iOS 2.0+ and Android 2.1+
$view->headLink()->headLink(array( $view->headLink()->headLink(array(
'rel' => 'apple-touch-icon-precomposed', 'rel' => 'apple-touch-icon-precomposed',
'href' => '/favicon-152.png' 'href' => '/favicon-152.png'
)); ));
//Favicon - targeted to any additional png size //Favicon - targeted to any additional png size
$view->headLink()->headLink(array( $view->headLink()->headLink(array(
'rel' => 'icon', 'rel' => 'icon',
'type' => 'image/png', 'type' => 'image/png',
'href' => '/favicon-32.png' 'href' => '/favicon-32.png'
)); ));
$view->headLink()->headLink(array( $view->headLink()->headLink(array(
'rel' => 'shortcut icon', 'rel' => 'shortcut icon',
'type' => 'image/x-icon', 'type' => 'image/x-icon',
'href' => '/favicon.ico') 'href' => '/favicon.ico')
); );
$view->headLink() $view->headLink()
->appendStylesheet('/assets/libs/bootstrap-3.3.7/css/bootstrap.min.css', 'all') ->appendStylesheet('/assets/libs/bootstrap-3.3.7/css/bootstrap.min.css', 'all')
->appendStylesheet('/assets/themes/default/css/docs.css', 'all') ->appendStylesheet('/assets/themes/default/css/docs.css', 'all')
->appendStylesheet('/assets/themes/default/css/main.css', 'all'); ->appendStylesheet('/assets/themes/default/css/main.css', 'all');
$view->headScript() $view->headScript()
->appendFile('/assets/libs/html5shiv.min.js', 'text/javascript', array('conditional' => 'lt IE 9')) ->appendFile('/assets/libs/html5shiv.min.js', 'text/javascript', array('conditional' => 'lt IE 9'))
->appendFile('/assets/libs/respond.min.js', 'text/javascript', array('conditional' => 'lt IE 9')) ->appendFile('/assets/libs/respond.min.js', 'text/javascript', array('conditional' => 'lt IE 9'))
->appendFile('/assets/libs/jquery-1.12.4.min.js', 'text/javascript') ->appendFile('/assets/libs/jquery-1.12.4.min.js', 'text/javascript')
->appendFile('/assets/libs/bootstrap-3.3.7/js/bootstrap.min.js', 'text/javascript'); ->appendFile('/assets/libs/bootstrap-3.3.7/js/bootstrap.min.js', 'text/javascript');
$view->headTitle()->setSeparator(' - '); $view->headTitle()->setSeparator(' - ');
$view->headTitle('Web Service API - Scores & Decisions'); $view->headTitle('Web Service API - Scores & Decisions');
} }
protected function _initRouter() protected function _initRouter()
{ {
$this->bootstrap('frontController'); $this->bootstrap('frontController');
$front = $this->getResource('frontController'); $front = $this->getResource('frontController');
$router = $front->getRouter(); $router = $front->getRouter();
// Lire les services disponibles et créer les routes // Lire les services disponibles et créer les routes
$services = require_once APPLICATION_PATH . '/../library/WsScore/ServicesConfig.php'; $services = require_once APPLICATION_PATH . '/../library/WsScore/ServicesConfig.php';
foreach( $services as $section => $params ) { foreach ($services as $section => $params) {
if ($params['actif']) { if ($params['actif']) {
$route = new Zend_Controller_Router_Route($section.'/:version', array( $route = new Zend_Controller_Router_Route($section.'/:version', array(
'controller' => 'service', 'controller' => 'service',
'action' => 'index', 'action' => 'index',
'service' => $section, 'service' => $section,
'version' => '', 'version' => '',
)); ));
$router->addRoute($section, $route); $router->addRoute($section, $route);
} }
} }
// Route pour WS Clients // Route pour WS Clients
$route = new Zend_Controller_Router_Route('clients/:client/:version', array( $route = new Zend_Controller_Router_Route('clients/:client/:version', array(
'controller' => 'service', 'controller' => 'service',
'action' => 'index', 'action' => 'index',
'service' => 'clients', 'service' => 'clients',
'client' => '', 'client' => '',
'version' => '' 'version' => ''
)); ));
$router->addRoute('client', $route); $router->addRoute('client', $route);
$fichierRoute = new Zend_Controller_Router_Route('fichier/:action/:fichier', array( $fichierRoute = new Zend_Controller_Router_Route('fichier/:action/:fichier', array(
'controller' => 'fichier', 'controller' => 'fichier',
'fichier' => '', 'fichier' => '',
)); ));
$router->addRoute('fichier', $fichierRoute); $router->addRoute('fichier', $fichierRoute);
return $router; return $router;
} }
protected function _initDb() protected function _initDb()
{ {
$c = new Zend_Config($this->getOptions()); $c = new Zend_Config($this->getOptions());
try { try {
$db = Zend_Db::factory($c->profil->db->metier); $db = Zend_Db::factory($c->profil->db->metier);
} catch ( Exception $e ) { } catch (Exception $e) {
if (APPLICATION_ENV == 'development') { if (APPLICATION_ENV == 'development') {
echo '<pre>'; print_r($e); echo '</pre>'; echo '<pre>';
} else { print_r($e);
echo "Le service rencontre actuellement un problème technique."; echo '</pre>';
} } else {
exit; echo "Le service rencontre actuellement un problème technique.";
} }
exit;
}
/** /**
* Set the default adapter to use with all model * Set the default adapter to use with all model
*/ */
Zend_Db_Table::setDefaultAdapter($db); Zend_Db_Table::setDefaultAdapter($db);
} }
protected function _initDoctrine() protected function _initDoctrine()
{ {
$c = new Zend_Config($this->getOptions()); $c = new Zend_Config($this->getOptions());
$config = new \Doctrine\DBAL\Configuration(); $config = new \Doctrine\DBAL\Configuration();
if (APPLICATION_ENV == 'development') { if (APPLICATION_ENV == 'development') {
$logger = new Scores_Logger_Sql(); $logger = new Scores_Logger_Sql();
$config->setSQLLogger($logger); $config->setSQLLogger($logger);
} }
$connectionParams = array( $connectionParams = array(
'dbname' => $c->profil->db->metier->params->dbname, 'dbname' => $c->profil->db->metier->params->dbname,
'user' => $c->profil->db->metier->params->username, 'user' => $c->profil->db->metier->params->username,
'password' => $c->profil->db->metier->params->password, 'password' => $c->profil->db->metier->params->password,
'host' => $c->profil->db->metier->params->host, 'host' => $c->profil->db->metier->params->host,
'charset' => 'utf8', 'charset' => 'utf8',
'driver' => 'pdo_mysql', 'driver' => 'pdo_mysql',
); );
try { try {
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config); $conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
} catch (\Doctrine\DBAL\DBALException $e) { } catch (\Doctrine\DBAL\DBALException $e) {
if (APPLICATION_ENV == 'development') { if (APPLICATION_ENV == 'development') {
echo '<pre>'; print_r($e); echo '</pre>'; echo '<pre>';
} else { print_r($e);
echo "Le service rencontre actuellement un problème technique."; echo '</pre>';
} } else {
exit; echo "Le service rencontre actuellement un problème technique.";
} }
exit;
}
Zend_Registry::set('doctrine', $conn); Zend_Registry::set('doctrine', $conn);
} }
protected function _initCache() protected function _initCache()
{ {
if ( APPLICATION_ENV!='development' ) { if (APPLICATION_ENV!='development') {
//MetadataCache pour la base de données //MetadataCache pour la base de données
$frontendOptions = array( $frontendOptions = array(
'lifetime' => 14400, 'lifetime' => 14400,
'automatic_serialization' => true 'automatic_serialization' => true
); );
$backendOptions = array(); $backendOptions = array();
$cache = Zend_Cache::factory('Core','Apc', $frontendOptions, $backendOptions); $cache = Zend_Cache::factory('Core', 'Apc', $frontendOptions, $backendOptions);
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache); Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
} }
} }
} }

View File

@ -52,4 +52,4 @@ return array(
'action' => 'about', 'action' => 'about',
'pages' => array(), 'pages' => array(),
), ),
); );

View File

@ -1,109 +1,107 @@
<?php <?php
class DemoController extends Zend_Controller_Action class DemoController extends Zend_Controller_Action
{ {
protected $_username; protected $_username;
protected $_hash; protected $_hash;
protected $methods = array( protected $methods = array(
'getIdentite' => array( 'getIdentite' => array(
'ws' => 'entreprise/v0.8?wsdl', 'ws' => 'entreprise/v0.8?wsdl',
'form' => 'getIdentite', 'form' => 'getIdentite',
), ),
); );
public function init() public function init()
{
$auth = Zend_Auth::getInstance();
$this->_username = $auth->getIdentity()->username;
$this->_hash = $auth->getIdentity()->hash;
}
public function indexAction()
{ {
//Liste $auth = Zend_Auth::getInstance();
$this->_username = $auth->getIdentity()->username;
$this->_hash = $auth->getIdentity()->hash;
}
public function indexAction()
{
//Liste
$tabMethods = array(); $tabMethods = array();
foreach($this->methods as $method => $element){ foreach ($this->methods as $method => $element) {
$url = $this->view->url(array( $url = $this->view->url(array(
'controller' => 'demo', 'controller' => 'demo',
'action' => 'method', 'action' => 'method',
'name' => $method, 'name' => $method,
)); ));
$tabMethods[] = array( $tabMethods[] = array(
'nom' => $method, 'nom' => $method,
'url' => $url, 'url' => $url,
); );
} }
$this->view->assign('methods', $tabMethods); $this->view->assign('methods', $tabMethods);
} }
public function methodAction() public function methodAction()
{ {
$method = $this->_getParam('name',''); $method = $this->_getParam('name', '');
$this->view->assign('method', $method); $this->view->assign('method', $method);
//Affichage du formulaire //Affichage du formulaire
if (array_key_exists($method, $this->methods)){ if (array_key_exists($method, $this->methods)) {
$class = 'Scores_Ws_Form_'.ucfirst($method); $class = 'Scores_Ws_Form_'.ucfirst($method);
if (class_exists($class)){ if (class_exists($class)) {
$form = new $class; $form = new $class;
$form->addElement('hidden', 'method', array( $form->addElement('hidden', 'method', array(
'value' => $method, 'value' => $method,
)); ));
if ($this->_request->isPost()) { if ($this->_request->isPost()) {
$formData = $this->_request->getPost(); $formData = $this->_request->getPost();
$form->populate($formData); $form->populate($formData);
} }
$this->view->assign('form', $form); $this->view->assign('form', $form);
} else { } else {
$this->view->assign('message',"Impossible d'afficher le formulaire !"); $this->view->assign('message', "Impossible d'afficher le formulaire !");
} }
} }
} }
public function requeteAction() public function requeteAction()
{ {
if ($this->_request->isPost()) { if ($this->_request->isPost()) {
$formData = $this->_request->getPost(); $formData = $this->_request->getPost();
$method = $formData['method']; $method = $formData['method'];
$class = 'Scores_Ws_Form_'.ucfirst($method); $class = 'Scores_Ws_Form_'.ucfirst($method);
if (class_exists($class)) { if (class_exists($class)) {
$form = new $class; $form = new $class;
if ($form->isValid($formData)) { if ($form->isValid($formData)) {
$method = $formData['method']; $method = $formData['method'];
$siret = $formData['siret']; $siret = $formData['siret'];
$accesWs = $this->methods[$method]['ws']; $accesWs = $this->methods[$method]['ws'];
$hostName = $this->getRequest()->getHttpHost(); $hostName = $this->getRequest()->getHttpHost();
$options = array( $options = array(
'login' => $this->_username, 'login' => $this->_username,
'password' => $this->_hash, 'password' => $this->_hash,
'features' => SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS 'features' => SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS
); );
$client = new Zend_Soap_Client('http://'.$hostName.'/'.$accesWs, $options); $client = new Zend_Soap_Client('http://'.$hostName.'/'.$accesWs, $options);
$params = new StdClass(); $params = new StdClass();
$params->siret = $siret; $params->siret = $siret;
try { try {
$reponse = $client->getIdentite($params); $reponse = $client->getIdentite($params);
} catch (Zend_Soap_Client_Exception $e) { } catch (Zend_Soap_Client_Exception $e) {
$reponse = $e->getMessage(); $reponse = $e->getMessage();
} }
$soap = array( $soap = array(
'requete' => $params, 'requete' => $params,
'reponse' => $reponse, 'reponse' => $reponse,
); );
$this->view->assign('soap',$soap); $this->view->assign('soap', $soap);
$xml = array( $xml = array(
'requete' => $client->getLastRequest(), 'requete' => $client->getLastRequest(),
'reponse' => $client->getLastResponse() 'reponse' => $client->getLastResponse()
); );
$this->view->assign('xml',$xml); $this->view->assign('xml', $xml);
} else { } else {
$this->_forward('method', 'demo', null, array('name'=> 'getIdentite')); $this->_forward('method', 'demo', null, array('name'=> 'getIdentite'));
} }
} }
} }
} }
} }

View File

@ -2,196 +2,188 @@
class DocumentationController extends Zend_Controller_Action class DocumentationController extends Zend_Controller_Action
{ {
/** /**
* Affichage de la documentation des webservices * Affichage de la documentation des webservices
*/ */
public function indexAction() public function indexAction()
{ {
//Do nothing //Do nothing
} }
/** /**
* Liste des services * Liste des services
*/ */
public function servicesAction() public function servicesAction()
{ {
}
} /**
* Liste des version par service
*/
public function servicevAction()
{
$request = $this->getRequest();
$name = $request->getParam('name');
/** $this->view->key = $name;
* Liste des version par service }
*/
public function servicevAction()
{
$request = $this->getRequest();
$name = $request->getParam('name');
$this->view->key = $name; public function serviceAction()
} {
$request = $this->getRequest();
$type = $request->getParam('type', 'sd');
$ws = strtolower($request->getParam('name', 'entreprise'));
public function serviceAction() $myService = $this->view->WsServices[$ws];
{
$request = $this->getRequest();
$type = $request->getParam('type', 'sd');
$ws = strtolower($request->getParam('name','entreprise'));
$myService = $this->view->WsServices[$ws]; // Gestion des versions
$serviceVersions = array();
$configServiceVersions = $myService['versions'];
foreach ($configServiceVersions as $section => $params) {
$serviceVersions[$section] = $params;
if ($params['defaut']) {
$defautVersion = $section;
}
}
$version = $request->getParam('version', $defautVersion);
// Gestion des versions $this->view->assign('serviceName', $myService['name']);
$serviceVersions = array(); $this->view->assign('serviceVersion', $version);
$configServiceVersions = $myService['versions'];
foreach( $configServiceVersions as $section => $params ){
$serviceVersions[$section] = $params;
if ($params['defaut']) {
$defautVersion = $section;
}
}
$version = $request->getParam('version', $defautVersion);
$this->view->assign('serviceName', $myService['name']); $isDeprecated = false;
$this->view->assign('serviceVersion', $version); if ($myService['versions'][$version]['defaut'] == '') {
$isDeprecated = false;
if ( $myService['versions'][$version]['defaut'] == '' ) {
$isDeprecated = true; $isDeprecated = true;
} }
$this->view->assign('isDeprecated', $isDeprecated); $this->view->assign('isDeprecated', $isDeprecated);
if ( $type == 'client') { if ($type == 'client') {
$client = $ws; $client = $ws;
$ws = 'entreprise'; $ws = 'entreprise';
} }
// Charger les classes et les types pour le service suivant la version // Charger les classes et les types pour le service suivant la version
if ( $type == 'client') { if ($type == 'client') {
$pathClassService = 'WsScore/Clients/'.ucfirst($client).'/v'.$version.'/'; $pathClassService = 'WsScore/Clients/'.ucfirst($client).'/v'.$version.'/';
} else { } else {
$pathClassService = 'WsScore/'.ucfirst($ws).'/v'.$version.'/'; $pathClassService = 'WsScore/'.ucfirst($ws).'/v'.$version.'/';
} }
//Génération du tableau de mapping //Génération du tableau de mapping
$classmap = include $pathClassService.'Config.php'; $classmap = include $pathClassService.'Config.php';
//Définir l'url d'accès au WSDL //Définir l'url d'accès au WSDL
$wsdl_url = $this->view->baseUrl(); $wsdl_url = $this->view->baseUrl();
if ( $type == 'client') { if ($type == 'client') {
$wsdl_url.= '/clients/'.$client.'/v'.$version; $wsdl_url.= '/clients/'.$client.'/v'.$version;
} else { } else {
$wsdl_url.= '/'.$ws.'/v'.$version; $wsdl_url.= '/'.$ws.'/v'.$version;
} }
if (APPLICATION_ENV == 'production'){ if (APPLICATION_ENV == 'production') {
$wsdl_url.= '?wsdl'; $wsdl_url.= '?wsdl';
} else { } else {
$wsdl_url.= '?wsdl-auto'; $wsdl_url.= '?wsdl-auto';
} }
// Affichage de la documentation // Affichage de la documentation
$doc = new Scores_Ws_Doc(ucfirst($ws), $classmap, $pathClassService); $doc = new Scores_Ws_Doc(ucfirst($ws), $classmap, $pathClassService);
$tabServiceMethods = $doc->getServiceMethods(); $tabServiceMethods = $doc->getServiceMethods();
// Tri des méthodes par ordre alphabétique // Tri des méthodes par ordre alphabétique
$tabServiceMethodsK = array(); $tabServiceMethodsK = array();
foreach($tabServiceMethods as $method) { foreach ($tabServiceMethods as $method) {
$tabServiceMethodsK[$method['name']] = $method; $tabServiceMethodsK[$method['name']] = $method;
} }
ksort($tabServiceMethodsK); ksort($tabServiceMethodsK);
$tabServiceTypes = $doc->getServiceTypes(); $tabServiceTypes = $doc->getServiceTypes();
$this->view->assign('wsdl', $wsdl_url); $this->view->assign('wsdl', $wsdl_url);
$this->view->assign('serviceMethods', $tabServiceMethodsK); $this->view->assign('serviceMethods', $tabServiceMethodsK);
$this->view->assign('serviceTypes', $tabServiceTypes); $this->view->assign('serviceTypes', $tabServiceTypes);
} }
/** /**
* Liste les exemples de code disponible pour chaque méthode * Liste les exemples de code disponible pour chaque méthode
*/ */
public function exemplesAction() public function exemplesAction()
{ {
$request = $this->getRequest(); $request = $this->getRequest();
$ws = strtolower($request->getParam('ws','Entreprise')); $ws = strtolower($request->getParam('ws', 'Entreprise'));
$auth = Zend_Auth::getInstance(); $auth = Zend_Auth::getInstance();
//Si client possède un webservice particulier alors on redirige vers la doc clients //Si client possède un webservice particulier alors on redirige vers la doc clients
$clients = include APPLICATION_PATH . '/../library/WsScore/Clients/ClientsConfig.php'; $clients = include APPLICATION_PATH . '/../library/WsScore/Clients/ClientsConfig.php';
foreach( $clients as $section => $params ){ foreach ($clients as $section => $params) {
if ($params['actif']) { if ($params['actif']) {
$wsClients[$params['idClient']] = $section; $wsClients[$params['idClient']] = $section;
} }
} }
if (array_key_exists($auth->getIdentity()->idClient, $wsClients)){ if (array_key_exists($auth->getIdentity()->idClient, $wsClients)) {
$this->_forward('clients', 'documentation', null, array(
'nom' => $wsClients[$auth->getIdentity()->idClient]
));
} else {
$this->_forward('clients', 'documentation', null, array( // Liste des webservices
'nom' => $wsClients[$auth->getIdentity()->idClient] $services = include APPLICATION_PATH . '/../library/WsScore/ServicesConfig.php';
)); foreach ($services as $section => $params) {
if ($params['actif']) {
$wsServices[$section] = $params;
}
}
} else { // On vérifie que l'utilisateur peut accèder à la documentation
$username = $auth->getIdentity()->username;
$idClient = $auth->getIdentity()->idClient;
if (array_key_exists($ws, $wsServices)) {
if (isset($wsServices['idClient']) && $idClient!=$wsServices['idClient']) {
$this->renderScript('documentation/nodoc.phtml');
exit;
}
if (isset($wsServices['user']) && !in_array($username, $wsServices['user'])) {
$this->renderScript('documentation/nodoc.phtml');
exit;
}
}
// Liste des webservices // Gestion des versions
$services = include APPLICATION_PATH . '/../library/WsScore/ServicesConfig.php'; $serviceVersions = array();
foreach( $services as $section => $params ) $configServiceVersions = $wsServices[$ws]['versions'];
{ foreach ($configServiceVersions as $section => $params) {
if ($params['actif']) { $serviceVersions[$section] = $params;
$wsServices[$section] = $params; if ($params['defaut']) {
} $defautVersion = $section;
} }
}
$version = $request->getParam('version', $defautVersion);
// On vérifie que l'utilisateur peut accèder à la documentation // Charger les classes et les types pour le service suivant la version
$username = $auth->getIdentity()->username; $pathClassService = 'WsScore/'.ucfirst($ws).'/v'.$version.'/';
$idClient = $auth->getIdentity()->idClient;
if ( array_key_exists($ws, $wsServices) )
{
if ( isset($wsServices['idClient']) && $idClient!=$wsServices['idClient'] )
{
$this->renderScript('documentation/nodoc.phtml');
exit;
}
if ( isset($wsServices['user']) && !in_array($username, $wsServices['user']) )
{
$this->renderScript('documentation/nodoc.phtml');
exit;
}
}
// Gestion des versions //Génération du tableau de mapping
$serviceVersions = array(); $classmap = include $pathClassService.'Config.php';
$configServiceVersions = $wsServices[$ws]['versions'];
foreach( $configServiceVersions as $section => $params ){
$serviceVersions[$section] = $params;
if ($params['defaut']) {
$defautVersion = $section;
}
}
$version = $request->getParam('version', $defautVersion);
// Charger les classes et les types pour le service suivant la version //Définir l'url d'accès au WSDL
$pathClassService = 'WsScore/'.ucfirst($ws).'/v'.$version.'/'; $wsdl_url = $this->view->baseUrl();
if (APPLICATION_ENV == 'production') {
//Génération du tableau de mapping $wsdl_url.= '/'.$ws.'/v'.$version.'?wsdl';
$classmap = include $pathClassService.'Config.php'; } else {
$wsdl_url.= '/'.$ws.'/v'.$version.'?wsdl-auto';
//Définir l'url d'accès au WSDL }
$wsdl_url = $this->view->baseUrl(); // Affichage de la documentation
if (APPLICATION_ENV == 'production'){ $doc = new Scores_Ws_Doc(ucfirst($ws), $classmap, $pathClassService);
$wsdl_url.= '/'.$ws.'/v'.$version.'?wsdl'; $tabServiceMethods = $doc->getServiceMethods();
} else { // Tri des méthodes par ordre alphabétique
$wsdl_url.= '/'.$ws.'/v'.$version.'?wsdl-auto'; $tabServiceMethodsK = array();
} foreach ($tabServiceMethods as $method) {
// Affichage de la documentation $tabServiceMethodsK[$method['name']] = $method;
$doc = new Scores_Ws_Doc(ucfirst($ws), $classmap, $pathClassService); }
$tabServiceMethods = $doc->getServiceMethods(); ksort($tabServiceMethodsK);
// Tri des méthodes par ordre alphabétique $tabServiceTypes = $doc->getServiceTypes();
$tabServiceMethodsK = array(); $this->view->assign('wsdl', $wsdl_url);
foreach($tabServiceMethods as $method) { $this->view->assign('serviceMethods', $tabServiceMethodsK);
$tabServiceMethodsK[$method['name']] = $method; $this->view->assign('serviceTypes', $tabServiceTypes);
} }
ksort($tabServiceMethodsK); }
$tabServiceTypes = $doc->getServiceTypes();
$this->view->assign('wsdl', $wsdl_url);
$this->view->assign('serviceMethods', $tabServiceMethodsK);
$this->view->assign('serviceTypes', $tabServiceTypes);
}
}
/** /**
* Affichage exemple de code avec coloration syntaxique * Affichage exemple de code avec coloration syntaxique
@ -200,23 +192,23 @@ class DocumentationController extends Zend_Controller_Action
*/ */
public function codeAction() public function codeAction()
{ {
$langage = strtolower($this->_getParam('langage','')); $langage = strtolower($this->_getParam('langage', ''));
$element = $this->_getParam('element',''); $element = $this->_getParam('element', '');
$fichier = APPLICATION_PATH . '/../public/assets/code/' . $element . '-' . $langage . '.txt'; $fichier = APPLICATION_PATH . '/../public/assets/code/' . $element . '-' . $langage . '.txt';
if (file_exists($fichier)){ if (file_exists($fichier)) {
$sourceCode = file_get_contents($fichier); $sourceCode = file_get_contents($fichier);
$geshi = new GeSHi($sourceCode, $langage); $geshi = new GeSHi($sourceCode, $langage);
$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
$sourceHighlight = $geshi->parse_code(); $sourceHighlight = $geshi->parse_code();
$this->view->assign('langage', strtoupper($langage)); $this->view->assign('langage', strtoupper($langage));
$this->view->assign('code', $sourceHighlight); $this->view->assign('code', $sourceHighlight);
} else { } else {
$this->view->assign('langage', $this->view->assign('langage',
'Element non traités, Vous pouvez aussi nous fournir des exemples.'); 'Element non traités, Vous pouvez aussi nous fournir des exemples.');
} }
} }
/** /**
@ -224,9 +216,8 @@ class DocumentationController extends Zend_Controller_Action
*/ */
public function erreurAction() public function erreurAction()
{ {
$ws = new Scores_Ws_Server(); $ws = new Scores_Ws_Server();
$erreurs = $ws->listError; $erreurs = $ws->listError;
$this->view->assign('erreurs', $erreurs); $this->view->assign('erreurs', $erreurs);
} }
} }

View File

@ -1,7 +1,7 @@
<?php <?php
class ErrorController extends Zend_Controller_Action class ErrorController extends Zend_Controller_Action
{ {
public function errorAction() public function errorAction()
{ {
$errors = $this->_getParam('error_handler'); $errors = $this->_getParam('error_handler');
@ -44,4 +44,3 @@ class ErrorController extends Zend_Controller_Action
return $log; return $log;
} }
} }

View File

@ -5,259 +5,257 @@ class FichierController extends Zend_Controller_Action
* PDO Connection with Doctrine * PDO Connection with Doctrine
* @var \Doctrine\DBAL\Connection * @var \Doctrine\DBAL\Connection
*/ */
protected $conn; protected $conn;
public function init() public function init()
{ {
$this->_helper->layout()->disableLayout(); $this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender(true); $this->_helper->viewRenderer->setNoRender(true);
$this->conn = Zend_Registry::get('doctrine'); $this->conn = Zend_Registry::get('doctrine');
} }
public function bodaccAction() public function bodaccAction()
{ {
$auth = Zend_Auth::getInstance(); $auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) { if ($auth->hasIdentity()) {
$c = Zend_Registry::get('config'); $c = Zend_Registry::get('config');
$directory = $c->profil->path->shared.'/datafile/bodacc/histo'; $directory = $c->profil->path->shared.'/datafile/bodacc/histo';
$q = $this->getRequest()->getParam('q'); $q = $this->getRequest()->getParam('q');
$filename = base64_decode($q); $filename = base64_decode($q);
$file = $directory.'/'.$filename; $file = $directory.'/'.$filename;
if (file_exists($file) && filesize($file) > 0) { if (file_exists($file) && filesize($file) > 0) {
//Log de la requete //Log de la requete
$data = array( $data = array(
'login' => $auth->getIdentity()->username, 'login' => $auth->getIdentity()->username,
'idClient' => $auth->getIdentity()->idClient, 'idClient' => $auth->getIdentity()->idClient,
'page' => 'histobodacc', 'page' => 'histobodacc',
'siren' => '', 'siren' => '',
'nic' => '', 'nic' => '',
'params' => $file, 'params' => $file,
'test' => 0, 'test' => 0,
'raisonSociale' => '', 'raisonSociale' => '',
'cp' => '', 'cp' => '',
'ville' => '', 'ville' => '',
'ipClient' => $_SERVER['REMOTE_ADDR'], 'ipClient' => $_SERVER['REMOTE_ADDR'],
); );
$this->conn->insert('sdv1.logs', $data); $this->conn->insert('sdv1.logs', $data);
$content_type = 'application/pdf'; $content_type = 'application/pdf';
// --- Envoi du fichier sur la sortie standard // --- Envoi du fichier sur la sortie standard
$modules = array(); //apache_get_modules(); $modules = array(); //apache_get_modules();
if (in_array('mod_xsendfile', $modules)) { if (in_array('mod_xsendfile', $modules)) {
header('X-Sendfile: ' . $file); header('X-Sendfile: ' . $file);
header('Content-Type: ' . $content_type); header('Content-Type: ' . $content_type);
header('Content-Disposition: inline; filename="' . $content_type . '"'); header('Content-Disposition: inline; filename="' . $content_type . '"');
exit; exit;
} else { } else {
ini_set('zlib.output_compression', '0'); ini_set('zlib.output_compression', '0');
header('Content-Transfer-Encoding: none'); header('Content-Transfer-Encoding: none');
header('Content-Type: ' . $content_type.''); header('Content-Type: ' . $content_type.'');
header('Content-Length: ' . filesize($file)); header('Content-Length: ' . filesize($file));
header('Content-MD5: ' . base64_encode(md5_file($file))); header('Content-MD5: ' . base64_encode(md5_file($file)));
header('Content-Disposition: inline; filename="' . basename($file) . '"'); header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate'); header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public'); header('Pragma: public');
readfile($file); readfile($file);
exit; exit;
} }
} else { } else {
echo "Erreur lors de l'affichage du fichier."; echo "Erreur lors de l'affichage du fichier.";
} }
} } else {
else { echo "Authentification échoué.";
echo "Authentification échoué."; }
} }
}
public function logsAction() public function logsAction()
{ {
$content_type = 'application/csv-tab-delimited-table'; $content_type = 'application/csv-tab-delimited-table';
$filename = $this->getRequest()->getParam('fichier'); $filename = $this->getRequest()->getParam('fichier');
$c = Zend_Registry::get('config'); $c = Zend_Registry::get('config');
$file = $c->profil->path->shared . '/files/'.$filename; $file = $c->profil->path->shared . '/files/'.$filename;
// --- Envoi du fichier sur la sortie standard // --- Envoi du fichier sur la sortie standard
if ( file_exists($file) ) { if (file_exists($file)) {
$modules = array(); //apache_get_modules(); $modules = array(); //apache_get_modules();
if (in_array('mod_xsendfile', $modules)) { if (in_array('mod_xsendfile', $modules)) {
header('X-Sendfile: ' . $file); header('X-Sendfile: ' . $file);
header('Content-Type: ' . $content_type); header('Content-Type: ' . $content_type);
header('Content-Disposition: inline; filename="' . $content_type . '"'); header('Content-Disposition: inline; filename="' . $content_type . '"');
exit; exit;
} else { } else {
ini_set('zlib.output_compression', '0'); ini_set('zlib.output_compression', '0');
header('Content-Transfer-Encoding: none'); header('Content-Transfer-Encoding: none');
header('Content-Type: ' . $content_type.''); header('Content-Type: ' . $content_type.'');
header('Content-Length: ' . filesize($file)); header('Content-Length: ' . filesize($file));
header('Content-MD5: ' . base64_encode(md5_file($file))); header('Content-MD5: ' . base64_encode(md5_file($file)));
header('Content-Disposition: inline; filename="' . basename($file) . '"'); header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate'); header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public'); header('Pragma: public');
readfile($file); readfile($file);
exit; exit;
} }
} else { } else {
$this->getResponse()->setHttpResponseCode(404); $this->getResponse()->setHttpResponseCode(404);
} }
} }
public function csvAction() public function csvAction()
{ {
$content_type = 'application/csv-tab-delimited-table'; $content_type = 'application/csv-tab-delimited-table';
$filename = $this->getRequest()->getParam('fichier'); $filename = $this->getRequest()->getParam('fichier');
$c = Zend_Registry::get('config'); $c = Zend_Registry::get('config');
$file = $c->profil->path->shared . '/files/'. $filename; $file = $c->profil->path->shared . '/files/'. $filename;
// --- Envoi du fichier sur la sortie standard // --- Envoi du fichier sur la sortie standard
if ( file_exists($file) ) { if (file_exists($file)) {
$modules = array(); //apache_get_modules(); $modules = array(); //apache_get_modules();
if (in_array('mod_xsendfile', $modules)) { if (in_array('mod_xsendfile', $modules)) {
header('X-Sendfile: ' . $file); header('X-Sendfile: ' . $file);
header('Content-Type: ' . $content_type); header('Content-Type: ' . $content_type);
header('Content-Disposition: inline; filename="' . $content_type . '"'); header('Content-Disposition: inline; filename="' . $content_type . '"');
exit; exit;
} else { } else {
ini_set('zlib.output_compression', '0'); ini_set('zlib.output_compression', '0');
header('Content-Transfer-Encoding: none'); header('Content-Transfer-Encoding: none');
header('Content-Type: ' . $content_type.''); header('Content-Type: ' . $content_type.'');
header('Content-Length: ' . filesize($file)); header('Content-Length: ' . filesize($file));
header('Content-MD5: ' . base64_encode(md5_file($file))); header('Content-MD5: ' . base64_encode(md5_file($file)));
header('Content-Disposition: inline; filename="' . basename($file) . '"'); header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate'); header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public'); header('Pragma: public');
readfile($file); readfile($file);
exit; exit;
} }
} } else {
else { $this->getResponse()->setHttpResponseCode(404);
$this->getResponse()->setHttpResponseCode(404); }
} }
}
public function kbisAction() public function kbisAction()
{ {
$content_type = 'application/pdf'; $content_type = 'application/pdf';
$filename = $this->getRequest()->getParam('fichier'); $filename = $this->getRequest()->getParam('fichier');
$c = Zend_Registry::get('config'); $c = Zend_Registry::get('config');
$file = realpath($c->profil->path->shared).'/datafile/kbis/'.$filename; $file = realpath($c->profil->path->shared).'/datafile/kbis/'.$filename;
// --- Envoi du fichier sur la sortie standard // --- Envoi du fichier sur la sortie standard
if ( file_exists($file) ) { if (file_exists($file)) {
$modules = array(); //apache_get_modules(); $modules = array(); //apache_get_modules();
if (in_array('mod_xsendfile', $modules)) { if (in_array('mod_xsendfile', $modules)) {
header('X-Sendfile: ' . $file); header('X-Sendfile: ' . $file);
header('Content-Type: ' . $content_type); header('Content-Type: ' . $content_type);
header('Content-Disposition: inline; filename="' . $content_type . '"'); header('Content-Disposition: inline; filename="' . $content_type . '"');
exit; exit;
} else { } else {
ini_set('zlib.output_compression', '0'); ini_set('zlib.output_compression', '0');
header('Content-Transfer-Encoding: none'); header('Content-Transfer-Encoding: none');
header('Content-Type: ' . $content_type.''); header('Content-Type: ' . $content_type.'');
header('Content-Length: ' . filesize($file)); header('Content-Length: ' . filesize($file));
header('Content-MD5: ' . base64_encode(md5_file($file))); header('Content-MD5: ' . base64_encode(md5_file($file)));
header('Content-Disposition: inline; filename="' . basename($file) . '"'); header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate'); header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public'); header('Pragma: public');
readfile($file); readfile($file);
exit; exit;
} }
} else { } else {
$this->getResponse()->setHttpResponseCode(404); $this->getResponse()->setHttpResponseCode(404);
} }
} }
public function associationsAction() public function associationsAction()
{ {
$content_type = 'application/pdf'; $content_type = 'application/pdf';
$filename = $this->getRequest()->getParam('fichier'); $filename = $this->getRequest()->getParam('fichier');
$c = Zend_Registry::get('config'); $c = Zend_Registry::get('config');
$file = $c->profil->path->shared . '/files/' . $filename; $file = $c->profil->path->shared . '/files/' . $filename;
// --- Envoi du fichier sur la sortie standard // --- Envoi du fichier sur la sortie standard
if ( file_exists($file) ) { if (file_exists($file)) {
$modules = array(); //apache_get_modules(); $modules = array(); //apache_get_modules();
if (in_array('mod_xsendfile', $modules)) { if (in_array('mod_xsendfile', $modules)) {
header('X-Sendfile: ' . $file); header('X-Sendfile: ' . $file);
header('Content-Type: ' . $content_type); header('Content-Type: ' . $content_type);
header('Content-Disposition: inline; filename="' . $content_type . '"'); header('Content-Disposition: inline; filename="' . $content_type . '"');
exit; exit;
} else { } else {
ini_set('zlib.output_compression', '0'); ini_set('zlib.output_compression', '0');
header('Content-Transfer-Encoding: none'); header('Content-Transfer-Encoding: none');
header('Content-Type: ' . $content_type.''); header('Content-Type: ' . $content_type.'');
header('Content-Length: ' . filesize($file)); header('Content-Length: ' . filesize($file));
header('Content-MD5: ' . base64_encode(md5_file($file))); header('Content-MD5: ' . base64_encode(md5_file($file)));
header('Content-Disposition: inline; filename="' . basename($file) . '"'); header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate'); header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public'); header('Pragma: public');
readfile($file); readfile($file);
exit; exit;
} }
} else { } else {
$this->getResponse()->setHttpResponseCode(404); $this->getResponse()->setHttpResponseCode(404);
} }
} }
public function greffesAction() public function greffesAction()
{ {
$content_type = 'application/pdf'; $content_type = 'application/pdf';
$filename = $this->getRequest()->getParam('fichier'); $filename = $this->getRequest()->getParam('fichier');
$c = Zend_Registry::get('config'); $c = Zend_Registry::get('config');
$file = $c->profil->path->shared . '/files/' .$filename; $file = $c->profil->path->shared . '/files/' .$filename;
// --- Envoi du fichier sur la sortie standard // --- Envoi du fichier sur la sortie standard
if ( file_exists($file) ) { if (file_exists($file)) {
$modules = array(); //apache_get_modules(); $modules = array(); //apache_get_modules();
if (in_array('mod_xsendfile', $modules)) { if (in_array('mod_xsendfile', $modules)) {
header('X-Sendfile: ' . $file); header('X-Sendfile: ' . $file);
header('Content-Type: ' . $content_type); header('Content-Type: ' . $content_type);
header('Content-Disposition: inline; filename="' . $content_type . '"'); header('Content-Disposition: inline; filename="' . $content_type . '"');
exit; exit;
} else { } else {
ini_set('zlib.output_compression', '0'); ini_set('zlib.output_compression', '0');
header('Content-Transfer-Encoding: none'); header('Content-Transfer-Encoding: none');
header('Content-Type: ' . $content_type.''); header('Content-Type: ' . $content_type.'');
header('Content-Length: ' . filesize($file)); header('Content-Length: ' . filesize($file));
header('Content-MD5: ' . base64_encode(md5_file($file))); header('Content-MD5: ' . base64_encode(md5_file($file)));
header('Content-Disposition: inline; filename="' . basename($file) . '"'); header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate'); header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public'); header('Pragma: public');
readfile($file); readfile($file);
exit; exit;
} }
} else { } else {
$this->getResponse()->setHttpResponseCode(404); $this->getResponse()->setHttpResponseCode(404);
} }
} }
public function crmAction() public function crmAction()
{ {
$content_type = 'application/x-bzip'; $content_type = 'application/x-bzip';
$filename = $this->getRequest()->getParam('fichier'); $filename = $this->getRequest()->getParam('fichier');
$c = Zend_Registry::get('config'); $c = Zend_Registry::get('config');
$file = $c->profil->path->shared . '/files/' .$filename; $file = $c->profil->path->shared . '/files/' .$filename;
// --- Envoi du fichier sur la sortie standard // --- Envoi du fichier sur la sortie standard
if ( file_exists($file) ) { if (file_exists($file)) {
$modules = array(); //apache_get_modules(); $modules = array(); //apache_get_modules();
if (in_array('mod_xsendfile', $modules)) { if (in_array('mod_xsendfile', $modules)) {
header('X-Sendfile: ' . $file); header('X-Sendfile: ' . $file);
header('Content-Type: ' . $content_type); header('Content-Type: ' . $content_type);
header('Content-Disposition: inline; filename="' . $content_type . '"'); header('Content-Disposition: inline; filename="' . $content_type . '"');
exit; exit;
} else { } else {
ini_set('zlib.output_compression', '0'); ini_set('zlib.output_compression', '0');
header('Content-Transfer-Encoding: none'); header('Content-Transfer-Encoding: none');
header('Content-Type: ' . $content_type.''); header('Content-Type: ' . $content_type.'');
header('Content-Length: ' . filesize($file)); header('Content-Length: ' . filesize($file));
header('Content-MD5: ' . base64_encode(md5_file($file))); header('Content-MD5: ' . base64_encode(md5_file($file)));
header('Content-Disposition: inline; filename="' . basename($file) . '"'); header('Content-Disposition: inline; filename="' . basename($file) . '"');
header('Cache-Control: private, max-age=0, must-revalidate'); header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public'); header('Pragma: public');
readfile($file); readfile($file);
exit; exit;
} }
} else { } else {
$this->getResponse()->setHttpResponseCode(404); $this->getResponse()->setHttpResponseCode(404);
} }
} }
} }

View File

@ -1,10 +1,15 @@
<?php <?php
class IndexController extends Zend_Controller_Action class IndexController extends Zend_Controller_Action
{ {
public function indexAction(){} public function indexAction()
{
}
public function contactAction(){} public function contactAction()
{
}
public function aboutAction(){} public function aboutAction()
{
}
} }

View File

@ -1,108 +1,106 @@
<?php <?php
class JsonrpcController extends Zend_Controller_Action class JsonrpcController extends Zend_Controller_Action
{ {
public function indexAction() public function indexAction()
{ {
$this->_helper->layout->disableLayout(); $this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(); $this->_helper->viewRenderer->setNoRender();
$request = $this->getRequest(); $request = $this->getRequest();
//Nom du service //Nom du service
$serviceName = strtolower($request->getParam('service', 'Entreprise')); $serviceName = strtolower($request->getParam('service', 'Entreprise'));
//Service spécifique client //Service spécifique client
if ($serviceName == 'clients') { if ($serviceName == 'clients') {
$client = $request->getParam('client', ''); $client = $request->getParam('client', '');
//Liste des clients //Liste des clients
$clients = array(); $clients = array();
$listeClients = include APPLICATION_PATH . '/../library/WsScore/Clients/ClientsConfig.php'; $listeClients = include APPLICATION_PATH . '/../library/WsScore/Clients/ClientsConfig.php';
foreach ( $listeClients as $section => $params ) { foreach ($listeClients as $section => $params) {
if ($params['actif']){ if ($params['actif']) {
$clients[] = $section; $clients[] = $section;
} }
} }
if (!in_array($client, $clients)){ if (!in_array($client, $clients)) {
echo 'Service clients introuvable !'; echo 'Service clients introuvable !';
exit; exit;
} }
$configServiceVersions = $clients[$client]['versions']; $configServiceVersions = $clients[$client]['versions'];
} } else {
else //Service versions
{ $services = include APPLICATION_PATH . '/../library/WsScore/ServicesConfig.php';
//Service versions $configServiceVersions = $services[$serviceName]['versions'];
$services = include APPLICATION_PATH . '/../library/WsScore/ServicesConfig.php'; }
$configServiceVersions = $services[$serviceName]['versions'];
} //Liste des versions
foreach ($configServiceVersions as $section => $params) {
//Liste des versions $serviceVersions[$section] = $params;
foreach( $configServiceVersions as $section => $params ) { if ($params['defaut']) {
$serviceVersions[$section] = $params; $defautVersion = $section;
if ($params['defaut']) { }
$defautVersion = $section; }
} $version = $request->getParam('version', 'v'.$defautVersion);
} $version = substr($version, 1);
$version = $request->getParam('version', 'v'.$defautVersion);
$version = substr($version, 1); // Version inexistante
if (!array_key_exists($version, $serviceVersions)) {
// Version inexistante echo "Version inexistante.";
if ( !array_key_exists($version, $serviceVersions) ) { exit;
echo "Version inexistante."; }
exit; // Version désactivé
} if (!$serviceVersions[$version]['actif']) {
// Version désactivé echo "Version désactivée.";
if ( !$serviceVersions[$version]['actif'] ) { exit;
echo "Version désactivée."; }
exit;
} // Charger les classes et les types pour le service suivant la version
if ($serviceName == 'clients') {
// Charger les classes et les types pour le service suivant la version $pathServiceClassIni = 'WsScore/Clients/'.ucfirst($client).'/v'.$version.'/Entreprise.ini';
if ($serviceName == 'clients') { $pathServiceClassPhp = 'WsScore/Clients/'.ucfirst($client).'/v'.$version.'/Entreprise.php';
$pathServiceClassIni = 'WsScore/Clients/'.ucfirst($client).'/v'.$version.'/Entreprise.ini'; $pathServiceUrl = 'clients/'.$client.'/v'.$version.'?wsdl-auto';
$pathServiceClassPhp = 'WsScore/Clients/'.ucfirst($client).'/v'.$version.'/Entreprise.php'; //On redéfini le nom du service
$pathServiceUrl = 'clients/'.$client.'/v'.$version.'?wsdl-auto'; $serviceName = 'Entreprise';
//On redéfini le nom du service $fichierWsdl = ucfirst($client).'-'.$serviceName.'-'.$version.'.wsdl';
$serviceName = 'Entreprise'; } else {
$fichierWsdl = ucfirst($client).'-'.$serviceName.'-'.$version.'.wsdl'; $pathServiceClassIni = 'WsScore/'.ucfirst($serviceName).'/v'.$version.'/'.ucfirst($serviceName).'.ini';
} else { $pathServiceClassPhp = 'WsScore/'.ucfirst($serviceName).'/v'.$version.'/'.ucfirst($serviceName).'.php';
$pathServiceClassIni = 'WsScore/'.ucfirst($serviceName).'/v'.$version.'/'.ucfirst($serviceName).'.ini'; $pathServiceUrl = $serviceName.'/v'.$version.'?wsdl-auto';
$pathServiceClassPhp = 'WsScore/'.ucfirst($serviceName).'/v'.$version.'/'.ucfirst($serviceName).'.php'; $fichierWsdl = ucfirst($serviceName).'-'.$version.'.wsdl';
$pathServiceUrl = $serviceName.'/v'.$version.'?wsdl-auto'; }
$fichierWsdl = ucfirst($serviceName).'-'.$version.'.wsdl';
} //Génération du tableau de mapping
$wsConfig = new Zend_Config_Ini($pathServiceClassIni);
//Génération du tableau de mapping foreach ($wsConfig->Type->toArray() as $Type) {
$wsConfig = new Zend_Config_Ini($pathServiceClassIni); $classmap[$Type] = $Type;
foreach($wsConfig->Type->toArray() as $Type){ }
$classmap[$Type] = $Type;
} //Inclusion des classes de données
require_once $pathServiceClassPhp;
//Inclusion des classes de données
require_once $pathServiceClassPhp; // Instance du server
$server = new Zend_Json_Server();
// Instance du server // Define class name
$server = new Zend_Json_Server(); $server->setClass(ucfirst($serviceName));
// Define class name
$server->setClass(ucfirst($serviceName)); // Gestion du SMD
if ($this->getRequest()->isGet()) {
// Gestion du SMD // Indiquer URL endpoint
if($this->getRequest()->isGet()){ //$this->getHelper('url')->url(array('controller'=>'', 'action'=>'' ));
// Indiquer URL endpoint $server->setTarget('/jsonrpc/'.$serviceName.'/'.$version.'/')
//$this->getHelper('url')->url(array('controller'=>'', 'action'=>'' )); ->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2);
$server->setTarget('/jsonrpc/'.$serviceName.'/'.$version.'/') // Grab the SMD
->setEnvelope(Zend_Json_Server_Smd::ENV_JSONRPC_2); $smd = $server->getServiceMap();
// Grab the SMD
$smd = $server->getServiceMap(); //Return the SMD to the client
if (!headers_sent()) {
//Return the SMD to the client header('Content-Type: application/json');
if (!headers_sent()) { }
header('Content-Type: application/json'); echo $smd;
} return;
echo $smd; } else {
return; $server->setAutoEmitResponse(true);
} else { $server->handle();
$server->setAutoEmitResponse(true); }
$server->handle(); }
} }
}
}

View File

@ -3,128 +3,126 @@ use League\Csv\Writer;
class RefController extends Zend_Controller_Action class RefController extends Zend_Controller_Action
{ {
public function indexAction() public function indexAction()
{ {
//Ne fait rien... //Ne fait rien...
} }
/** /**
* Donne accès au fichier * Donne accès au fichier
*/ */
public function fichierAction() public function fichierAction()
{ {
//Lecture du nom du fichier //Lecture du nom du fichier
$fichier = $this->_getParam('q',''); $fichier = $this->_getParam('q', '');
$fichier = $fichier . '.csv'; $fichier = $fichier . '.csv';
if (!empty($fichier) && file_exists('fichiers/'.$fichier)) if (!empty($fichier) && file_exists('fichiers/'.$fichier)) {
{ $this->_helper->layout->disableLayout();
$this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender();
$this->_helper->viewRenderer->setNoRender();
list($nomFichier, $extFichier) = explode('.',$fichier); list($nomFichier, $extFichier) = explode('.', $fichier);
//Distribution du fichier sur la sortie standard //Distribution du fichier sur la sortie standard
switch ($extFichier) { switch ($extFichier) {
case 'png' : $content_type = 'image/png'; break; case 'png': $content_type = 'image/png'; break;
case 'gif' : $content_type = 'image/gif'; break; case 'gif': $content_type = 'image/gif'; break;
case 'jpeg': case 'jpeg':
case 'jpg' : $content_type = 'image/jpeg'; break; case 'jpg': $content_type = 'image/jpeg'; break;
case 'pdf' : $content_type = 'application/pdf'; break; case 'pdf': $content_type = 'application/pdf'; break;
case 'csv' : $content_type = 'application/csv-tab-delimited-table'; break; case 'csv': $content_type = 'application/csv-tab-delimited-table'; break;
} }
$this->getResponse()->setHeader('Content-Type', $content_type); $this->getResponse()->setHeader('Content-Type', $content_type);
$contentDisposition = 'attachment'; $contentDisposition = 'attachment';
switch ($contentDisposition) { switch ($contentDisposition) {
case 'inline': case 'inline':
$this->getResponse()->setHeader('Content-Disposition', 'inline'); $this->getResponse()->setHeader('Content-Disposition', 'inline');
break; break;
case 'attachment': case 'attachment':
$this->getResponse()->setHeader('Content-Disposition', "attachment; filename=\"$fichier\""); $this->getResponse()->setHeader('Content-Disposition', "attachment; filename=\"$fichier\"");
break; break;
} }
$data = file_get_contents('assets/fichiers/'.$fichier); $data = file_get_contents('assets/fichiers/'.$fichier);
$this->getResponse()->setHeader('Content-Length', strlen($data)) $this->getResponse()->setHeader('Content-Length', strlen($data))
->setHeader('Cache-Control', 'private, max-age=0, must-revalidate') ->setHeader('Cache-Control', 'private, max-age=0, must-revalidate')
->setHeader('Pragma', 'public') ->setHeader('Pragma', 'public')
->setBody($data); ->setBody($data);
} else { } else {
$this->view->assign('message', 'Fichier introuvable !'); $this->view->assign('message', 'Fichier introuvable !');
} }
} }
/** /**
* Donne accès aux données contenues dans une table de base de données * Donne accès aux données contenues dans une table de base de données
*/ */
public function tableAction() public function tableAction()
{ {
$request = $this->getRequest(); $request = $this->getRequest();
$requetesql = $request->getParam('q',''); $requetesql = $request->getParam('q', '');
$fichierCsv = $requetesql.'.csv'; $fichierCsv = $requetesql.'.csv';
$fichierSql = $requetesql.'.sql'; $fichierSql = $requetesql.'.sql';
//Emplacement des fichiers générés - lien symbolique en PRODUCTION //Emplacement des fichiers générés - lien symbolique en PRODUCTION
$c = Zend_Registry::get('config'); $c = Zend_Registry::get('config');
$path = $c->profil->path->shared . '/files/fichiers/'; $path = $c->profil->path->shared . '/files/fichiers/';
if (!is_dir($path)) { mkdir($path); } if (!is_dir($path)) {
if (!empty($requetesql)) { mkdir($path);
if (!file_exists($path . $fichierCsv)) { }
if (file_exists('assets/sql/'.$fichierSql)) { if (!empty($requetesql)) {
/** if (!file_exists($path . $fichierCsv)) {
* @var \Doctrine\DBAL\Connection $conn if (file_exists('assets/sql/'.$fichierSql)) {
*/ /**
$conn = Zend_Registry::get('doctrine'); * @var \Doctrine\DBAL\Connection $conn
$sql = file_get_contents('assets/sql/'.$fichierSql); */
$stmt = $conn->prepare($sql); $conn = Zend_Registry::get('doctrine');
$stmt->setFetchMode(\PDO::FETCH_ASSOC); $sql = file_get_contents('assets/sql/'.$fichierSql);
$stmt->execute(); $stmt = $conn->prepare($sql);
if ($stmt->rowCount() > 0) { $stmt->setFetchMode(\PDO::FETCH_ASSOC);
$csv = Writer::createFromPath($path . $fichierCsv.'.tmp', 'w'); $stmt->execute();
$csv->setNewline("\r\n"); if ($stmt->rowCount() > 0) {
$headers = array_keys($stmt->fetch()); $csv = Writer::createFromPath($path . $fichierCsv.'.tmp', 'w');
$csv->insertOne($headers); $csv->setNewline("\r\n");
$csv->insertAll($stmt); $headers = array_keys($stmt->fetch());
} $csv->insertOne($headers);
rename($path . $fichierCsv.'.tmp', $path . $fichierCsv); $csv->insertAll($stmt);
} }
} rename($path . $fichierCsv.'.tmp', $path . $fichierCsv);
}
}
if (file_exists($path . $fichierCsv)) { if (file_exists($path . $fichierCsv)) {
$this->_helper->layout->disableLayout(); $this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(); $this->_helper->viewRenderer->setNoRender();
//Distribution du fichier sur la sortie standard //Distribution du fichier sur la sortie standard
list($nomFichier, $extFichier) = explode('.',$fichierCsv); list($nomFichier, $extFichier) = explode('.', $fichierCsv);
switch ($extFichier) switch ($extFichier) {
{ case 'png': $content_type = 'image/png'; break;
case 'png' : $content_type = 'image/png'; break; case 'gif': $content_type = 'image/gif'; break;
case 'gif' : $content_type = 'image/gif'; break; case 'jpeg':
case 'jpeg': case 'jpg': $content_type = 'image/jpeg'; break;
case 'jpg' : $content_type = 'image/jpeg'; break; case 'pdf': $content_type = 'application/pdf'; break;
case 'pdf' : $content_type = 'application/pdf'; break; case 'csv': $content_type = 'application/csv-tab-delimited-table'; break;
case 'csv' : $content_type = 'application/csv-tab-delimited-table'; break; }
} $this->getResponse()->setHeader('Content-Type', $content_type);
$this->getResponse()->setHeader('Content-Type', $content_type); $contentDisposition = 'attachment';
$contentDisposition = 'attachment'; switch ($contentDisposition) {
switch ($contentDisposition) case 'inline':
{ $this->getResponse()->setHeader('Content-Disposition', 'inline');
case 'inline': break;
$this->getResponse()->setHeader('Content-Disposition', 'inline'); case 'attachment':
break; $this->getResponse()->setHeader('Content-Disposition', "attachment; filename=\"$fichierCsv\"");
case 'attachment': break;
$this->getResponse()->setHeader('Content-Disposition', "attachment; filename=\"$fichierCsv\""); }
break;
}
$data = file_get_contents($path . $fichierCsv); $data = file_get_contents($path . $fichierCsv);
$this->getResponse()->setHeader('Content-Length', strlen($data)) $this->getResponse()->setHeader('Content-Length', strlen($data))
->setHeader('Cache-Control', 'private, max-age=0, must-revalidate') ->setHeader('Cache-Control', 'private, max-age=0, must-revalidate')
->setHeader('Pragma', 'public') ->setHeader('Pragma', 'public')
->setBody($data); ->setBody($data);
} }
} else { } else {
$this->view->assign('message', 'Paramètres incorrects !'); $this->view->assign('message', 'Paramètres incorrects !');
} }
} }
}
}

View File

@ -7,191 +7,185 @@ class ServiceController extends Zend_Controller_Action
{ {
public function indexAction() public function indexAction()
{ {
/** /**
* Be sure we don't make any render * Be sure we don't make any render
*/ */
$this->_helper->layout->disableLayout(); $this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender(); $this->_helper->viewRenderer->setNoRender();
$request = $this->getRequest(); $request = $this->getRequest();
// --- Get the service name, make sure the string is in lower case // --- Get the service name, make sure the string is in lower case
$serviceName = strtolower($request->getParam('service', 'Entreprise')); $serviceName = strtolower($request->getParam('service', 'Entreprise'));
// --- ClassName and Directory with first letter capitalized // --- ClassName and Directory with first letter capitalized
$serviceClassName = ucfirst($serviceName); $serviceClassName = ucfirst($serviceName);
// --- Customize service for customers // --- Customize service for customers
if ('clients' == $serviceName) { if ('clients' == $serviceName) {
$client = strtolower($request->getParam('client', '')); $client = strtolower($request->getParam('client', ''));
$clientClassName = ucfirst($client); $clientClassName = ucfirst($client);
// --- Get list of customers // --- Get list of customers
$clients = array(); $clients = array();
$listeClients = include APPLICATION_PATH . '/../library/WsScore/Clients/ClientsConfig.php'; $listeClients = include APPLICATION_PATH . '/../library/WsScore/Clients/ClientsConfig.php';
foreach ( $listeClients as $section => $params ) { foreach ($listeClients as $section => $params) {
if ($params['actif']) { if ($params['actif']) {
$clients[$section] = $params; $clients[$section] = $params;
} }
} }
if (!array_key_exists($client, $clients)) { if (!array_key_exists($client, $clients)) {
echo 'Service clients introuvable !'; echo 'Service clients introuvable !';
exit; exit;
} }
$configServiceVersions = $clients[$client]['versions']; $configServiceVersions = $clients[$client]['versions'];
} }
// --- Service versions // --- Service versions
else { else {
$services = include APPLICATION_PATH . '/../library/WsScore/ServicesConfig.php'; $services = include APPLICATION_PATH . '/../library/WsScore/ServicesConfig.php';
$configServiceVersions = $services[$serviceName]['versions']; $configServiceVersions = $services[$serviceName]['versions'];
} }
// --- Check versions // --- Check versions
foreach ($configServiceVersions as $section => $params) { foreach ($configServiceVersions as $section => $params) {
$serviceVersions[$section] = $params; $serviceVersions[$section] = $params;
if ($params['defaut']) { if ($params['defaut']) {
$defautVersion = $section; $defautVersion = $section;
} }
} }
$version = $request->getParam('version', 'v'.$defautVersion); $version = $request->getParam('version', 'v'.$defautVersion);
$version = substr($version, 1); $version = substr($version, 1);
// --- Version inexistante // --- Version inexistante
if (!array_key_exists($version, $serviceVersions)) { if (!array_key_exists($version, $serviceVersions)) {
echo "Version inexistante."; echo "Version inexistante.";
exit; exit;
} }
// --- Version désactivé // --- Version désactivé
if (!$serviceVersions[$version]['actif']) { if (!$serviceVersions[$version]['actif']) {
echo "Version désactivée."; echo "Version désactivée.";
exit; exit;
} }
// --- Charger les classes et les types pour le service suivant la version // --- Charger les classes et les types pour le service suivant la version
if ('clients' == $serviceName) { if ('clients' == $serviceName) {
$pathServiceClassIni = 'WsScore/Clients/'.$clientClassName.'/v'.$version.'/Config.php'; $pathServiceClassIni = 'WsScore/Clients/'.$clientClassName.'/v'.$version.'/Config.php';
$pathServiceClassPhp = 'WsScore/Clients/'.$clientClassName.'/v'.$version.'/Service.php'; $pathServiceClassPhp = 'WsScore/Clients/'.$clientClassName.'/v'.$version.'/Service.php';
// --- Gestion du mode de génération du wsdl // --- Gestion du mode de génération du wsdl
if ( APPLICATION_ENV == 'development' if (APPLICATION_ENV == 'development'
|| array_key_exists('mode', $serviceVersions[$version]) || array_key_exists('mode', $serviceVersions[$version])
&& $serviceVersions[$version]['mode']=='auto') { && $serviceVersions[$version]['mode']=='auto') {
$pathServiceUrl = 'clients/'.$client.'/v'.$version.'?wsdl-auto'; $pathServiceUrl = 'clients/'.$client.'/v'.$version.'?wsdl-auto';
} } else {
else { $pathServiceUrl = 'clients/'.$client.'/v'.$version.'?wsdl';
$pathServiceUrl = 'clients/'.$client.'/v'.$version.'?wsdl'; }
} // --- On redéfini le nom du service
// --- On redéfini le nom du service $serviceClassName = 'Entreprise';
$serviceClassName = 'Entreprise'; $fichierWsdl = $clientClassName.'-'.$serviceClassName.'-'.$version.'.wsdl';
$fichierWsdl = $clientClassName.'-'.$serviceClassName.'-'.$version.'.wsdl'; } else {
} $pathServiceClassIni = 'WsScore/'.$serviceClassName.'/v'.$version.'/Config.php';
else { $pathServiceClassPhp = 'WsScore/'.$serviceClassName.'/v'.$version.'/Service.php';
$pathServiceClassIni = 'WsScore/'.$serviceClassName.'/v'.$version.'/Config.php'; // --- Gestion du mode de génération du wsdl
$pathServiceClassPhp = 'WsScore/'.$serviceClassName.'/v'.$version.'/Service.php'; if (APPLICATION_ENV == 'development'
// --- Gestion du mode de génération du wsdl || array_key_exists('mode', $serviceVersions[$version])
if ( APPLICATION_ENV == 'development' && $serviceVersions[$version]['mode']=='auto') {
|| array_key_exists('mode', $serviceVersions[$version]) $pathServiceUrl = $serviceName.'/v'.$version.'?wsdl-auto';
&& $serviceVersions[$version]['mode']=='auto') { } else {
$pathServiceUrl = $serviceName.'/v'.$version.'?wsdl-auto'; $pathServiceUrl = $serviceName.'/v'.$version.'?wsdl';
} }
else { $fichierWsdl = $serviceClassName.'-'.$version.'.wsdl';
$pathServiceUrl = $serviceName.'/v'.$version.'?wsdl'; }
}
$fichierWsdl = $serviceClassName.'-'.$version.'.wsdl';
} // --- Get map of WSDL type to PHP Classes
$classmap = include $pathServiceClassIni;
// --- Get map of WSDL type to PHP Classes // --- Inclusion des classes de données
$classmap = include $pathServiceClassIni; require_once $pathServiceClassPhp;
// --- Inclusion des classes de données // --- Get hostname - add compatibility with Reverse Proxy
require_once $pathServiceClassPhp; $hostName = $this->getRequest()->getHttpHost();
// --- Get hostname - add compatibility with Reverse Proxy
$hostName = $this->getRequest()->getHttpHost();
$fichierWsdl = $hostName . '-' . $fichierWsdl; $fichierWsdl = $hostName . '-' . $fichierWsdl;
$c = Zend_registry::get('config'); $c = Zend_registry::get('config');
$wsdlPath = $c->profil->path->shared . '/wsdl'; $wsdlPath = $c->profil->path->shared . '/wsdl';
// --- Fourniture du wsdl // --- Fourniture du wsdl
if (isset($_GET['wsdl']) && file_exists($wsdlPath . '/' . $fichierWsdl)) { if (isset($_GET['wsdl']) && file_exists($wsdlPath . '/' . $fichierWsdl)) {
if (!headers_sent()) { if (!headers_sent()) {
header('Content-Type: text/xml'); header('Content-Type: text/xml');
} }
readfile($wsdlPath . '/' . $fichierWsdl); readfile($wsdlPath . '/' . $fichierWsdl);
} } elseif (isset($_GET['wsdl']) && !file_exists($wsdlPath . '/' . $fichierWsdl)
elseif ( isset($_GET['wsdl']) && !file_exists($wsdlPath . '/' . $fichierWsdl)
|| isset($_GET['wsdl-generate']) || isset($_GET['wsdl-generate'])
|| isset($_GET['wsdl-auto']) ) { || isset($_GET['wsdl-auto'])) {
// --- Définition du webservice // --- Définition du webservice
$wsdl = new Zend_Soap_AutoDiscover(); $wsdl = new Zend_Soap_AutoDiscover();
$wsdl->setComplexTypeStrategy('Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence'); $wsdl->setComplexTypeStrategy('Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence');
$wsdl->setOperationBodyStyle( array('use' => 'literal') ); $wsdl->setOperationBodyStyle(array('use' => 'literal'));
$wsdl->setBindingStyle( array('style' => 'document') ); $wsdl->setBindingStyle(array('style' => 'document'));
$wsdl->setClass($serviceClassName); $wsdl->setClass($serviceClassName);
// --- Enregistrement du WSDL dans un fichier // --- Enregistrement du WSDL dans un fichier
if ( isset($_GET['wsdl-generate']) ) { if (isset($_GET['wsdl-generate'])) {
if (file_exists($wsdlPath . '/' . $fichierWsdl)) { if (file_exists($wsdlPath . '/' . $fichierWsdl)) {
unlink($wsdlPath . '/' . $fichierWsdl); unlink($wsdlPath . '/' . $fichierWsdl);
} }
$wsdl->dump($wsdlPath . '/' . $fichierWsdl); $wsdl->dump($wsdlPath . '/' . $fichierWsdl);
echo "Le fichier $fichierWsdl a été généré"; echo "Le fichier $fichierWsdl a été généré";
// --- Génération/Fourniture du wsdl // --- Génération/Fourniture du wsdl
} elseif (isset($_GET['wsdl']) && !file_exists($wsdlPath . '/' . $fichierWsdl)) { } elseif (isset($_GET['wsdl']) && !file_exists($wsdlPath . '/' . $fichierWsdl)) {
$wsdl->dump($wsdlPath . '/' . $fichierWsdl); $wsdl->dump($wsdlPath . '/' . $fichierWsdl);
if ( !headers_sent() ) { if (!headers_sent()) {
header('Content-Type: text/xml'); header('Content-Type: text/xml');
} }
readfile($wsdlPath . '/' . $fichierWsdl); readfile($wsdlPath . '/' . $fichierWsdl);
} }
// --- Envoi sur la sortie standard le wsdl sans enregistrement dans un fichier // --- Envoi sur la sortie standard le wsdl sans enregistrement dans un fichier
elseif ( isset($_GET['wsdl-auto']) ){ elseif (isset($_GET['wsdl-auto'])) {
$wsdl->handle(); $wsdl->handle();
} }
} }
// --- Fourniture du service // --- Fourniture du service
else { else {
// --- Traitement // --- Traitement
if (in_array(APPLICATION_ENV, array('production', 'staging')) if (in_array(APPLICATION_ENV, array('production', 'staging'))
&& file_exists($wsdlPath . '/' . $fichierWsdl)) { && file_exists($wsdlPath . '/' . $fichierWsdl)) {
$server = new Zend_Soap_Server($wsdlPath . '/' . $fichierWsdl); $server = new Zend_Soap_Server($wsdlPath . '/' . $fichierWsdl);
} } else {
else { $server = new Zend_Soap_Server('http://'.$hostName.'/'.$pathServiceUrl);
$server = new Zend_Soap_Server('http://'.$hostName.'/'.$pathServiceUrl); }
}
// --- Sonde paramètres server // --- Sonde paramètres server
$debug = false; $debug = false;
$debugUser = ''; $debugUser = '';
if ($debug && $_SERVER['PHP_AUTH_USER'] == $debugUser) { if ($debug && $_SERVER['PHP_AUTH_USER'] == $debugUser) {
file_put_contents(APPLICATION_PATH . '/../debugserver.log', file_put_contents(APPLICATION_PATH . '/../debugserver.log',
"FichierWSDL : ".$fichierWsdl."\n". "FichierWSDL : ".$fichierWsdl."\n".
"Hostname : ".$hostName."\n" "Hostname : ".$hostName."\n"
); );
} }
// --- Options et traitement de la requete // --- Options et traitement de la requete
$server->setSoapFeatures(SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS); $server->setSoapFeatures(SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS);
$server->setClassmap($classmap); $server->setClassmap($classmap);
$server->setEncoding('UTF-8'); $server->setEncoding('UTF-8');
$server->registerFaultException(array('Scores_Ws_Exception')); $server->registerFaultException(array('Scores_Ws_Exception'));
$server->setWsiCompliant(true); $server->setWsiCompliant(true);
// --- Création du service // --- Création du service
$server->setObject(new $serviceClassName()); $server->setObject(new $serviceClassName());
$server->handle(); $server->handle();
// --- Pour débuggage ultime // --- Pour débuggage ultime
$debug = false; $debug = false;
$debugUser = ''; $debugUser = '';
if ($debug && $_SERVER['PHP_AUTH_USER'] == $debugUser) { if ($debug && $_SERVER['PHP_AUTH_USER'] == $debugUser) {
file_put_contents(APPLICATION_PATH . '/../debugcall.log', file_put_contents(APPLICATION_PATH . '/../debugcall.log',
"FichierWSDL : ".$fichierWsdl."\n"."Hostname : ".$hostName."\n"); "FichierWSDL : ".$fichierWsdl."\n"."Hostname : ".$hostName."\n");
$request = $server->getLastRequest(); $request = $server->getLastRequest();
file_put_contents(APPLICATION_PATH . '/../debugcall.log', $request . "\n", FILE_APPEND); file_put_contents(APPLICATION_PATH . '/../debugcall.log', $request . "\n", FILE_APPEND);
$response = $server->getLastResponse(); $response = $server->getLastResponse();
file_put_contents(APPLICATION_PATH . '/../debugcall.log', $response. "\n", FILE_APPEND); file_put_contents(APPLICATION_PATH . '/../debugcall.log', $response. "\n", FILE_APPEND);
} }
} }
} }
} }

View File

@ -1,56 +1,54 @@
<?php <?php
class UserController extends Zend_Controller_Action class UserController extends Zend_Controller_Action
{ {
public function indexAction() public function indexAction()
{
}
public function loginAction()
{ {
$this->_helper->layout()->disableLayout(); }
$this->view->headLink()->appendStylesheet('/assets/themes/default/css/signin.css', 'all'); public function loginAction()
{
$this->_helper->layout()->disableLayout();
$this->view->headTitle()->append('Connexion'); $this->view->headLink()->appendStylesheet('/assets/themes/default/css/signin.css', 'all');
$form = new Application_Form_Login();
$this->view->form = $form;
$request = $this->getRequest();
if ($request->isPost()) {
$formData = $request->getPost();
if ($form->isValid($formData)) {
$login = $form->getValue('login');
$pass = $form->getValue('pass');
$auth = Zend_Auth::getInstance();
$authAdapter = new Scores_Auth_Adapter_Db($login, $pass, true);
$result = $auth->authenticate($authAdapter);
if ($result->isValid()) {
$timeout = $auth->getIdentity()->timeout;
//Ecrit un cookie persistant valide pendant le temps definit $this->view->headTitle()->append('Connexion');
Zend_Session::rememberMe($timeout); $form = new Application_Form_Login();
$this->view->form = $form;
$request = $this->getRequest();
if ($request->isPost()) {
$formData = $request->getPost();
if ($form->isValid($formData)) {
$login = $form->getValue('login');
$pass = $form->getValue('pass');
$auth = Zend_Auth::getInstance();
$authAdapter = new Scores_Auth_Adapter_Db($login, $pass, true);
$result = $auth->authenticate($authAdapter);
if ($result->isValid()) {
$timeout = $auth->getIdentity()->timeout;
$storage = new Zend_Auth_Storage_Session(); //Ecrit un cookie persistant valide pendant le temps definit
$sessionNamespace = new Zend_Session_Namespace($storage->getNamespace()); Zend_Session::rememberMe($timeout);
$sessionNamespace->setExpirationSeconds($timeout);
$auth->setStorage($storage);
$this->redirect('/'); $storage = new Zend_Auth_Storage_Session();
} else { $sessionNamespace = new Zend_Session_Namespace($storage->getNamespace());
$this->view->message = ''; $sessionNamespace->setExpirationSeconds($timeout);
foreach ($result->getMessages() as $message) { $auth->setStorage($storage);
$this->view->message.= $message."<br/>";
}
}
} $this->redirect('/');
} } else {
$this->view->message = '';
foreach ($result->getMessages() as $message) {
$this->view->message.= $message."<br/>";
}
}
}
}
} }
public function logoutAction() public function logoutAction()
{ {
$this->_helper->layout()->disableLayout(); $this->_helper->layout()->disableLayout();
Zend_Auth::getInstance()->clearIdentity(); Zend_Auth::getInstance()->clearIdentity();
} }
public function paramsAction() public function paramsAction()
@ -120,9 +118,9 @@ class UserController extends Zend_Controller_Action
); );
$display = array(); $display = array();
foreach ( $listdroit as $droit ) { foreach ($listdroit as $droit) {
foreach ( $assoc as $l => $d ) { foreach ($assoc as $l => $d) {
if ( in_array(strtoupper($droit), $d) ) { if (in_array(strtoupper($droit), $d)) {
$display[] = array( $display[] = array(
'label' => $l, 'label' => $l,
'droit' => $droit, 'droit' => $droit,
@ -132,4 +130,4 @@ class UserController extends Zend_Controller_Action
} }
$this->view->display = $display; $this->view->display = $display;
} }
} }

View File

@ -1,8 +1,7 @@
<?php <?php
class Zend_View_Helper_DocComplement extends Zend_View_Helper_Abstract class Zend_View_Helper_DocComplement extends Zend_View_Helper_Abstract
{ {
public function docComplement($method) public function docComplement($method)
{ {
}
} }
}

View File

@ -1,8 +1,8 @@
<?php <?php
class Zend_View_Helper_DocDescription extends Zend_View_Helper_Abstract class Zend_View_Helper_DocDescription extends Zend_View_Helper_Abstract
{ {
public function docDescription($method) public function docDescription($method)
{ {
return $method['desc']; return $method['desc'];
} }
} }

View File

@ -1,31 +1,31 @@
<?php <?php
class Zend_View_Helper_DocExemple extends Zend_View_Helper_Abstract class Zend_View_Helper_DocExemple extends Zend_View_Helper_Abstract
{ {
public function docExemple($method) public function docExemple($method)
{ {
$exemple = ''; $exemple = '';
$langages = array( $langages = array(
'php' => 'PHP', 'php' => 'PHP',
'java' => 'Java', 'java' => 'Java',
'perl' => 'Perl', 'perl' => 'Perl',
'python' => 'Python', 'python' => 'Python',
'csharp' => 'C#' 'csharp' => 'C#'
); );
foreach ($langages as $langage => $lib){ foreach ($langages as $langage => $lib) {
$fichier = 'assets/code/'.$method.'-'.$langage.'.txt'; $fichier = 'assets/code/'.$method.'-'.$langage.'.txt';
if (file_exists($fichier)){ if (file_exists($fichier)) {
$url = $this->view->url( $url = $this->view->url(
array( array(
'controller' => 'documentation', 'controller' => 'documentation',
'action' => 'code', 'action' => 'code',
'langage' => $langage, 'langage' => $langage,
'element' => $method, 'element' => $method,
), null, true); ), null, true);
$exemple.= '<a href="'.$url.'">' . $lib . '</a>'; $exemple.= '<a href="'.$url.'">' . $lib . '</a>';
$exemple.= '&nbsp;'; $exemple.= '&nbsp;';
} }
} }
return $exemple; return $exemple;
} }
} }

View File

@ -1,61 +1,59 @@
<?php <?php
class Zend_View_Helper_DocMethod extends Zend_View_Helper_Abstract class Zend_View_Helper_DocMethod extends Zend_View_Helper_Abstract
{ {
protected $_transcodeType = array(
'str' => 'string',
'bool' => 'boolean',
'integer' => 'int',
);
protected $_transcodeType = array( public function docMethod($method)
'str' => 'string', {
'bool' => 'boolean', $output = '';
'integer' => 'int',
);
public function docMethod($method) $returnType = $method['return'];
{ $methodName = $method['name'];
$output = '';
$returnType = $method['return']; $cptParameters = 0;
$methodName = $method['name']; $parameters = '';
foreach ($method['params'] as $param) {
if (isset($param['optional'])) {
$parameters.= '[';
}
$parameters.= '<i>' . $this->transcodeType($param['type']) . '</i>';
$parameters.= '&nbsp;';
$parameters.= '<b>' . $param['name'] . '</b>';
$cptParameters = 0; if (isset($param['optional'])) {
$parameters = ''; if (isset($param['defaultValue'])) {
foreach ($method['params'] as $param) { $parameters.= ' = ';
if (isset($param['optional'])) { if (is_bool($param['defaultValue'])) {
$parameters.= '['; $parameters.= ($param['defaultValue'] === false) ? 'false' : 'true' ;
} } elseif (is_string($param['defaultValue']) && $param['defaultValue']=='') {
$parameters.= '<i>' . $this->transcodeType($param['type']) . '</i>'; $parameters.= "''";
$parameters.= '&nbsp;'; } else {
$parameters.= '<b>' . $param['name'] . '</b>'; $parameters.= $param['defaultValue'];
}
if (isset($param['optional'])) { }
if (isset($param['defaultValue'])) { $parameters.= ']';
$parameters.= ' = '; }
if (is_bool($param['defaultValue'])){ $cptParameters++;
$parameters.= ($param['defaultValue'] === false) ? 'false' : 'true' ; if ($cptParameters < count($method['params'])) {
} elseif (is_string($param['defaultValue']) && $param['defaultValue']==''){ $parameters.= ', ';
$parameters.= "''"; }
} else { }
$parameters.= $param['defaultValue']; $output = '<i>' . $this->transcodeType($returnType) . '</i>';
} $output.= ' ';
} $output.= '<b>' . $methodName . '</b>' . ' <b>(</b> ' . $parameters . ' <b>)</b>';
$parameters.= ']'; return $output;
} }
$cptParameters++;
if ($cptParameters < count($method['params'])){
$parameters.= ', ';
}
}
$output = '<i>' . $this->transcodeType($returnType) . '</i>';
$output.= ' ';
$output.= '<b>' . $methodName . '</b>' . ' <b>(</b> ' . $parameters . ' <b>)</b>';
return $output;
}
private function transcodeType($type)
{
if(array_key_exists($type, $this->_transcodeType)){
return $this->_transcodeType[$type];
} else {
return $type;
}
}
private function transcodeType($type)
{
if (array_key_exists($type, $this->_transcodeType)) {
return $this->_transcodeType[$type];
} else {
return $type;
}
}
} }

View File

@ -1,81 +1,80 @@
<?php <?php
class Zend_View_Helper_DocParameter extends Zend_View_Helper_Abstract class Zend_View_Helper_DocParameter extends Zend_View_Helper_Abstract
{ {
protected $serviceTypes; protected $serviceTypes;
protected $types = array( protected $types = array(
'string', 'str', 'string', 'str',
'boolean', 'bool', 'boolean', 'bool',
'int', 'integer', 'long', 'int', 'integer', 'long',
'float', 'double', 'float', 'double',
'array', 'object', 'mixed' 'array', 'object', 'mixed'
); );
protected $_transcodeType = array( protected $_transcodeType = array(
'str' => 'string', 'str' => 'string',
'bool' => 'boolean', 'bool' => 'boolean',
'integer' => 'int', 'integer' => 'int',
); );
public function docParameter($params, $serviceTypes) public function docParameter($params, $serviceTypes)
{ {
$this->serviceTypes = $serviceTypes; $this->serviceTypes = $serviceTypes;
$output = ''; $output = '';
if (count($params)>0) { if (count($params)>0) {
$output.= '<ul>'; $output.= '<ul>';
foreach ($params as $param) { foreach ($params as $param) {
$output.= $this->formatParam($param); $output.= $this->formatParam($param);
} }
$output.= '</ul>'; $output.= '</ul>';
} }
return $output; return $output;
} }
private function parseType($type) private function parseType($type)
{ {
$output = ''; $output = '';
$type = str_replace('[]', '', $type); $type = str_replace('[]', '', $type);
if (array_key_exists($type, $this->serviceTypes)) { if (array_key_exists($type, $this->serviceTypes)) {
$types = $this->serviceTypes[$type]; $types = $this->serviceTypes[$type];
$output.= '<ul>'; $output.= '<ul>';
foreach ($types as $param) { foreach ($types as $param) {
$output.= $this->formatParam($param); $output.= $this->formatParam($param);
} }
$output.= '</ul>'; $output.= '</ul>';
} elseif (in_array($type, $this->types)) { } elseif (in_array($type, $this->types)) {
$output.= ''; $output.= '';
} elseif ($type == 'void'){ } elseif ($type == 'void') {
$output.= 'Void'; $output.= 'Void';
} else { } else {
$output.= ' => <b>Type '.$type.' inconnu</b>'; $output.= ' => <b>Type '.$type.' inconnu</b>';
} }
return $output; return $output;
} }
private function formatParam($param) private function formatParam($param)
{ {
$output = ''; $output = '';
$output.= '<li>'; $output.= '<li>';
$output.= '<i>' . $this->transcodeType($param['type']) . '</i>'; $output.= '<i>' . $this->transcodeType($param['type']) . '</i>';
$output.= ' '; $output.= ' ';
$output.= '<b>' . $param['name'] . '</b>'; $output.= '<b>' . $param['name'] . '</b>';
if (isset($param['description']) && !empty($param['description'])) { if (isset($param['description']) && !empty($param['description'])) {
$output.= ' - '.$param['description']; $output.= ' - '.$param['description'];
} }
if (!in_array($param['type'], $this->types)) { if (!in_array($param['type'], $this->types)) {
$output.= $this->parseType($param['type']); $output.= $this->parseType($param['type']);
} }
$output.= '</li>'; $output.= '</li>';
return $output; return $output;
} }
private function transcodeType($type) private function transcodeType($type)
{ {
if(array_key_exists($type, $this->_transcodeType)){ if (array_key_exists($type, $this->_transcodeType)) {
return $this->_transcodeType[$type]; return $this->_transcodeType[$type];
} else { } else {
return $type; return $type;
} }
} }
}
}

View File

@ -1,74 +1,73 @@
<?php <?php
class Zend_View_Helper_DocReturn extends Zend_View_Helper_Abstract class Zend_View_Helper_DocReturn extends Zend_View_Helper_Abstract
{ {
protected $serviceTypes; protected $serviceTypes;
protected $types = array( protected $types = array(
'string', 'str', 'string', 'str',
'boolean', 'bool', 'boolean', 'bool',
'integer', 'int', 'long', 'integer', 'int', 'long',
'float', 'double', 'float', 'double',
'array', 'object', 'mixed' 'array', 'object', 'mixed'
); );
protected $_transcodeType = array( protected $_transcodeType = array(
'str' => 'string', 'str' => 'string',
'bool' => 'boolean', 'bool' => 'boolean',
'integer' => 'int', 'integer' => 'int',
); );
public function docReturn($type, $serviceTypes) public function docReturn($type, $serviceTypes)
{ {
$this->serviceTypes = $serviceTypes; $this->serviceTypes = $serviceTypes;
return $this->parseType($type); return $this->parseType($type);
} }
private function parseType($type) private function parseType($type)
{ {
$output = ''; $output = '';
$type = str_replace('[]', '', $type); $type = str_replace('[]', '', $type);
if (array_key_exists($type, $this->serviceTypes)) { if (array_key_exists($type, $this->serviceTypes)) {
$types = $this->serviceTypes[$type]; $types = $this->serviceTypes[$type];
$output.= '<ul>'; $output.= '<ul>';
foreach ($types as $param) { foreach ($types as $param) {
$output.= $this->formatParam($param); $output.= $this->formatParam($param);
} }
$output.= '</ul>'; $output.= '</ul>';
} elseif (in_array($type, $this->types)) { } elseif (in_array($type, $this->types)) {
$output.= '<i>' . $type . '</i> '; $output.= '<i>' . $type . '</i> ';
} elseif ($type == 'void'){ } elseif ($type == 'void') {
$output.= 'Void'; $output.= 'Void';
} else { } else {
$output.= ' => <b>Type '.$type.' inconnu</b>'; $output.= ' => <b>Type '.$type.' inconnu</b>';
} }
return $output; return $output;
} }
private function formatParam($param) private function formatParam($param)
{ {
$output = ''; $output = '';
$output.= '<li>'; $output.= '<li>';
$output.= '<i>' . $this->transcodeType($param['type']) . '</i>'; $output.= '<i>' . $this->transcodeType($param['type']) . '</i>';
$output.= ' '; $output.= ' ';
$output.= '<b>'. $param['name'] . '</b>'; $output.= '<b>'. $param['name'] . '</b>';
if (isset($param['description']) && !empty($param['description'])) { if (isset($param['description']) && !empty($param['description'])) {
$output.= ' - '.$param['description']; $output.= ' - '.$param['description'];
} }
$type = str_replace('[]', '', $param['type']); $type = str_replace('[]', '', $param['type']);
if (!in_array($type, $this->types)) { if (!in_array($type, $this->types)) {
$output.= $this->parseType($param['type']); $output.= $this->parseType($param['type']);
} }
$output.= '</li>'; $output.= '</li>';
return $output; return $output;
} }
private function transcodeType($type)
{
if(array_key_exists($type, $this->_transcodeType)){
return $this->_transcodeType[$type];
} else {
return $type;
}
}
private function transcodeType($type)
{
if (array_key_exists($type, $this->_transcodeType)) {
return $this->_transcodeType[$type];
} else {
return $type;
}
}
} }

View File

@ -2,16 +2,16 @@
class Zend_View_Helper_ProfileLink extends Zend_View_Helper_Abstract class Zend_View_Helper_ProfileLink extends Zend_View_Helper_Abstract
{ {
public function profileLink() public function profileLink()
{ {
$auth = Zend_Auth::getInstance(); $auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) { if ($auth->hasIdentity()) {
$username = $auth->getIdentity()->username; $username = $auth->getIdentity()->username;
$logoutUrl = $this->view->url(array( $logoutUrl = $this->view->url(array(
'controller' => 'user', 'controller' => 'user',
'action' => 'logout' 'action' => 'logout'
), null, true); ), null, true);
return '<a href="'.$logoutUrl.'" title="Se déconnecter" class="navbar-link">Déconnexion : ' . $username . '</a>'; return '<a href="'.$logoutUrl.'" title="Se déconnecter" class="navbar-link">Déconnexion : ' . $username . '</a>';
} }
} }
} }