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; } } if (array_key_exists($auth->getIdentity()->idClient, $wsClients)){ $this->_forward('clients', 'documentation', null, array( 'nom' => $wsClients[$auth->getIdentity()->idClient] )); } else { // Liste des webservices $services = include APPLICATION_PATH . '/../library/WsScore/ServicesConfig.php'; foreach( $services as $section => $params ) { if ($params['actif']) { $wsServices[$section] = $params; } } // 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; } } // 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); // 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 = array(); $wsConfig = new Zend_Config_Ini($pathClassService.ucfirst($ws).'.ini'); if ( $wsConfig->count()>0 ) { foreach($wsConfig->Type->toArray() as $Type){ $classmap[$Type] = $Type; } } //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 require_once 'Web/WebClassDoc.php'; $doc = new WebClassDoc(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); } } public function clientsAction() { $request = $this->getRequest(); $client = strtolower($request->getParam('nom')); $ws = 'entreprise'; // Gestion des versions $clients = include APPLICATION_PATH . '/../library/WsScore/Clients/ClientsConfig.php'; $configServiceVersions = $clients[$client][$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 $pathClassService = 'WsScore/Clients/'.ucfirst($client).'/v'.$version.'/'; //Génération du tableau de mapping $classmap = array(); $wsConfig = new Zend_Config_Ini($pathClassService.ucfirst($ws).'.ini'); if ( $wsConfig->count()>0 ) { foreach($wsConfig->Type->toArray() as $Type){ $classmap[$Type] = $Type; } } //Définir l'url d'accès au WSDL $wsdl_url = $this->view->baseUrl(); if (APPLICATION_ENV == 'production'){ $wsdl_url.= '/clients/'.$client.'/v'.$version.'?wsdl'; } else { $wsdl_url.= '/clients/'.$client.'/v'.$version.'?wsdl-auto'; } // Affichage de la documentation require_once 'Web/WebClassDoc.php'; $doc = new WebClassDoc(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); } /** * Liste les exemples de code disponible pour chaque méthode */ public function exemplesAction() { } /** * Affichage exemple de code avec coloration syntaxique * Le code doit être placé dans public/code et doit être nommé * [nom de la méthode]-langage.txt */ public function codeAction() { $langage = strtolower($this->_getParam('langage','')); $element = $this->_getParam('element',''); $fichier = APPLICATION_PATH . '/../public/code/' . $element . '-' . $langage . '.txt'; if (file_exists($fichier)){ $sourceCode = file_get_contents($fichier); require_once 'geshi/geshi.php'; $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.'); } } /** * Affichage de la liste des erreurs avec leur code */ public function erreurAction() { require_once 'WsScore/WsScore.php'; $ws = new WsScore(); $erreurs = $ws->listError; $this->view->assign('erreurs', $erreurs); } }