Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 872 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 872 Rev 1160
1
<?php
1
<?php
2
class GenerateurNomSciHtml {
2
class GenerateurNomSciHtml {
3
	protected $bdd = null;
3
	protected $bdd = null;
4
	protected $table = null;
4
	protected $table = null;
5
 
5
 
6
	protected $num = null;
6
	protected $num = null;
7
	protected $compo_nom = array();
7
	protected $compo_nom = array();
8
 
8
 
9
	protected $abbr = array (
9
	protected $abbr = array (
10
			'infra-gen.' 	=>	'Infra-Genre',
10
			'infra-gen.' 	=>	'Infra-Genre',
11
			'sect.'			=> 'Section',
11
			'sect.'			=> 'Section',
12
			'subsect.'		=> 'Sous-Section',
12
			'subsect.'		=> 'Sous-Section',
13
			'ser.'			=> 'Série',
13
			'ser.'			=> 'Série',
14
			'subser.'		=> 'Sous-Série',
14
			'subser.'		=> 'Sous-Série',
15
			'gr.'			=> 'Groupe',
15
			'gr.'			=> 'Groupe',
16
			'agg.' 			=> 'Agrégat',
16
			'agg.' 			=> 'Agrégat',
17
			'sp.' 			=> 'Espèce',
17
			'sp.' 			=> 'Espèce',
18
			'subsp.'		=> 'Sous-Espèce',
18
			'subsp.'		=> 'Sous-Espèce',
19
			'infra-sp.'		=> 'Infra-Espèce',
19
			'infra-sp.'		=> 'Infra-Espèce',
20
			'var.'			=> 'Variété',
20
			'var.'			=> 'Variété',
21
			'subvar.'		=> 'Sous-Variété',
21
			'subvar.'		=> 'Sous-Variété',
22
			'fa'			=> 'Forme',
22
			'fa'			=> 'Forme',
23
			'subf.'			=> 'Sous-Forme',
23
			'subf.'			=> 'Sous-Forme',
24
			'f. sp.'		=> 'Forma species',
24
			'f. sp.'		=> 'Forma species',
25
			'proles' 		=> 'Race prole'
25
			'proles' 		=> 'Race prole'
26
	);
26
	);
27
 
27
 
28
	private $nomSciTpl = '<span class="sci">%s</span>';
28
	private $nomSciTpl = '<span class="sci">%s</span>';
29
 
29
 
30
	private $nomSupraGenTpl = '<span class="supra_gen">%s</span>';
30
	private $nomSupraGenTpl = '<span class="supra_gen">%s</span>';
31
	private $genTpl = '<span class="gen">%s</span>';
31
	private $genTpl = '<span class="gen">%s</span>';
32
	private $infraGenTpl = '<span class="infra-gen">%s</span>';
32
	private $infraGenTpl = '<span class="infra-gen">%s</span>';
33
	private $spFHTpl = '<span class="gen">%s</span> <span class="sp">%s</span>';
33
	private $spFHTpl = '<span class="gen">%s</span> <span class="sp">%s</span>';
34
	private $typeEpitheteTpl = '<abbr class="type_epithete" title="%s">%s</abbr>';
34
	private $typeEpitheteTpl = '<abbr class="type_epithete" title="%s">%s</abbr>';
35
	private $infraSpFHTpl = '<span class="gen">%s</span> <span class="sp">%s</span> <abbr class="type-epithete" title="%s">%s</abbr> <span class="infra-sp">%s</span>';
35
	private $infraSpFHTpl = '<span class="gen">%s</span> <span class="sp">%s</span> <abbr class="type-epithete" title="%s">%s</abbr> <span class="infra-sp">%s</span>';
36
 
36
 
37
	private $hybrideTpl = '<span class="hyb">× <span class="%s">%s</span></span>';
37
	private $hybrideTpl = '<span class="hyb">× <span class="%s">%s</span></span>';
38
	private $chimereTpl = '<span class="chimere">+ <span class="%s">%s</span></span>';
38
	private $chimereTpl = '<span class="chimere">+ <span class="%s">%s</span></span>';
39
	private $formuleHybTpl = '<span class="formule-hyb">%s</span>';
39
	private $formuleHybTpl = '<span class="formule-hyb">%s</span>';
40
	private $hybriditeTpl = '<span class="%s">%s</span>';
40
	private $hybriditeTpl = '<span class="%s">%s</span>';
41
 
41
 
42
	private $gpGxAvecCvarTpl = '<span class="gp">%s <abbr title="grex">gx</abbr>(%s <abbr title="groupe">Gp</abbr>)</span>';
42
	private $gpGxAvecCvarTpl = '<span class="gp">%s <abbr title="grex">gx</abbr>(%s <abbr title="groupe">Gp</abbr>)</span>';
43
	private $gpGxSansCvarTpl = '<span class="gp">%s <abbr title="grex">gx</abbr>%s <abbr title="groupe">Gp</abbr></span>';
43
	private $gpGxSansCvarTpl = '<span class="gp">%s <abbr title="grex">gx</abbr>%s <abbr title="groupe">Gp</abbr></span>';
44
	private $gxTpl = '<span class="gp">%s <abbr title="grex">gx</abbr></span>';
44
	private $gxTpl = '<span class="gp">%s <abbr title="grex">gx</abbr></span>';
45
	private $gpAvecCvarTpl = '<span class="gp">(%s <abbr title="groupe">Gp</abbr>)</span>';
45
	private $gpAvecCvarTpl = '<span class="gp">(%s <abbr title="groupe">Gp</abbr>)</span>';
46
	private $gpSansCvarTpl = '<span class="gp">%s <abbr title="groupe">Gp</abbr></span>';
46
	private $gpSansCvarTpl = '<span class="gp">%s <abbr title="groupe">Gp</abbr></span>';
47
	private $commTpl = '<span class="commercial">%s</span>';
47
	private $commTpl = '<span class="commercial">%s</span>';
48
	private $cvarTpl = '<span class="cultivar">\'%s\'</span>';
48
	private $cvarTpl = '<span class="cultivar">\'%s\'</span>';
49
 
49
 
50
	public function generer(Array $nomsDecomposes) {
50
	public function generer(Array $nomsDecomposes) {
51
		$nomsSciHtml = array();
51
		$nomsSciHtml = array();
52
		foreach ($nomsDecomposes as $infos) {
52
		foreach ($nomsDecomposes as $infos) {
53
			$nom = $this->genererNomSciHtml($infos);
53
			$nom = $this->genererNomSciHtml($infos);
54
			if ($nom != '') {
54
			if ($nom != '') {
55
				$nomsSciHtml[$this->num] = $nom;
55
				$nomsSciHtml[$this->num] = $nom;
56
			}
56
			}
57
		}
57
		}
58
		return $nomsSciHtml;
58
		return $nomsSciHtml;
59
	}
59
	}
60
 
60
 
61
	public function genererNomSciHtml(Array $nomDecomposes) {
61
	public function genererNomSciHtml(Array $nomDecomposes) {
62
		$this->initialiserVariables($nomDecomposes);
62
		$this->initialiserVariables($nomDecomposes);
63
 
63
 
64
		$nomSciHtml = '';
64
		$nomSciHtml = '';
65
		$nomSciHtml .= $this->ajouterBaliseNomSupraGen();
65
		$nomSciHtml .= $this->ajouterBaliseNomSupraGen();
66
		$nomSciHtml .= $this->verifierHybridite($this->compo_nom['genre'], 'gen');
66
		$nomSciHtml .= $this->verifierHybridite($this->compo_nom['genre'], 'gen');
67
		$nomSciHtml .= $this->ajouterBaliseInfraGen();
67
		$nomSciHtml .= $this->ajouterBaliseInfraGen();
68
		$nomSciHtml .= $this->verifierHybridite($this->compo_nom['epithete_sp'], 'sp');
68
		$nomSciHtml .= $this->verifierHybridite($this->compo_nom['epithete_sp'], 'sp');
69
		$nomSciHtml .= $this->ajouterBaliseTypeInfraSp();
69
		$nomSciHtml .= $this->ajouterBaliseTypeInfraSp();
70
		$nomSciHtml .= $this->verifierHybridite($this->compo_nom['epithete_infra_sp'], 'infra-sp');
70
		$nomSciHtml .= $this->verifierHybridite($this->compo_nom['epithete_infra_sp'], 'infra-sp');
71
		$nomSciHtml .= $this->ajouterCultivarGpComm();
71
		$nomSciHtml .= $this->ajouterCultivarGpComm();
72
 
72
 
73
		if ($nomSciHtml != '') {
73
		if ($nomSciHtml != '') {
74
			$nomSciHtml = sprintf($this->nomSciTpl, trim($nomSciHtml));
74
			$nomSciHtml = sprintf($this->nomSciTpl, trim($nomSciHtml));
75
		} else {
75
		} else {
76
			$nomSciHtml = $this->verifierHybridite($this->compo_nom['nom_sci'], 'infra-sp');
76
			$nomSciHtml = $this->verifierHybridite($this->compo_nom['nom_sci'], 'infra-sp');
77
		}
77
		}
78
		return $nomSciHtml;
78
		return $nomSciHtml;
79
	}
79
	}
80
 
80
 
81
	private function initialiserVariables($infos) {
81
	private function initialiserVariables($infos) {
82
		$this->num = $infos['num_nom'];
82
		$this->num = $infos['num_nom'];
83
		$this->compo_nom = $infos;
83
		$this->compo_nom = $infos;
84
	}
84
	}
85
 
85
 
86
	private function ajouterBaliseNomSupraGen() {
86
	private function ajouterBaliseNomSupraGen() {
87
		$html = '';
87
		$html = '';
88
		if ($this->compo_nom['nom_supra_generique'] != '') {
88
		if ($this->compo_nom['nom_supra_generique'] != '') {
89
			$html = sprintf($this->nomSupraGenTpl, $this->compo_nom['nom_supra_generique']);
89
			$html = sprintf($this->nomSupraGenTpl, $this->compo_nom['nom_supra_generique']);
90
		}
90
		}
91
		return $html;
91
		return $html;
92
	}
92
	}
93
 
93
 
94
	private function ajouterTypeEpithete($type) {
94
	private function ajouterTypeEpithete($type) {
95
		if (!array_key_exists($type, $this->abbr)) {
95
		if (!array_key_exists($type, $this->abbr)) {
96
			$this->abbr[$type] = $type;
96
			$this->abbr[$type] = $type;
97
		}
97
		}
98
	}
98
	}
99
 
99
 
100
	private function ajouterBaliseInfraGen() {
100
	private function ajouterBaliseInfraGen() {
101
		$html = '';
101
		$html = '';
102
		if ($this->verifierTypeInfraGen()) {
102
		if ($this->verifierTypeInfraGen()) {
103
			$html = $this->ajouterBaliseTypeInfraGen();
103
			$html = $this->ajouterBaliseTypeInfraGen();
104
		} else {
104
		} else {
105
			if ($this->avoirInfo('epithete_infra_generique')) {
105
			if ($this->avoirInfo('epithete_infra_generique')) {
106
				$html = sprintf($this->infraGenTpl, $this->compo_nom['epithete_infra_generique']);
106
				$html = sprintf($this->infraGenTpl, $this->compo_nom['epithete_infra_generique']);
107
			}
107
			}
108
		}
108
		}
109
		return $html;
109
		return $html;
110
	}
110
	}
111
 
111
 
112
	private function verifierTypeInfraGen() {
112
	private function verifierTypeInfraGen() {
113
		$ok = false;
113
		$ok = false;
114
		if ($this->compo_nom['type_epithete'] != '' && $this->compo_nom['epithete_infra_generique'] != '') {
114
		if ($this->compo_nom['type_epithete'] != '' && $this->compo_nom['epithete_infra_generique'] != '') {
115
			$this->ajouterTypeEpithete($this->compo_nom['type_epithete']);
115
			$this->ajouterTypeEpithete($this->compo_nom['type_epithete']);
116
			$ok = true;
116
			$ok = true;
117
		}
117
		}
118
		return $ok;
118
		return $ok;
119
	}
119
	}
120
 
120
 
121
	private function ajouterBaliseTypeInfraGen() {
121
	private function ajouterBaliseTypeInfraGen() {
122
		$html = '';
122
		$html = '';
123
		$type = $this->compo_nom['type_epithete'];
123
		$type = $this->compo_nom['type_epithete'];
124
 
124
 
125
		if ($type == 'agg.') {
125
		if ($type == 'agg.') {
126
			// Ajout de l'infra gen avant le type s'il est égal à agg.
126
			// Ajout de l'infra gen avant le type s'il est égal à agg.
127
			$html = ' '.$this->ajouterBaliseInfraGen().
127
			$html = ' '.$this->compo_nom['epithete_infra_generique'].
128
					' '.sprintf($this->typeEpitheteTpl, $this->abbr[$type], $type);
128
					' '.sprintf($this->typeEpitheteTpl, $this->abbr[$type], $type);
129
		} else {
129
		} else {
130
			$html = ' '.sprintf($this->typeEpitheteTpl, $this->abbr[$type], $type).
130
			$html = ' '.sprintf($this->typeEpitheteTpl, $this->abbr[$type], $type).
131
					' '.$this->ajouterBaliseInfraGen();
131
					' '.$this->compo_nom['epithete_infra_generique'];
132
		}
132
		}
133
		return $html;
133
		return $html;
134
	}
134
	}
135
 
135
 
136
	private function ajouterBaliseTypeInfraSp() {
136
	private function ajouterBaliseTypeInfraSp() {
137
		$html = '';
137
		$html = '';
138
		$type = $this->compo_nom['type_epithete'];
138
		$type = $this->compo_nom['type_epithete'];
139
		$infraSp = $this->compo_nom['epithete_infra_sp'];
139
		$infraSp = $this->compo_nom['epithete_infra_sp'];
140
 
140
 
141
		if ($infraSp != '') {
141
		if ($infraSp != '') {
142
			if ($type != '') {
142
			if ($type != '') {
143
				$this->ajouterTypeEpithete($type);
143
				$this->ajouterTypeEpithete($type);
144
				$html = ' '.sprintf($this->typeEpitheteTpl, $this->abbr[$type], $type);
144
				$html = ' '.sprintf($this->typeEpitheteTpl, $this->abbr[$type], $type);
145
			} else {
145
			} else {
146
				$message = "Nom #{$this->num} contient un épithète infra-spécifique mais son type n'est pas renseigné.";
146
				$message = "Nom #{$this->num} contient un épithète infra-spécifique mais son type n'est pas renseigné.";
147
				throw new Exception($message);
147
				throw new Exception($message);
148
			}
148
			}
149
		}
149
		}
150
		return $html;
150
		return $html;
151
	}
151
	}
152
 
152
 
153
	private function ajouterCultivarGpComm() {
153
	private function ajouterCultivarGpComm() {
154
		$html = '';
154
		$html = '';
155
		if ($this->avoirInfo('cultivar_groupe')) {
155
		if ($this->avoirInfo('cultivar_groupe')) {
156
			$html .= ' '.$this->ajouterCultivarGroupe();
156
			$html .= ' '.$this->ajouterCultivarGroupe();
157
		}
157
		}
158
		if ($this->avoirInfo('nom_commercial')) {
158
		if ($this->avoirInfo('nom_commercial')) {
159
			$html .= ' '.sprintf($this->commTpl, $this->compo_nom['nom_commercial']);
159
			$html .= ' '.sprintf($this->commTpl, $this->compo_nom['nom_commercial']);
160
		}
160
		}
161
		if ($this->avoirInfo('cultivar')) {
161
		if ($this->avoirInfo('cultivar')) {
162
			$html .= ' '.sprintf($this->cvarTpl, $this->compo_nom['cultivar']);
162
			$html .= ' '.sprintf($this->cvarTpl, $this->compo_nom['cultivar']);
163
		}
163
		}
164
		return $html;
164
		return $html;
165
	}
165
	}
166
 
166
 
167
	private function avoirInfo($valeur) {
167
	private function avoirInfo($valeur) {
168
		return (isset($this->compo_nom[$valeur]) && $this->compo_nom[$valeur] != '') ? true : false;
168
		return (isset($this->compo_nom[$valeur]) && $this->compo_nom[$valeur] != '') ? true : false;
169
	}
169
	}
170
 
170
 
171
	/**
171
	/**
172
	 * Permet d'ajouter les groupes de cultivar en fonction de la présence d'un cultivar et de la présence d'un grex
172
	 * Permet d'ajouter les groupes de cultivar en fonction de la présence d'un cultivar et de la présence d'un grex
173
	 *
173
	 *
174
	 * L'ensemble des individus obtenu par une fécondation particulière s'appelle un le Grex (que pour les orchidées).
174
	 * L'ensemble des individus obtenu par une fécondation particulière s'appelle un le Grex (que pour les orchidées).
175
	 * Au sein du grex, certains individus peuvent se distinguer par des formes, des coloris ou autres qui font que
175
	 * Au sein du grex, certains individus peuvent se distinguer par des formes, des coloris ou autres qui font que
176
	 * l'obtenteur du grex va les sélectionner.
176
	 * l'obtenteur du grex va les sélectionner.
177
	 * les noms de groupes de cultivars sont suivis de l'abréviation « Gp » et placés entre parenthèses
177
	 * les noms de groupes de cultivars sont suivis de l'abréviation « Gp » et placés entre parenthèses
178
	 * les noms de grex, s'ils sont utilisés devant une épithète de cultivar, ne se mettent pas entre parenthèses
178
	 * les noms de grex, s'ils sont utilisés devant une épithète de cultivar, ne se mettent pas entre parenthèses
179
	 *	 ex : Cymbidium Alexanderi gx 'Westonbirt' (cultivar_groupe = Alexanderi gx) ;
179
	 *	 ex : Cymbidium Alexanderi gx 'Westonbirt' (cultivar_groupe = Alexanderi gx) ;
180
	 * les noms de groupe se mettent entre parenthèses s'ils sont devant une épithète de cultivar
180
	 * les noms de groupe se mettent entre parenthèses s'ils sont devant une épithète de cultivar
181
	 *	 ex : Dracaena fragrans (Deremenis Gp) 'Christianne' (cultivar_groupe = Deremenis)
181
	 *	 ex : Dracaena fragrans (Deremenis Gp) 'Christianne' (cultivar_groupe = Deremenis)
182
	 * Un grex peut contenir des groupes (rédaction d'un exemple de l'ICNCP)
182
	 * Un grex peut contenir des groupes (rédaction d'un exemple de l'ICNCP)
183
	 *	 ex : × Rhyncosophrocattleya Marie Lemon Stick grex Francis Suzuki Group
183
	 *	 ex : × Rhyncosophrocattleya Marie Lemon Stick grex Francis Suzuki Group
184
	 *	 ou : × Rhyncosophrocattleya Marie Lemon Stick gx Francis Suzuki Gp
184
	 *	 ou : × Rhyncosophrocattleya Marie Lemon Stick gx Francis Suzuki Gp
185
	 * @param unknown_type $val
185
	 * @param unknown_type $val
186
	 *
186
	 *
187
	 */
187
	 */
188
	private function ajouterCultivarGroupe() {
188
	private function ajouterCultivarGroupe() {
189
		$html = '';
189
		$html = '';
190
		// si le champ cultivar_groupe n'est pas vide
190
		// si le champ cultivar_groupe n'est pas vide
191
		if ($this->avoirInfo('cultivar_groupe')) {
191
		if ($this->avoirInfo('cultivar_groupe')) {
192
			$groupe = trim($this->compo_nom['cultivar_groupe']);
192
			$groupe = trim($this->compo_nom['cultivar_groupe']);
193
 
193
 
194
			// Sélection des templates
194
			// Sélection des templates
195
			$tplGx = $this->gxTpl;
195
			$tplGx = $this->gxTpl;
196
			$tplGpGx = $this->gpGxSansCvarTpl;
196
			$tplGpGx = $this->gpGxSansCvarTpl;
197
			$tplGp = $this->gpSansCvarTpl;
197
			$tplGp = $this->gpSansCvarTpl;
198
			// s'il y a un cultivar, on ajoute des parenthèses au groupe (mais pas au grex)
198
			// s'il y a un cultivar, on ajoute des parenthèses au groupe (mais pas au grex)
199
			if ($this->avoirInfo('cultivar')) {
199
			if ($this->avoirInfo('cultivar')) {
200
				$tplGpGx = $this->gpGxAvecCvarTpl;
200
				$tplGpGx = $this->gpGxAvecCvarTpl;
201
				$tplGp = $this->gpAvecCvarTpl;
201
				$tplGp = $this->gpAvecCvarTpl;
202
			}
202
			}
203
 
203
 
204
			// Création du HTML du groupe de cultivar
204
			// Création du HTML du groupe de cultivar
205
			if (strrpos($groupe, ' gx ') !== false) {//si le grex est composé de groupe
205
			if (strrpos($groupe, ' gx ') !== false) {//si le grex est composé de groupe
206
				$gpEtGx = explode(' gx ', $groupe);
206
				$gpEtGx = explode(' gx ', $groupe);
207
				$html = sprintf($tplGpGx, $gpEtGx[0], $gpEtGx[1]);
207
				$html = sprintf($tplGpGx, $gpEtGx[0], $gpEtGx[1]);
208
			} else if (preg_match('/ gx$/', $groupe)) {//s'il y a un grex et pas de groupe
208
			} else if (preg_match('/ gx$/', $groupe)) {//s'il y a un grex et pas de groupe
209
				$gx = str_replace(' gx', '', $groupe);
209
				$gx = str_replace(' gx', '', $groupe);
210
				$html = sprintf($tplGx, $gx);
210
				$html = sprintf($tplGx, $gx);
211
			} else { //s'il n'y a pas de grex mais un groupe
211
			} else { //s'il n'y a pas de grex mais un groupe
212
				$html = sprintf($tplGp, $groupe);
212
				$html = sprintf($tplGp, $groupe);
213
			}
213
			}
214
		}
214
		}
215
		return $html;
215
		return $html;
216
	}
216
	}
217
 
217
 
218
	/**
218
	/**
219
	 *
219
	 *
220
	 * Permet de repérer s'il s'agit d'un hybride (infra-sp, genre, sp) ou d'une chimère.
220
	 * Permet de repérer s'il s'agit d'un hybride (infra-sp, genre, sp) ou d'une chimère.
221
	 * @param unknown_type $val
221
	 * @param unknown_type $val
222
	 * @param unknown_type $type
222
	 * @param unknown_type $type
223
	 */
223
	 */
224
	private function verifierHybridite($epithete, $type) {
224
	private function verifierHybridite($epithete, $type) {
225
		$html = '';
225
		$html = '';
226
		if ($epithete != '') {
226
		if ($epithete != '') {
227
			if (substr($epithete, 0, 2) == 'x ') {
227
			if (substr($epithete, 0, 2) == 'x ') {
228
				$hybride = str_replace('x ', '', $epithete);
228
				$hybride = str_replace('x ', '', $epithete);
229
				$html = ' '.sprintf($this->hybrideTpl, $type, $hybride);
229
				$html = ' '.sprintf($this->hybrideTpl, $type, $hybride);
230
			} elseif (substr($epithete, 0, 2) == '+ ') {
230
			} elseif (substr($epithete, 0, 2) == '+ ') {
231
				$hybride = str_replace('+ ', '', $epithete);
231
				$hybride = str_replace('+ ', '', $epithete);
232
				$html = ' '.sprintf($this->chimereTpl, $type, $hybride);
232
				$html = ' '.sprintf($this->chimereTpl, $type, $hybride);
233
			} else if (substr_count($epithete, ' x ') > 1) {// Cas d'une formule d'hybridité comprenant des parents hybrides
233
			} else if (substr_count($epithete, ' x ') > 1) {// Cas d'une formule d'hybridité comprenant des parents hybrides
234
				$html = ' '.$this->insererBaliseFormuleHyb($epithete);
234
				$html = ' '.$this->insererBaliseFormuleHyb($epithete);
235
			} elseif (substr_count($epithete, ' x ') == 1) {// Cas d'une formule d'hybridité simple
235
			} elseif (substr_count($epithete, ' x ') == 1) {// Cas d'une formule d'hybridité simple
236
				$html = ' '.$this->ajouterFomuleHybridite($epithete, $type);
236
				$html = ' '.$this->ajouterFomuleHybridite($epithete, $type);
237
			} else {// Autre cas...
237
			} else {// Autre cas...
238
				$html = ' '.sprintf($this->hybriditeTpl, $type, $epithete);
238
				$html = ' '.sprintf($this->hybriditeTpl, $type, $epithete);
239
			}
239
			}
240
		}
240
		}
241
		return $html;
241
		return $html;
242
	}
242
	}
243
 
243
 
244
	private function ajouterFomuleHybridite($formule, $type) {
244
	private function ajouterFomuleHybridite($formule, $type) {
245
		$tab_x = explode(' x ', $formule);
245
		$tab_x = explode(' x ', $formule);
246
		$formule_hyb = array();
246
		$formule_hyb = array();
247
		switch ($type) {
247
		switch ($type) {
248
			case 'gen' 		:
248
			case 'gen' 		:
249
				foreach ($tab_x as $hyb) {
249
				foreach ($tab_x as $hyb) {
250
					$formule_hyb[] = sprintf($this->genTpl, $hyb);
250
					$formule_hyb[] = sprintf($this->genTpl, $hyb);
251
				}
251
				}
252
				break;
252
				break;
253
			case 'sp'		:
253
			case 'sp'		:
254
				foreach ($tab_x as $hyb) {
254
				foreach ($tab_x as $hyb) {
255
					if (substr_count($hyb, ' ') >= 1) {
255
					if (substr_count($hyb, ' ') >= 1) {
256
						list($gen, $sp) = explode(' ', $hyb);
256
						list($gen, $sp) = explode(' ', $hyb);
257
						$formule_hyb[] = sprintf($this->spFHTpl, $gen, $sp);
257
						$formule_hyb[] = sprintf($this->spFHTpl, $gen, $sp);
258
					} else if (preg_match('/^[A-Z]/', $hyb)) {
258
					} else if (preg_match('/^[A-Z]/', $hyb)) {
259
						$gen = $hyb;
259
						$gen = $hyb;
260
						$formule_hyb[] = sprintf($this->genTpl, $gen);
260
						$formule_hyb[] = sprintf($this->genTpl, $gen);
261
					}
261
					}
262
				}
262
				}
263
				break;
263
				break;
264
			case 'infra-sp' :
264
			case 'infra-sp' :
265
				foreach ($tab_x as $hyb) {
265
				foreach ($tab_x as $hyb) {
266
					list($gen, $sp, $typeEpithete, $infraSp) = explode (' ', $hyb);
266
					list($gen, $sp, $typeEpithete, $infraSp) = explode (' ', $hyb);
267
					if (isset($infraSp)) {
267
					if (isset($infraSp)) {
268
						$formule_hyb[] = sprintf($this->infraSpFHTpl, $gen, $sp, $this->abbr[$typeEpithete], $typeEpithete, $infraSp);
268
						$formule_hyb[] = sprintf($this->infraSpFHTpl, $gen, $sp, $this->abbr[$typeEpithete], $typeEpithete, $infraSp);
269
					} else {
269
					} else {
270
						$formule_hyb[] = sprintf($this->spFHTpl, $gen, $sp);
270
						$formule_hyb[] = sprintf($this->spFHTpl, $gen, $sp);
271
					}
271
					}
272
				}
272
				}
273
				break;
273
				break;
274
			default : break;
274
			default : break;
275
		}
275
		}
276
		return $this->insererBaliseFormuleHyb(implode(' x ', $formule_hyb));
276
		return $this->insererBaliseFormuleHyb(implode(' x ', $formule_hyb));
277
	}
277
	}
278
 
278
 
279
	private function insererBaliseFormuleHyb($formule) {
279
	private function insererBaliseFormuleHyb($formule) {
280
		return sprintf($this->formuleHybTpl, $formule);
280
		return sprintf($this->formuleHybTpl, $formule);
281
	}
281
	}
282
}
282
}
283
?>
283
?>