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_USER', $config->profil->db->metier->params->username);
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
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
protected function _initViewSettings()
{
$this->bootstrap('view');
protected function _initViewSettings()
{
$this->bootstrap('view');
$view = $this->getResource('view');
$view->setEncoding('UTF-8');
$view->doctype('HTML5');
$view = $this->getResource('view');
$view->setEncoding('UTF-8');
$view->doctype('HTML5');
$view->headMeta()
->appendName('viewport', 'width=device-width, initial-scale=1.0')
->appendHttpEquiv('X-UA-Compatible', 'IE=edge')
->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8')
$view->headMeta()
->appendName('viewport', 'width=device-width, initial-scale=1.0')
->appendHttpEquiv('X-UA-Compatible', 'IE=edge')
->appendHttpEquiv('Content-Type', 'text/html; charset=UTF-8')
->appendHttpEquiv('Content-Language', 'fr-FR');
//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')
);
//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')
);
$view->headLink()
->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/main.css', 'all');
$view->headLink()
->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/main.css', 'all');
$view->headScript()
->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/jquery-1.12.4.min.js', 'text/javascript')
->appendFile('/assets/libs/bootstrap-3.3.7/js/bootstrap.min.js', 'text/javascript');
$view->headScript()
->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/jquery-1.12.4.min.js', 'text/javascript')
->appendFile('/assets/libs/bootstrap-3.3.7/js/bootstrap.min.js', 'text/javascript');
$view->headTitle()->setSeparator(' - ');
$view->headTitle('Web Service API - Scores & Decisions');
}
$view->headTitle()->setSeparator(' - ');
$view->headTitle('Web Service API - Scores & Decisions');
}
protected function _initRouter()
{
$this->bootstrap('frontController');
$front = $this->getResource('frontController');
$router = $front->getRouter();
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);
}
}
// 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 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);
// 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;
}
$fichierRoute = new Zend_Controller_Router_Route('fichier/:action/:fichier', array(
'controller' => 'fichier',
'fichier' => '',
));
$router->addRoute('fichier', $fichierRoute);
return $router;
}
protected function _initDb()
{
$c = new Zend_Config($this->getOptions());
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;
}
protected function _initDb()
{
$c = new Zend_Config($this->getOptions());
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);
}
/**
* Set the default adapter to use with all model
*/
Zend_Db_Table::setDefaultAdapter($db);
}
protected function _initDoctrine()
{
$c = new Zend_Config($this->getOptions());
protected function _initDoctrine()
{
$c = new Zend_Config($this->getOptions());
$config = new \Doctrine\DBAL\Configuration();
$config = new \Doctrine\DBAL\Configuration();
if (APPLICATION_ENV == 'development') {
$logger = new Scores_Logger_Sql();
$config->setSQLLogger($logger);
}
if (APPLICATION_ENV == 'development') {
$logger = new Scores_Logger_Sql();
$config->setSQLLogger($logger);
}
$connectionParams = array(
'dbname' => $c->profil->db->metier->params->dbname,
'user' => $c->profil->db->metier->params->username,
'password' => $c->profil->db->metier->params->password,
'host' => $c->profil->db->metier->params->host,
'charset' => 'utf8',
'driver' => 'pdo_mysql',
);
$connectionParams = array(
'dbname' => $c->profil->db->metier->params->dbname,
'user' => $c->profil->db->metier->params->username,
'password' => $c->profil->db->metier->params->password,
'host' => $c->profil->db->metier->params->host,
'charset' => 'utf8',
'driver' => 'pdo_mysql',
);
try {
try {
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
} catch (\Doctrine\DBAL\DBALException $e) {
if (APPLICATION_ENV == 'development') {
echo '<pre>'; print_r($e); echo '</pre>';
} else {
echo "Le service rencontre actuellement un problème technique.";
}
exit;
}
} catch (\Doctrine\DBAL\DBALException $e) {
if (APPLICATION_ENV == 'development') {
echo '<pre>';
print_r($e);
echo '</pre>';
} else {
echo "Le service rencontre actuellement un problème technique.";
}
exit;
}
Zend_Registry::set('doctrine', $conn);
}
}
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);
}
}
}
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);
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,61 +1,59 @@
<?php
class Zend_View_Helper_DocMethod extends Zend_View_Helper_Abstract
{
protected $_transcodeType = array(
'str' => 'string',
'bool' => 'boolean',
'integer' => 'int',
);
protected $_transcodeType = array(
'str' => 'string',
'bool' => 'boolean',
'integer' => 'int',
);
public function docMethod($method)
{
$output = '';
public function docMethod($method)
{
$output = '';
$returnType = $method['return'];
$methodName = $method['name'];
$returnType = $method['return'];
$methodName = $method['name'];
$cptParameters = 0;
$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;
$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>';
if (isset($param['optional'])) {
if (isset($param['defaultValue'])) {
$parameters.= ' = ';
if (is_bool($param['defaultValue'])){
$parameters.= ($param['defaultValue'] === false) ? 'false' : 'true' ;
} elseif (is_string($param['defaultValue']) && $param['defaultValue']==''){
$parameters.= "''";
} else {
$parameters.= $param['defaultValue'];
}
}
$parameters.= ']';
}
$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;
}
}
if (isset($param['optional'])) {
if (isset($param['defaultValue'])) {
$parameters.= ' = ';
if (is_bool($param['defaultValue'])) {
$parameters.= ($param['defaultValue'] === false) ? 'false' : 'true' ;
} elseif (is_string($param['defaultValue']) && $param['defaultValue']=='') {
$parameters.= "''";
} else {
$parameters.= $param['defaultValue'];
}
}
$parameters.= ']';
}
$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;
}
}
}

