2010-10-20 12:21:59 +00:00
|
|
|
<?php
|
|
|
|
class DocumentationController extends Zend_Controller_Action
|
|
|
|
{
|
2010-10-25 12:57:14 +00:00
|
|
|
protected $classmap = array();
|
2010-10-20 12:21:59 +00:00
|
|
|
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
/* Initialize action controller here */
|
|
|
|
}
|
|
|
|
|
|
|
|
public function preDispatch()
|
|
|
|
{
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
if (!$auth->hasIdentity()){
|
|
|
|
$this->_redirect('/user/login');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Affichage de la documentation des webservices
|
|
|
|
*/
|
|
|
|
public function indexAction()
|
|
|
|
{
|
|
|
|
$ws = $this->_getParam('ws','WsEntreprise');
|
|
|
|
|
|
|
|
//Liste de webservice protégé
|
|
|
|
$protectedWs = array(
|
|
|
|
'WsInterne' => array('mricois', 'ylenaour', 'sbeaugrand')
|
|
|
|
);
|
|
|
|
//On vérifie que l'utilisateur peut accèder à la documentation
|
|
|
|
if ( array_key_exists($ws, $protectedWs) )
|
|
|
|
{
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$username = $auth->getIdentity();
|
|
|
|
if ( !in_array($username, $protectedWs[$ws]) )
|
|
|
|
{
|
|
|
|
$this->renderScript('documentation/nodoc.phtml');
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
2010-10-25 12:57:14 +00:00
|
|
|
$wsConfig = new Zend_Config_Ini(APPLICATION_PATH .
|
|
|
|
'/configs/'.$ws.'.ini');
|
|
|
|
foreach ($wsConfig->Type as $type){
|
|
|
|
$this->classmap[$type] = $type;
|
|
|
|
}
|
|
|
|
|
2010-10-20 12:21:59 +00:00
|
|
|
//Affichage de la documentation
|
|
|
|
require_once 'Web/WebClassDoc.php';
|
2010-10-25 12:57:14 +00:00
|
|
|
$doc = new WebClassDoc($ws, $this->classmap);
|
2010-10-20 12:21:59 +00:00
|
|
|
$tabServiceMethods = $doc->getServiceMethods();
|
|
|
|
$tabServiceTypes = $doc->getServiceTypes();
|
|
|
|
$this->view->assign('serviceMethods', $tabServiceMethods);
|
|
|
|
$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','');
|
|
|
|
|
2010-10-29 14:04:17 +00:00
|
|
|
$fichier = APPLICATION_PATH .
|
|
|
|
'/../public/code/' . $element . '-' . $langage . '.txt';
|
2010-10-20 12:21:59 +00:00
|
|
|
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.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|