Subversion Repositories eFlore/Applications.moissonnage

Rev

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

Rev 31 Rev 34
Line 37... Line 37...
37
	
37
	
38
	private $nomComplet;
38
	private $nomComplet;
39
	private $nomCourt;
39
	private $nomCourt;
40
	private $taxon;
40
	private $taxon;
-
 
41
	private $bdd = null;
41
	private $bdd = null;
42
	
42
	private $nomsChampsBdtfx = array('nn' => 'num_nom_retenu', 'nt' => 'num_taxonomique', 'ns' => 'nom_sci');
43
	private $nomsChampsBdtfx = array('nn' => 'num_nom_retenu', 'nt' => 'num_taxonomique', 'ns' => 'nom_sci');
43
	private $nomsChampsBdtxa = array('nn' => 'num_nom_retenu', 'nt' => 'num_tax', 'ns' => 'nom_sci');
44
	private $nomsChampsBdtxa = array('nn' => 'num_nom_retenu', 'nt' => 'num_tax', 'ns' => 'nom_sci');
Line 85... Line 86...
85
	
86
	
86
	private function getBdd() {
87
	private function getBdd() {
87
		if (is_null($this->bdd)) {
88
		if (is_null($this->bdd)) {
88
			$this->bdd = new Bdd();
89
			$this->bdd = new Bdd();
89
		}
-
 
90
		$nomBdd = Config::get('bdd_eflore');
-
 
91
		if (is_null($nomBdd)) {
90
		}
92
			$nomBdd = Config::get('bdd_nom');
-
 
93
		}
91
		$nomBdd = Config::get('bdd_nom');
94
		$this->bdd->requeter("USE ".$nomBdd);
92
		$this->bdd->requeter("USE ".$nomBdd);
95
		return $this->bdd;
93
		return $this->bdd;
Line 96... Line 94...
96
	}
94
	}
97
	
95
	
98
	public function recupererTaxonsSousEspeces($listeNn = null) {
96
	public function recupererSynonymesEtSousEspeces() {
99
		$sousTaxons = array();
-
 
100
		if (!is_null($this->taxon) && $this->taxon['rang'] == Config::get('rang.espece')) {
-
 
101
			if (is_null($listeNn)) {
-
 
102
				$listeNn = $this->taxon['nn'];
97
		$sousTaxons = array();
103
			}
98
		if (!is_null($this->taxon) && $this->taxon['rang'] >= Config::get('rang.espece')) {
104
			$requete =
99
			$requete =
105
				"SELECT ".$this->champs['nn']." AS nn, ".$this->champs['nt']." AS nt, ".
100
			"SELECT ".$this->champs['nn']." AS nn, ".$this->champs['nt']." AS nt, ".
106
				$this->champs['ns']." AS nom, rang FROM ".$this->nomComplet." WHERE ".
101
			$this->champs['ns']." AS nom, rang FROM ".$this->nomComplet. " WHERE ".
107
				"num_tax_sup IN ({$listeNn}) AND num_nom=".$this->champs['nn'];
-
 
108
			$resultats = $this->getBdd()->recupererTous($requete);
-
 
109
			
-
 
110
			$nouvelleListeNn = '';
-
 
111
			foreach ($resultats as $sousTaxon) {
-
 
112
				$sousTaxons[] = $sousTaxon;
-
 
113
				$nouvelleListeNn .= (strlen($nouvelleListeNn) == 0 ? '' : ',') . $sousTaxon['nn'];
-
 
114
			}
-
 
115
			// recherche de sous taxons au niveau inferieur (parcours recursif de la methode)
-
 
116
			if (count($resultats) > 0) {
-
 
117
				$sousTaxons = array_merge($sousTaxons, $this->recupererTaxonsSousEspeces($nouvelleListeNn));
102
			$this->champs['nt']."=".$this->taxon['nt']." OR hierarchie LIKE '%-".$this->champs['nn']."-%'";
118
			}
103
			$sousTaxons = $this->getBdd()->recupererTous($requete);
119
		}
104
		}
Line 120... Line 105...
120
		return $sousTaxons;
105
		return $sousTaxons;
121
	}
106
	}
122
	
107
	
123
	public function recupererTaxonsFamilles() {
108
	public function recupererGenres() {
124
		$sousTaxons = array();
109
		$sousTaxons = array();
125
		if (!is_null($this->taxon) && $this->taxon['rang'] == Config::get('rang.genre')) {
110
		if (!is_null($this->taxon) && $this->taxon['rang'] == Config::get('rang.famille')) {
126
			$requete =
111
			$requete =
127
				"SELECT ".$this->champs['nn']." AS nn, ".$this->champs['nt']." AS nt, ".
112
			"SELECT ".$this->champs['nn']." AS nn, ".$this->champs['nt']." AS nt, ".
128
				$this->champs['ns']." AS nom, rang FROM ".$this->nomComplet." WHERE ".
113
			$this->champs['ns']." AS nom, rang FROM ".$this->nomComplet. " WHERE ".
129
				"num_tax_sup=".$this->taxon['nn']." AND num_nom=".$this->champs['nn'];
114
			"num_tax_sup=".$this->taxon['nn']." AND num_nom=".$this->champs['nn'];
130
			$sousTaxons = $this->getBdd()->recupererTous($requete);
115
			$sousTaxons = $this->getBdd()->recupererTous($requete);
Line 147... Line 132...
147
			}
132
			}
148
		}
133
		}
149
		return $tableau;
134
		return $tableau;
150
	}
135
	}
Line 151... Line 136...
151
	
136
	
152
	public function obtenirNumeroNomenclatural($nomScientifique) {
137
	public function obtenirNumeroNomenclatural($nomScientifique, $numeroNomenclatural = null) {
153
		$aProteger = $this->getBdd()->proteger(trim($nomScientifique) . '%');
138
		$aProteger = $this->getBdd()->proteger(trim($nomScientifique) . '%');
154
		$requete = "SELECT ".$this->champs['nn']." AS nn FROM ".$this->nomComplet." ".
139
		$requete = "SELECT ".$this->champs['nn']." AS nn FROM ".$this->nomComplet." ".
-
 
140
			"WHERE ".$this->champs['ns']." LIKE ".$aProteger;
-
 
141
		if (!is_null($numeroNomenclatural) || strlen($numeroNomenclatural) > 0) {
-
 
142
			$requete .= " OR ".$this->champs['nn']."={$numeroNomenclatural}";
155
			"WHERE ".$this->champs['ns']." LIKE ".$aProteger;
143
		}
156
		$taxon = $this->getBdd()->recuperer($requete);
144
		$taxon = $this->getBdd()->recuperer($requete);
157
		if ($taxon == false) {
145
		if ($taxon == false) {
158
			$taxon = null;
146
			$taxon = null;
159
		} else {
147
		} else {
160
			$taxon['referentiel'] = $this->nomComplet;
148
			$taxon['referentiel'] = $this->nomComplet;
161
		}
149
		}
162
		return $taxon;
150
		return $taxon;
Line 163... Line 151...
163
	}
151
	}
-
 
152
	
164
	
153
}
165
}
154