View File

@ -1,81 +1,80 @@
<?php
class Zend_View_Helper_DocParameter extends Zend_View_Helper_Abstract
{
protected $serviceTypes;
protected $serviceTypes;
protected $types = array(
'string', 'str',
'boolean', 'bool',
'int', 'integer', 'long',
'float', 'double',
'array', 'object', 'mixed'
);
protected $types = array(
'string', 'str',
'boolean', 'bool',
'int', 'integer', 'long',
'float', 'double',
'array', 'object', 'mixed'
);
protected $_transcodeType = array(
'str' => 'string',
'bool' => 'boolean',
'integer' => 'int',
);
protected $_transcodeType = array(
'str' => 'string',
'bool' => 'boolean',
'integer' => 'int',
);
public function docParameter($params, $serviceTypes)
{
$this->serviceTypes = $serviceTypes;
$output = '';
if (count($params)>0) {
$output.= '<ul>';
foreach ($params as $param) {
$output.= $this->formatParam($param);
}
$output.= '</ul>';
}
return $output;
}
public function docParameter($params, $serviceTypes)
{
$this->serviceTypes = $serviceTypes;
$output = '';
if (count($params)>0) {
$output.= '<ul>';
foreach ($params as $param) {
$output.= $this->formatParam($param);
}
$output.= '</ul>';
}
return $output;
}
private function parseType($type)
{
$output = '';
$type = str_replace('[]', '', $type);
if (array_key_exists($type, $this->serviceTypes)) {
$types = $this->serviceTypes[$type];
$output.= '<ul>';
foreach ($types as $param) {
$output.= $this->formatParam($param);
}
$output.= '</ul>';
} elseif (in_array($type, $this->types)) {
$output.= '';
} elseif ($type == 'void'){
$output.= 'Void';
} else {
$output.= ' => <b>Type '.$type.' inconnu</b>';
}
return $output;
}
private function parseType($type)
{
$output = '';
$type = str_replace('[]', '', $type);
if (array_key_exists($type, $this->serviceTypes)) {
$types = $this->serviceTypes[$type];
$output.= '<ul>';
foreach ($types as $param) {
$output.= $this->formatParam($param);
}
$output.= '</ul>';
} elseif (in_array($type, $this->types)) {
$output.= '';
} elseif ($type == 'void') {
$output.= 'Void';
} else {
$output.= ' => <b>Type '.$type.' inconnu</b>';
}
return $output;
}
private function formatParam($param)
{
$output = '';
$output.= '<li>';
$output.= '<i>' . $this->transcodeType($param['type']) . '</i>';
$output.= ' ';
$output.= '<b>' . $param['name'] . '</b>';
if (isset($param['description']) && !empty($param['description'])) {
$output.= ' - '.$param['description'];
}
if (!in_array($param['type'], $this->types)) {
$output.= $this->parseType($param['type']);
}
$output.= '</li>';
return $output;
}
private function formatParam($param)
{
$output = '';
$output.= '<li>';
$output.= '<i>' . $this->transcodeType($param['type']) . '</i>';
$output.= ' ';
$output.= '<b>' . $param['name'] . '</b>';
if (isset($param['description']) && !empty($param['description'])) {
$output.= ' - '.$param['description'];
}
if (!in_array($param['type'], $this->types)) {
$output.= $this->parseType($param['type']);
}
$output.= '</li>';
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,74 +1,73 @@
<?php
class Zend_View_Helper_DocReturn extends Zend_View_Helper_Abstract
{
protected $serviceTypes;
protected $serviceTypes;
protected $types = array(
'string', 'str',
'boolean', 'bool',
'integer', 'int', 'long',
'float', 'double',
'array', 'object', 'mixed'
);
protected $types = array(
'string', 'str',
'boolean', 'bool',
'integer', 'int', 'long',
'float', 'double',
'array', 'object', 'mixed'
);
protected $_transcodeType = array(
'str' => 'string',
'bool' => 'boolean',
'integer' => 'int',
);
protected $_transcodeType = array(
'str' => 'string',
'bool' => 'boolean',
'integer' => 'int',
);
public function docReturn($type, $serviceTypes)
{
$this->serviceTypes = $serviceTypes;
return $this->parseType($type);
}
public function docReturn($type, $serviceTypes)
{
$this->serviceTypes = $serviceTypes;
return $this->parseType($type);
}
private function parseType($type)
{
$output = '';
$type = str_replace('[]', '', $type);
if (array_key_exists($type, $this->serviceTypes)) {
$types = $this->serviceTypes[$type];
$output.= '<ul>';
foreach ($types as $param) {
$output.= $this->formatParam($param);
}
$output.= '</ul>';
} elseif (in_array($type, $this->types)) {
$output.= '<i>' . $type . '</i> ';
} elseif ($type == 'void'){
$output.= 'Void';
} else {
$output.= ' => <b>Type '.$type.' inconnu</b>';
}
return $output;
}
private function parseType($type)
{
$output = '';
$type = str_replace('[]', '', $type);
if (array_key_exists($type, $this->serviceTypes)) {
$types = $this->serviceTypes[$type];
$output.= '<ul>';
foreach ($types as $param) {
$output.= $this->formatParam($param);
}
$output.= '</ul>';
} elseif (in_array($type, $this->types)) {
$output.= '<i>' . $type . '</i> ';
} elseif ($type == 'void') {
$output.= 'Void';
} else {
$output.= ' => <b>Type '.$type.' inconnu</b>';
}
return $output;
}
private function formatParam($param)
{
$output = '';
$output.= '<li>';
$output.= '<i>' . $this->transcodeType($param['type']) . '</i>';
$output.= ' ';
$output.= '<b>'. $param['name'] . '</b>';
if (isset($param['description']) && !empty($param['description'])) {
$output.= ' - '.$param['description'];
}
$type = str_replace('[]', '', $param['type']);
if (!in_array($type, $this->types)) {
$output.= $this->parseType($param['type']);
}
$output.= '</li>';
return $output;
}
private function transcodeType($type)
{
if(array_key_exists($type, $this->_transcodeType)){
return $this->_transcodeType[$type];
} else {
return $type;
}
}
private function formatParam($param)
{
$output = '';
$output.= '<li>';
$output.= '<i>' . $this->transcodeType($param['type']) . '</i>';
$output.= ' ';
$output.= '<b>'. $param['name'] . '</b>';
if (isset($param['description']) && !empty($param['description'])) {
$output.= ' - '.$param['description'];
}
$type = str_replace('[]', '', $param['type']);
if (!in_array($type, $this->types)) {
$output.= $this->parseType($param['type']);
}
$output.= '</li>';
return $output;
}
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
{
public function profileLink()
{
$auth = Zend_Auth::getInstance();
public function profileLink()
{
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
$username = $auth->getIdentity()->username;
$logoutUrl = $this->view->url(array(
'controller' => 'user',
'action' => 'logout'
'controller' => 'user',
'action' => 'logout'
), null, true);
return '<a href="'.$logoutUrl.'" title="Se déconnecter" class="navbar-link">Déconnexion : ' . $username . '</a>';
}
}
}
}
}