| Line 35... |
Line 35... |
| 35 |
$this->tableNomsVernaculaires = $this->config['table_nv'];
|
35 |
$this->tableNomsVernaculaires = $this->config['table_nv'];
|
| 36 |
$this->urlStatutsProtection = $this->config['url_service_sptb'];
|
36 |
$this->urlStatutsProtection = $this->config['url_service_sptb'];
|
| 37 |
}
|
37 |
}
|
| Line 38... |
Line 38... |
| 38 |
|
38 |
|
| 39 |
public function consulter($ressources, $parametres) {
|
- |
|
| 40 |
|
39 |
public function consulter($ressources, $parametres) {
|
| 41 |
$retour = null;
|
40 |
$retour = null;
|
| 42 |
if(preg_match("/^(nt|nn):([0-9]+)$/", $ressources[0], $matches)) {
|
41 |
if(preg_match("/^(nt|nn):([0-9]+)$/", $ressources[0], $matches)) {
|
| 43 |
$champ_nt_ou_nn = ($matches[1] == "nn") ? "num_nom" : "num_tax";
|
- |
|
| 44 |
|
42 |
$champ_nt_ou_nn = ($matches[1] == "nn") ? "num_nom" : "num_tax";
|
| 45 |
if(count($ressources) == 1) {
|
43 |
if(count($ressources) == 1) {
|
| 46 |
// toutes les infos
|
44 |
// toutes les infos
|
| 47 |
$infos_espece = $this->getInfosEspece($champ_nt_ou_nn, $matches[2]);
|
45 |
$infos_espece = $this->getInfosEspece($champ_nt_ou_nn, $matches[2]);
|
| 48 |
$retour = array_merge($infos_espece, $this->getInfosPresence($champ_nt_ou_nn, $matches[2]));
|
46 |
$retour = array_merge($infos_espece, $this->getInfosPresence($champ_nt_ou_nn, $matches[2]));
|
| Line 65... |
Line 63... |
| 65 |
$retour = array('statuts_protection' => $this->getStatutsProtection($champ_nt_ou_nn, $matches[2]));
|
63 |
$retour = array('statuts_protection' => $this->getStatutsProtection($champ_nt_ou_nn, $matches[2]));
|
| 66 |
break;
|
64 |
break;
|
| 67 |
case "presence":
|
65 |
case "presence":
|
| 68 |
$retour = $this->getInfosPresence($champ_nt_ou_nn, $matches[2]);
|
66 |
$retour = $this->getInfosPresence($champ_nt_ou_nn, $matches[2]);
|
| 69 |
break;
|
67 |
break;
|
| - |
|
68 |
case "presence-departement":
|
| - |
|
69 |
$retour = $this->getInfosPresenceDepartement($champ_nt_ou_nn, $matches[2], $ressources[2]);
|
| - |
|
70 |
break;
|
| 70 |
default:
|
71 |
default:
|
| 71 |
$retour = "Actions possibles: noms-vernaculaires, statuts-protection, presence";
|
72 |
$retour = "Actions possibles: noms-vernaculaires, statuts-protection, presence";
|
| 72 |
}
|
73 |
}
|
| 73 |
}
|
74 |
}
|
| 74 |
} else {
|
75 |
} else {
|
| Line 100... |
Line 101... |
| 100 |
$colonnes[] = '`' . ($i > 9 ? $i : "0$i") . '`';
|
101 |
$colonnes[] = '`' . ($i > 9 ? $i : "0$i") . '`';
|
| 101 |
}
|
102 |
}
|
| 102 |
$somme = implode('+', $colonnes);
|
103 |
$somme = implode('+', $colonnes);
|
| 103 |
return $somme;
|
104 |
return $somme;
|
| 104 |
}
|
105 |
}
|
| - |
|
106 |
|
| - |
|
107 |
protected function getInfosPresenceDepartement($champ_nt_ou_nn, $nt_ou_nn, $departement) {
|
| - |
|
108 |
|
| - |
|
109 |
// Afin de s'assurer d'une valeur numérique
|
| - |
|
110 |
$departement = intval($departement);
|
| - |
|
111 |
// Afin de gérer les noms de colonnes qui commencent par 0 sans imposer de format
|
| - |
|
112 |
// de nombre à l'entrée du web service
|
| - |
|
113 |
$departement = $departement < 10 ? "0".$departement : $departement;
|
| - |
|
114 |
|
| - |
|
115 |
$req = "SELECT count(*) > 0 as present".
|
| - |
|
116 |
" FROM ".$this->table.
|
| - |
|
117 |
" WHERE ".$champ_nt_ou_nn." = ".$this->getBdd()->proteger($nt_ou_nn).' AND '.
|
| - |
|
118 |
"`".$departement."` = 1";
|
| - |
|
119 |
//echo $req;exit;
|
| - |
|
120 |
$resultat = $this->getBdd()->recuperer($req);
|
| - |
|
121 |
return $resultat;
|
| - |
|
122 |
}
|
| Line 105... |
Line 123... |
| 105 |
|
123 |
|
| 106 |
protected function getInfosPresence($champ_nt_ou_nn, $nt_ou_nn) {
|
124 |
protected function getInfosPresence($champ_nt_ou_nn, $nt_ou_nn) {
|
| 107 |
$req = "SELECT " . $this->construireSommeColonnes() . " as nb_presence_zones".
|
125 |
$req = "SELECT " . $this->construireSommeColonnes() . " as nb_presence_zones".
|
| 108 |
" FROM ".$this->table.
|
126 |
" FROM ".$this->table.
|