Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 1215 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1215 Rev 1278
Line 93... Line 93...
93
			$code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE;
93
			$code = RestServeur::HTTP_CODE_MAUVAISE_REQUETE;
94
			throw new Exception($message, $code);
94
			throw new Exception($message, $code);
95
		}
95
		}
96
	}
96
	}
Line 97... Line -...
97
 
-
 
98
	private function obtenirLois(Array $id_lois) { 
-
 
99
		$id_lois = array_map(array($this->bdd, 'proteger'), $id_lois);
-
 
100
		$requete = "SELECT * FROM ".Config::get('bdd_table_lois').' '.
-
 
101
		           "WHERE cd_protection IN (".implode(',',$id_lois).") ORDER BY zone_application ASC";
-
 
102
		$lois = $this->bdd->recupererTous($requete, 'ASSOC');
-
 
103
		foreach ($lois as $loi) {
-
 
104
			$retour[$loi['cd_protection']] = $loi;
-
 
105
		}
-
 
106
		return $retour;
97
 
Line 107... Line 98...
107
	}
98
 
108
	
99
	
109
	private function obtenirLoisZoneGeo(Array $id_lois) {
100
	private function obtenirLoisZoneGeo(Array $id_lois) {
110
		$id_lois = array_map(array($this->bdd, 'proteger'), $id_lois);
101
		$id_lois = array_map(array($this->bdd, 'proteger'), $id_lois);
111
		$requete = "SELECT DISTINCT zone_application, code_zone_application, type_protection FROM ".Config::get('bdd_table_lois').' '.
102
		$requete = "SELECT DISTINCT zone_application, code_zone_application, type_protection FROM ".Config::get('bdd_table_especes').' '.
112
			           "WHERE cd_protection IN (".implode(',',$id_lois).") ORDER BY zone_application ASC";   
103
			           "WHERE cd_protection IN (".implode(',',$id_lois).") ORDER BY zone_application ASC";   
Line 113... Line 104...
113
		return $this->bdd->recupererTous($requete);
104
		return $this->bdd->recupererTous($requete);
Line 120... Line 111...
120
			$conditions_taxons[] = $this->nn_demande;
111
			$conditions_taxons[] = $this->nn_demande;
121
		}
112
		}
Line 122... Line 113...
122
		
113
		
123
		$requete = "SELECT * FROM ".Config::get('bdd_table_especes');
114
		$requete = "SELECT * FROM ".Config::get('bdd_table_especes');
124
		if ($this->nn_demande != null) {
115
		if ($this->nn_demande != null) {
125
			$requete .= " WHERE num_nom_retenu IN (".implode(', ', $conditions_taxons).") OR "
-
 
126
				. "num_nom IN (".implode(', ', $conditions_taxons).") ";
116
			$requete .= " WHERE num_nom_retenu IN (".implode(', ', $conditions_taxons).")";
127
		}
117
		}
128
		// pagination
118
		// pagination
129
		$requete .= " LIMIT " . $this->navigation_depart . ", " . $this->navigation_limite;
119
		$requete .= " LIMIT " . $this->navigation_depart . ", " . $this->navigation_limite;
130
		$requete .= ' -- ' . __FILE__ . ':' . __LINE__;
120
		$requete .= ' -- ' . __FILE__ . ':' . __LINE__;
Line 137... Line 127...
137
		return $statuts;           
127
		return $statuts;           
138
	}	
128
	}	
139
//+---------------------------FONCTIONS DE FORMATAGE---------------------------------------------------------+
129
//+---------------------------FONCTIONS DE FORMATAGE---------------------------------------------------------+
Line 140... Line 130...
140
 
130
 
141
	private function formaterRetour($statuts_taxon) {
131
	private function formaterRetour($statuts_taxon) {
142
		$retour = "";
132
		$retour = array();
143
		if ($statuts_taxon) {
-
 
144
			foreach ($statuts_taxon as $nom) {				
-
 
145
				$f[$nom['cd_protection']][$nom['num_nom']] = $nom['nom_sci'];
-
 
146
				$lois_statuts[] = $nom['cd_protection'];
-
 
147
			}
133
		if ($statuts_taxon) {
148
			switch($this->retour_format) {
134
			switch($this->retour_format) {
149
				case 'zone_geo':
135
			    case 'zone_geo': 
150
					$retour = $this->obtenirLoisZoneGeo($lois_statuts);
136
				    $retour = $this->obtenirLoisZoneGeo(array_column($statuts_taxon, "cd_protection"));
Line 151... Line 137...
151
				break;
137
				break;
152
						
-
 
153
				case 'nom':
138
						
154
					$lois = $this->obtenirLois($lois_statuts);
139
				case 'nom':
155
					foreach ($statuts_taxon as $nom) {
140
				    foreach ($statuts_taxon as $nom) {//print_r($nom);
156
						$retour[$nom['num_nom']]['num_nom'] = $nom['num_nom'];
141
						$retour[$nom['num_nom']]['num_nom'] = $nom['num_nom_retenu'];
Line 157... Line 142...
157
						$retour[$nom['num_nom']]['nom_sci'] = $nom['nom_sci'];
142
						$retour[$nom['num_nom']]['nom_sci'] = $nom['nom_sci'];
158
						$retour[$nom['num_nom']]['lois'][$nom['cd_protection']] = $lois[$nom['cd_protection']];
143
						$retour[$nom['num_nom']]['lois'][$nom['cd_protection']] = $nom;
159
					
144
					
160
					}
145
					}
-
 
146
				break;
-
 
147
				case 'complet':
-
 
148
				    foreach ($statuts_taxon as $nom) { //print_r($nom);
161
				break;
149
				        $retour[$nom['zone_application']][$nom['cd_protection']]['cd_type_statut'] = $nom['cd_type_statut'];
162
				case 'complet':
150
				        $retour[$nom['zone_application']][$nom['cd_protection']]['type_protection'] = $nom['type_protection'];
163
					$lois = $this->obtenirLois($lois_statuts);
151
				        $retour[$nom['zone_application']][$nom['cd_protection']]['rg_type_statut'] = $nom['rg_type_statut'];
-
 
152
				        $retour[$nom['zone_application']][$nom['cd_protection']]['cd_protection'] = $nom['cd_protection'];
164
					foreach ($lois as $id => $loi) {
153
				        $retour[$nom['zone_application']][$nom['cd_protection']]['intitule'] = $nom['intitule'];
-
 
154
				        $retour[$nom['zone_application']][$nom['cd_protection']]['rq_statut'] = $nom['rq_statut'];
165
						$retour[$loi['zone_application']][$id] = $loi;
155
				        $retour[$nom['zone_application']][$nom['cd_protection']]['zone_application'] = $nom['zone_application'];
166
						if (isset($f[$id])) {
156
				        $retour[$nom['zone_application']][$nom['cd_protection']]['citation'] = $nom['citation'];
167
							foreach ($f[$id] as $num_nom => $nom_sci) {
-
 
168
								$retour[$loi['zone_application']][$id]['nom_sci'][$num_nom] = $nom_sci;
-
 
169
							}
157
				        $retour[$nom['zone_application']][$nom['cd_protection']]['hyperlien'] = $nom['hyperlien'];
Line 170... Line 158...
170
						}
158
				        $retour[$nom['zone_application']][$nom['cd_protection']]['nom_sci'][$nom['num_nom_retenu']] = $nom['nom_sci'];
171
					}
159
				    }
172
					break;
160
					break;