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')); $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); $this->view->assign('serviceName', $myService['name']); $this->view->assign('serviceVersion', $version); $isDeprecated = false; if ($myService['versions'][$version]['defaut'] == '') { $isDeprecated = true; } $this->view->assign('isDeprecated', $isDeprecated); 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.'/'; } //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'; } // 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); } /** * 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(); //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 = 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); } } /** * 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/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(); $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() { $ws = new Scores_Ws_Server(); $erreurs = $ws->listError; $this->view->assign('erreurs', $erreurs); } }