1,4 → 1,4 |
<?php |
<?php |
// declare(encoding='UTF-8'); |
/** |
* Service affichant les dernières photo publiques du CEL ouvrable sous forme de diaporama. |
14,172 → 14,172 |
* ===> vignette = [0-9]+,[0-9]+ [par défaut : 4,3] |
* Indique le nombre de vignette par ligne et le nombre de ligne. |
* |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt> |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt> |
* @version $Id$ |
* @copyright Copyright (c) 2010, Tela Botanica (accueil@tela-botanica.org) |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt> |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt> |
* @version $Id$ |
* @copyright Copyright (c) 2010, Tela Botanica (accueil@tela-botanica.org) |
*/ |
class Manager extends WidgetCommun { |
|
const DS = DIRECTORY_SEPARATOR; |
const SERVICE_DEFAUT = 'manager'; |
private $cel_url_tpl = null; |
/** Si spécifié, on ajoute une barre de navigation inter-applications */ |
private $bar; |
//private $parametres_autorises = array('projet', 'type', 'langue', 'order'); |
private $parametres_autorises = array( |
'projet' => 'projet', |
'type' => 'type', |
'langue' => 'langue', |
'order' => 'order' |
); |
/** |
* Méthode appelée par défaut pour charger ce widget. |
*/ |
public function executer() { |
$retour = null; |
// Pour la création de l'id du cache nous ne tenons pas compte du paramètre de l'url callback |
unset($this->parametres['callback']); |
extract($this->parametres); |
$this->bar = (isset($bar)) ? $bar : false; |
|
if (!isset($mode)) { |
$mode = self::SERVICE_DEFAUT; |
} |
|
$this->cel_url_tpl = $this->config['manager']['celUrlTpl']; |
|
if ($_POST != array()) { |
$this->parametres['projet'] = $_POST['projet']; |
$this->parametres['langue'] = $_POST['langue']; |
if ($mode == 'modification') { |
$parametres = $this->traiterParametresModif(); |
$json = $this->getDao()->modifier($this->cel_url_tpl, $parametres); |
} else { |
$json = $this->getDao()->ajouter($this->cel_url_tpl, $_POST); |
$this->parametres['mode'] = $mode = 'modification'; |
} |
} |
|
|
|
|
$methode = $this->traiterNomMethodeExecuter($mode); |
if (method_exists($this, $methode)) { |
$retour = $this->$methode(); |
} else { |
$this->messages[] = "Ce type de service '$methode' n'est pas disponible."; |
} |
|
$contenu = ''; |
if (is_null($retour)) { |
$this->messages[] = 'La ressource demandée a retourné une valeur nulle.'; |
} else { |
if (isset($retour['donnees'])) { |
$retour['donnees']['prod'] = ($this->config['parametres']['modeServeur'] == "prod"); |
$retour['donnees']['bar'] = $this->bar; |
$retour['donnees']['url_base'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], ''); |
$retour['donnees']['mode'] = $mode; |
$squelette = dirname(__FILE__).self::DS.'squelettes'.self::DS.$retour['squelette'].'.tpl.html'; |
$contenu = $this->traiterSquelettePhp($squelette, $retour['donnees']); |
} else { |
$this->messages[] = 'Les données à transmettre au squelette sont nulles.'; |
} |
} |
$this->envoyer($contenu); |
} |
|
private function executerManager() { |
$params = array(); |
$retour['squelette'] = 'manager'; |
foreach ($this->parametres_autorises as $id=>$pa) { |
if (isset($this->parametres[$pa])) { |
$params[] = $pa."=".$this->parametres[$pa]; |
} |
} |
$param = implode($params, '&'); |
$url = $this->cel_url_tpl; |
if ($param != "") $url .= '?'.$param; |
$json = $this->getDao()->consulter($url); |
$retour['donnees']['widget'] = (array) json_decode($json, true); |
$retour['donnees']['widgetUrlTpl'] = $this->config['manager']['widgetUrlTpl']; |
return $retour; |
} |
|
private function executerCreation() { |
//https://api.tela-botanica.org/service:cel:NomsChampsEtendus/cle |
$retour['squelette'] ='creation'; |
$jsonlangue = $this->getDao()->consulter($this->config['manager']['languesUrl']); |
$tableaulangue= (array) json_decode($jsonlangue, true); |
$retour['donnees']['langues'] = $tableaulangue['resultat'] ; |
$retour['donnees']['widget'] = array(); |
if (isset($this->parametres['projet'])) { |
$url = $this->cel_url_tpl.'?projet='.$this->parametres['projet']; |
$json = $this->getDao()->consulter($url); |
$tableau = (array) json_decode($json, true); |
$retour['donnees']['widget'] = $tableau[0]; |
$urltype = $this->cel_url_tpl.'?esttype=1'; |
$jsontype = $this->getDao()->consulter($urltype); |
$tableautype= (array) json_decode($jsontype, true); |
$retour['donnees']['type'] = $tableautype; |
} |
return $retour; |
} |
|
private function executerSaisie() { |
$retour = ''; |
if (isset($this->parametres['projet'])) { |
$retour['squelette'] = 'saisie'; |
$url = $this->cel_url_tpl.'?projet='.$this->parametres['projet']; |
$json = $this->getDao()->consulter($url); |
$tableau = (array) json_decode($json, true); |
$retour['donnees']['widget'] = $tableau[0]; |
} |
return $retour; |
} |
|
private function executerModification() { |
$retour = ''; |
if (isset($this->parametres['projet'])) { |
$retour['squelette'] = 'creation'; |
$url = $this->cel_url_tpl.'?projet='.$this->parametres['projet'].'&langue='.$this->parametres['langue']; |
$json = $this->getDao()->consulter($url); |
$tableau = (array) json_decode($json, true); |
$retour['donnees']['widget'] = $tableau[0]; |
$urltype = $this->cel_url_tpl.'?esttype=1'; |
$jsontype = $this->getDao()->consulter($urltype); |
$tableautype= (array) json_decode($jsontype, true); |
$retour['donnees']['type'] = $tableautype; |
} |
return $retour; |
} |
private function traiterParametres() { |
$parametres_flux = '?'; |
$criteres = array('utilisateur', 'commune', 'dept', 'taxon', 'commentaire', 'date', 'tag', 'motcle', 'projet', 'num_taxon', 'num_nom', 'referentiel', 'groupe_zones_geo'); |
foreach($this->parametres as $nom_critere => $valeur_critere) { |
if (in_array($nom_critere, $criteres)) { |
$valeur_critere = str_replace(' ', '%20', $valeur_critere); |
$parametres_flux .= $nom_critere.'='.$valeur_critere.'&'; |
} |
} |
|
if ($parametres_flux == '?') { |
$parametres_flux = ''; |
} else { |
$parametres_flux = rtrim($parametres_flux, '&'); |
} |
return $parametres_flux; |
} |
|
private function traiterParametresModif() { |
$parametres_modif = array(); |
foreach ($_POST as $id => $parametres) { |
if ($parametres != "") { |
$parametres_modif[$id] = $parametres; |
} |
} |
return $parametres_modif; |
} |
const DS = DIRECTORY_SEPARATOR; |
const SERVICE_DEFAUT = 'manager'; |
private $cel_url_tpl = null; |
/** Si spécifié, on ajoute une barre de navigation inter-applications */ |
private $bar; |
//private $parametres_autorises = array('projet', 'type', 'langue', 'order'); |
private $parametres_autorises = array( |
'projet' => 'projet', |
'type' => 'type', |
'langue' => 'langue', |
'order' => 'order' |
); |
/** |
* Méthode appelée par défaut pour charger ce widget. |
*/ |
public function executer() { |
$retour = null; |
// Pour la création de l'id du cache nous ne tenons pas compte du paramètre de l'url callback |
unset($this->parametres['callback']); |
extract($this->parametres); |
$this->bar = (isset($bar)) ? $bar : false; |
|
if (!isset($mode)) { |
$mode = self::SERVICE_DEFAUT; |
} |
|
$this->cel_url_tpl = $this->config['manager']['celUrlTpl']; |
|
if ($_POST != array()) { |
$this->parametres['projet'] = $_POST['projet']; |
$this->parametres['langue'] = $_POST['langue']; |
if ($mode == 'modification') { |
$parametres = $this->traiterParametresModif(); |
$json = $this->getDao()->modifier($this->cel_url_tpl, $parametres); |
} else { |
$json = $this->getDao()->ajouter($this->cel_url_tpl, $_POST); |
$this->parametres['mode'] = $mode = 'modification'; |
} |
} |
|
|
|
|
$methode = $this->traiterNomMethodeExecuter($mode); |
if (method_exists($this, $methode)) { |
$retour = $this->$methode(); |
} else { |
$this->messages[] = "Ce type de service '$methode' n'est pas disponible."; |
} |
|
$contenu = ''; |
if (is_null($retour)) { |
$this->messages[] = 'La ressource demandée a retourné une valeur nulle.'; |
} else { |
if (isset($retour['donnees'])) { |
$retour['donnees']['prod'] = ($this->config['parametres']['modeServeur'] == "prod"); |
$retour['donnees']['bar'] = $this->bar; |
$retour['donnees']['url_base'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], ''); |
$retour['donnees']['mode'] = $mode; |
$squelette = dirname(__FILE__).self::DS.'squelettes'.self::DS.$retour['squelette'].'.tpl.html'; |
$contenu = $this->traiterSquelettePhp($squelette, $retour['donnees']); |
} else { |
$this->messages[] = 'Les données à transmettre au squelette sont nulles.'; |
} |
} |
$this->envoyer($contenu); |
} |
|
private function executerManager() { |
$params = array(); |
$retour['squelette'] = 'manager'; |
foreach ($this->parametres_autorises as $id=>$pa) { |
if (isset($this->parametres[$pa])) { |
$params[] = $pa."=".$this->parametres[$pa]; |
} |
} |
$param = implode($params, '&'); |
$url = $this->cel_url_tpl; |
if ($param != "") $url .= '?'.$param; |
$json = $this->getDao()->consulter($url); |
$retour['donnees']['widget'] = (array) json_decode($json, true); |
$retour['donnees']['widgetUrlTpl'] = $this->config['manager']['widgetUrlTpl']; |
return $retour; |
} |
|
private function executerCreation() { |
//https://api.tela-botanica.org/service:cel:NomsChampsEtendus/cle |
$retour['squelette'] ='creation'; |
$jsonlangue = $this->getDao()->consulter($this->config['manager']['languesUrl']); |
$tableaulangue= (array) json_decode($jsonlangue, true); |
$retour['donnees']['langues'] = $tableaulangue['resultat'] ; |
$retour['donnees']['widget'] = array(); |
if (isset($this->parametres['projet'])) { |
$url = $this->cel_url_tpl.'?projet='.$this->parametres['projet']; |
$json = $this->getDao()->consulter($url); |
$tableau = (array) json_decode($json, true); |
$retour['donnees']['widget'] = $tableau[0]; |
$urltype = $this->cel_url_tpl.'?esttype=1'; |
$jsontype = $this->getDao()->consulter($urltype); |
$tableautype= (array) json_decode($jsontype, true); |
$retour['donnees']['type'] = $tableautype; |
} |
return $retour; |
} |
|
private function executerSaisie() { |
$retour = ''; |
if (isset($this->parametres['projet'])) { |
$retour['squelette'] = 'saisie'; |
$url = $this->cel_url_tpl.'?projet='.$this->parametres['projet']; |
$json = $this->getDao()->consulter($url); |
$tableau = (array) json_decode($json, true); |
$retour['donnees']['widget'] = $tableau[0]; |
} |
return $retour; |
} |
|
private function executerModification() { |
$retour = ''; |
if (isset($this->parametres['projet'])) { |
$retour['squelette'] = 'creation'; |
$url = $this->cel_url_tpl.'?projet='.$this->parametres['projet'].'&langue='.$this->parametres['langue']; |
$json = $this->getDao()->consulter($url); |
$tableau = (array) json_decode($json, true); |
$retour['donnees']['widget'] = $tableau[0]; |
$urltype = $this->cel_url_tpl.'?esttype=1'; |
$jsontype = $this->getDao()->consulter($urltype); |
$tableautype= (array) json_decode($jsontype, true); |
$retour['donnees']['type'] = $tableautype; |
} |
return $retour; |
} |
private function traiterParametres() { |
$parametres_flux = '?'; |
$criteres = array('utilisateur', 'commune', 'dept', 'taxon', 'commentaire', 'date', 'tag', 'motcle', 'projet', 'num_taxon', 'num_nom', 'referentiel', 'groupe_zones_geo'); |
foreach($this->parametres as $nom_critere => $valeur_critere) { |
if (in_array($nom_critere, $criteres)) { |
$valeur_critere = str_replace(' ', '%20', $valeur_critere); |
$parametres_flux .= $nom_critere.'='.$valeur_critere.'&'; |
} |
} |
|
if ($parametres_flux == '?') { |
$parametres_flux = ''; |
} else { |
$parametres_flux = rtrim($parametres_flux, '&'); |
} |
return $parametres_flux; |
} |
|
private function traiterParametresModif() { |
$parametres_modif = array(); |
foreach ($_POST as $id => $parametres) { |
if ($parametres != "") { |
$parametres_modif[$id] = $parametres; |
} |
} |
return $parametres_modif; |
} |
} |
?> |
?> |