| Line 12... |
Line 12... |
| 12 |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
|
12 |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
|
| 13 |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
|
13 |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
|
| 14 |
* @version $Id$
|
14 |
* @version $Id$
|
| 15 |
*/
|
15 |
*/
|
| 16 |
class Bdtfx extends Script {
|
16 |
class Bdtfx extends Script {
|
| - |
|
17 |
|
| 17 |
protected $bdd = null;
|
18 |
protected $bdd = null;
|
| 18 |
protected $table = null;
|
19 |
protected $table = null;
|
| 19 |
protected $num = null;
|
- |
|
| 20 |
protected $compo_nom = array();
|
20 |
private $projetNom = 'bdtfx';
|
| 21 |
protected $abbr = array (
|
- |
|
| 22 |
'infra-gen.' => 'Infra-Genre',
|
- |
|
| 23 |
'sect.' => 'Section',
|
- |
|
| 24 |
'subsect.' => 'Sous-Section',
|
- |
|
| 25 |
'ser.' => 'Série',
|
- |
|
| 26 |
'subser.' => 'Sous-Série',
|
- |
|
| 27 |
'gr.' => 'Groupe',
|
- |
|
| 28 |
'agg.' => 'Agrégat',
|
- |
|
| 29 |
'sp.' => 'Espèce',
|
- |
|
| 30 |
'subsp.' => 'Sous-Espèce',
|
- |
|
| 31 |
'infra-sp.' => 'Infra-Espèce',
|
- |
|
| 32 |
'var.' => 'Variété',
|
- |
|
| 33 |
'subvar.' => 'Sous-Variété',
|
- |
|
| 34 |
'fa' => 'Forme',
|
- |
|
| 35 |
'subf.' => 'Sous-Forme',
|
- |
|
| 36 |
'f. sp.' => 'Forma species',
|
- |
|
| 37 |
'proles' => 'Race prole'
|
- |
|
| 38 |
);
|
21 |
|
| 39 |
private $nomSciTpl = '<span class=sci>%s</span>';
|
- |
|
| 40 |
private $nomSupraGenTpl = '<span class="supra_gen">%s</span>';
|
- |
|
| 41 |
private $genTpl = '<span class="gen">%s</span>';
|
- |
|
| 42 |
private $infraGenTpl = '<span class="infra-gen">%s</span>';
|
- |
|
| 43 |
private $spFHTpl = '<span class="gen">%s</span> <span class="sp">%s</span>';
|
- |
|
| 44 |
private $typeEpitheteTpl = '<abbr class="type_epithete" title="%s">%s</abbr>';
|
- |
|
| 45 |
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>';
|
- |
|
| 46 |
private $formuleHybTpl = '<span class="formule-hyb">%s</span>';
|
- |
|
| 47 |
protected $table_requete;
|
- |
|
| 48 |
protected $limite_req_tuples = 10000;
|
22 |
protected $pasInsertion = 1000;
|
| 49 |
protected $depart_req_tuples = 0;
|
23 |
protected $departInsertion = 0;
|
| Line 50... |
Line 24... |
| 50 |
|
24 |
|
| 51 |
protected $parametres_autorises = array(
|
25 |
protected $parametres_autorises = array(
|
| Line 52... |
Line 26... |
| 52 |
'-t' => array(true, true, 'Nom de la table qui doit être traitée'));
|
26 |
'-t' => array(false, true, 'Permet de tester le script sur un jeux réduit de données (indiquer le nombre de lignes).'));
|
| - |
|
27 |
|
| - |
|
28 |
public function executer() {
|
| - |
|
29 |
try {
|
| 53 |
|
30 |
$this->initialiser();
|
| 54 |
public function executer() {
|
31 |
|
| 55 |
// Lancement de l'action demandée
|
32 |
// Lancement de l'action demandée
|
| - |
|
33 |
$cmd = $this->getParametre('a');
|
| - |
|
34 |
switch ($cmd) {
|
| - |
|
35 |
case 'chargerTous' :
|
| - |
|
36 |
$this->chargerStructureSql();
|
| - |
|
37 |
$this->chargerBdtfx();
|
| - |
|
38 |
$this->genererNomSciHtml();
|
| - |
|
39 |
break;
|
| - |
|
40 |
case 'chargerStructureSql' :
|
| - |
|
41 |
$this->chargerStructureSql();
|
| - |
|
42 |
break;
|
| - |
|
43 |
case 'chargerBdtfx' :
|
| 56 |
$cmd = $this->getParametre('a');
|
44 |
$this->chargerBdtfx();
|
| 57 |
switch ($cmd) {
|
45 |
break;
|
| 58 |
case 'nomSciHtml' :
|
46 |
case 'genererNomSciHtml' :
|
| 59 |
$this->genererNomSciHtml();
|
47 |
$this->genererNomSciHtml();
|
| 60 |
break;
|
48 |
break;
|
| - |
|
49 |
default :
|
| - |
|
50 |
throw new Exception("Erreur : la commande '$cmd' n'existe pas!");
|
| - |
|
51 |
}
|
| 61 |
default :
|
52 |
} catch (Exception $e) {
|
| 62 |
$this->traiterErreur('Erreur : la commande "%s" n\'existe pas!', array($cmd));
|
53 |
$this->traiterErreur($e->getMessage());
|
| Line 63... |
Line 54... |
| 63 |
}
|
54 |
}
|
| - |
|
55 |
}
|
| 64 |
}
|
56 |
|
| - |
|
57 |
private function initialiser() {
|
| - |
|
58 |
$this->chargerConfigDuProjet();
|
| - |
|
59 |
$this->bdd = new Bdd();
|
| - |
|
60 |
}
|
| - |
|
61 |
|
| - |
|
62 |
private function chargerConfigDuProjet() {
|
| - |
|
63 |
$fichierIni = dirname(__FILE__).DS.$this->projetNom.'.ini';
|
| - |
|
64 |
if (file_exists($fichierIni)) {
|
| - |
|
65 |
Config::charger($fichierIni);
|
| - |
|
66 |
} else {
|
| - |
|
67 |
$m = "Veuillez configurer le projet en créant le fichier '{$this->projetNom}.ini' ".
|
| - |
|
68 |
"dans le dossier du module de script du projet à partir du fichier '{$this->projetNom}.defaut.ini'.";
|
| - |
|
69 |
throw new Exception($m);
|
| - |
|
70 |
}
|
| - |
|
71 |
}
|
| - |
|
72 |
|
| - |
|
73 |
private function chargerStructureSql() {
|
| - |
|
74 |
$chemin = Config::get('chemins.structureSql');
|
| - |
|
75 |
$requetes = Outils::extraireRequetes($chemin);
|
| - |
|
76 |
foreach ($requetes as $requete) {
|
| - |
|
77 |
$this->bdd->requeter($requete);
|
| - |
|
78 |
}
|
| - |
|
79 |
}
|
| - |
|
80 |
|
| - |
|
81 |
private function chargerBdtfx() {
|
| - |
|
82 |
$chemin = Config::get('chemins.bdtfx');
|
| - |
|
83 |
$table = Config::get('tables.bdtfx');
|
| - |
|
84 |
$requete = "LOAD DATA INFILE '$chemin' ".
|
| - |
|
85 |
"REPLACE INTO TABLE $table ".
|
| - |
|
86 |
'CHARACTER SET utf8 '.
|
| - |
|
87 |
'FIELDS '.
|
| - |
|
88 |
" TERMINATED BY '\t' ".
|
| - |
|
89 |
" ENCLOSED BY '' ".
|
| - |
|
90 |
" ESCAPED BY '\\\' ".
|
| Line -... |
Line 91... |
| - |
|
91 |
'IGNORE 1 LINES';
|
| - |
|
92 |
$this->bdd->requeter($requete);
|
| - |
|
93 |
}
|
| - |
|
94 |
|
| 65 |
|
95 |
private function genererNomSciHtml() {
|
| 66 |
private function genererNomSciHtml() {
|
96 |
$this->initialiserGenerationNomsSciHtml();
|
| 67 |
$this->initialiser();
|
97 |
$this->preparerTable();
|
| 68 |
|
- |
|
| 69 |
$nbtot = $this->recupererNbTotalTuples();
|
- |
|
| 70 |
while ($this->depart_req_tuples < $nbtot) {
|
- |
|
| 71 |
$resultat = $this->recupererTuples();
|
- |
|
| 72 |
$nb_tot_res = count($resultat);
|
- |
|
| 73 |
$compteur = 1;
|
- |
|
| 74 |
foreach ($resultat as $tuples => $infos) { //pour chaque tuple
|
- |
|
| 75 |
$this->initialiserVariables($infos);
|
- |
|
| 76 |
|
98 |
$generateur = new GenerateurNomSciHtml();
|
| 77 |
$nomSciHtml = '';
|
- |
|
| 78 |
$nomSciHtml .= $this->ajouterBaliseNomSupraGen();
|
- |
|
| 79 |
$nomSciHtml .= $this->verifierHybridite($this->compo_nom['genre'], 'gen');
|
- |
|
| 80 |
$nomSciHtml .= $this->ajouterBaliseInfraGen();
|
- |
|
| 81 |
$nomSciHtml .= $this->verifierHybridite($this->compo_nom['epithete_sp'], 'sp');
|
- |
|
| 82 |
$nomSciHtml .= $this->ajouterBaliseTypeInfraSp();
|
- |
|
| 83 |
$nomSciHtml .= $this->verifierHybridite($this->compo_nom['epithete_infra_sp'], 'infra-sp');
|
- |
|
| 84 |
$nomSciHtml .= $this->ajouterCultivarGpComm();
|
- |
|
| 85 |
|
- |
|
| 86 |
if ($nomSciHtml != '') {
|
99 |
$nbreTotal = $this->recupererNbTotalTuples();
|
| 87 |
$this->table_requete[$this->num] = sprintf($this->nomSciTpl, trim($nomSciHtml));
|
100 |
while ($this->departInsertion < $nbreTotal) {
|
| 88 |
}
|
101 |
$resultat = $this->recupererTuples();
|
| 89 |
if (count($this->table_requete) == 1000) {
|
102 |
$nomsSciEnHtml = $generateur->generer($resultat);
|
| 90 |
$this->lancerRequeteModification();
|
103 |
$this->lancerRequeteModification($nomsSciEnHtml);
|
| 91 |
array_splice($this->table_requete, 0);
|
- |
|
| 92 |
} elseif ($compteur == $nb_tot_res) {
|
- |
|
| 93 |
$this->lancerRequeteModification();
|
104 |
$this->departInsertion += $this->pasInsertion;
|
| 94 |
}
|
105 |
$this->afficherAvancement("Insertion des noms scientifique au format HTML dans la base par paquet de {$this->pasInsertion} en cours");
|
| 95 |
$compteur++;
|
106 |
if ($this->stopperLaBoucle()) {
|
| 96 |
$this->afficherAvancement('Génération des noms scientifique au format HTML en cours');
|
107 |
break;
|
| Line 97... |
Line 108... |
| 97 |
}
|
108 |
}
|
| 98 |
}
|
109 |
}
|
| 99 |
echo "\n";
|
110 |
echo "\n";
|
| 100 |
}
|
111 |
}
|
| 101 |
|
112 |
|
| Line 102... |
Line 113... |
| 102 |
private function initialiser() {
|
113 |
private function initialiserGenerationNomsSciHtml() {
|
| 103 |
$this->bdd = new Bdd();
|
114 |
require_once dirname(__FILE__).DS.'GenerateurNomSciHtml.php';
|
| 104 |
$this->table = $this->getParametre('t');
|
115 |
echo dirname(__FILE__).DS.'GenerateurNomSciHtml.php';
|
| 105 |
$this->preparerTable();
|
116 |
$this->table = Config::get('tables.bdtfx');
|
| 106 |
}
|
117 |
}
|
| 107 |
|
118 |
|
| 108 |
private function preparerTable() {
|
119 |
private function preparerTable() {
|
| 109 |
$requete = "SHOW COLUMNS FROM {$this->table} LIKE 'nom_sci_html' ";
|
120 |
$requete = "SHOW COLUMNS FROM {$this->table} LIKE 'nom_sci_html' ";
|
| 110 |
$resultat = $this->bdd->recuperer($requete);
|
121 |
$resultat = $this->bdd->recuperer($requete);
|
| 111 |
if ($resultat === false) {
|
122 |
if ($resultat === false) {
|
| Line 112... |
Line 123... |
| 112 |
$requete = "ALTER TABLE {$this->table} ".
|
123 |
$requete = "ALTER TABLE {$this->table} ".
|
| 113 |
'ADD nom_sci_html VARCHAR( 500 ) '.
|
124 |
'ADD nom_sci_html VARCHAR( 500 ) '.
|
| 114 |
'CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ';
|
125 |
'CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ';
|
| 115 |
$this->bdd->requeter($requete);
|
126 |
$this->bdd->requeter($requete);
|
| 116 |
}
|
127 |
}
|
| Line 117... |
Line 128... |
| 117 |
}
|
128 |
}
|
| 118 |
|
129 |
|
| 119 |
private function recupererNbTotalTuples(){
|
130 |
private function recupererNbTotalTuples(){
|
| 120 |
$req = "SELECT count(*) AS nb FROM {$this->table} ";
|
131 |
$requete = "SELECT count(*) AS nb FROM {$this->table} ";
|
| 121 |
$res = $this->bdd->recuperer($req);
|
132 |
$resultat = $this->bdd->recuperer($requete);
|
| 122 |
return $res['nb'];
|
133 |
return $resultat['nb'];
|
| 123 |
}
|
- |
|
| 124 |
|
134 |
}
|
| 125 |
private function recupererTuples() {
|
- |
|
| 126 |
$requete = 'SELECT num_nom, rang, nom_supra_generique, genre, epithete_infra_generique, '.
|
135 |
|
| 127 |
' epithete_sp, type_epithete, epithete_infra_sp,cultivar_groupe, '.
|
136 |
private function recupererTuples() {
|
| Line 128... |
Line 137... |
| 128 |
' nom_commercial, cultivar '.
|
137 |
$requete = 'SELECT num_nom, rang, nom_supra_generique, genre, epithete_infra_generique, '.
|
| 129 |
"FROM {$this->table} ".
|
- |
|
| 130 |
"LIMIT {$this->depart_req_tuples},{$this->limite_req_tuples} ";
|
- |
|
| 131 |
|
- |
|
| 132 |
$resultat = $this->bdd->recupererTous($requete);
|
- |
|
| 133 |
$this->depart_req_tuples += 10000;
|
- |
|
| 134 |
return $resultat;
|
- |
|
| 135 |
}
|
- |
|
| 136 |
|
- |
|
| 137 |
private function initialiserVariables($infos) {
|
- |
|
| 138 |
$this->num = $infos['num_nom'];
|
- |
|
| 139 |
$this->compo_nom = $infos;
|
- |
|
| 140 |
}
|
- |
|
| 141 |
|
- |
|
| 142 |
private function ajouterBaliseNomSupraGen() {
|
138 |
' epithete_sp, type_epithete, epithete_infra_sp,cultivar_groupe, '.
|
| 143 |
$html = '';
|
- |
|
| 144 |
if ($this->compo_nom['nom_supra_generique'] != '') {
|
- |
|
| 145 |
$html = sprintf($this->nomSupraGenTpl, $this->compo_nom['nom_supra_generique']);
|
- |
|
| 146 |
}
|
- |
|
| 147 |
return $html;
|
- |
|
| 148 |
}
|
- |
|
| 149 |
|
- |
|
| 150 |
private function ajouterTypeEpithete($type) {
|
139 |
' nom_commercial, cultivar '.
|
| 151 |
if (!array_key_exists($type, $this->abbr)) {
|
- |
|
| 152 |
$this->abbr[$type] = $type;
|
- |
|
| 153 |
}
|
- |
|
| 154 |
}
|
- |
|
| 155 |
|
- |
|
| 156 |
private function ajouterBaliseInfraGen() {
|
- |
|
| 157 |
$html = '';
|
- |
|
| 158 |
if ($this->verifierTypeInfraGen()) {
|
- |
|
| 159 |
$html .= $this->ajouterBaliseTypeInfraGen();
|
- |
|
| 160 |
} else {
|
- |
|
| 161 |
if ($this->avoirInfo('epithete_infra_generique')) {
|
- |
|
| 162 |
$html .= sprintf($this->infraGenTpl, $this->compo_nom['epithete_infra_generique']);
|
- |
|
| 163 |
}
|
- |
|
| 164 |
}
|
- |
|
| 165 |
return $html;
|
- |
|
| 166 |
}
|
- |
|
| 167 |
|
- |
|
| 168 |
private function verifierTypeInfraGen() {
|
- |
|
| 169 |
$ok = false;
|
- |
|
| 170 |
if ($this->compo_nom['type_epithete'] != '' && $this->compo_nom['epithete_infra_generique'] != '') {
|
- |
|
| 171 |
$this->ajouterTypeEpithete($this->compo_nom['type_epithete']);
|
- |
|
| 172 |
$ok = true;
|
- |
|
| 173 |
}
|
140 |
"FROM {$this->table} ".
|
| 174 |
return $ok;
|
- |
|
| 175 |
}
|
- |
|
| 176 |
|
- |
|
| 177 |
private function ajouterBaliseTypeInfraGen() {
|
141 |
"LIMIT {$this->departInsertion},{$this->pasInsertion} ";
|
| 178 |
$html = '';
|
- |
|
| 179 |
$type = $this->compo_nom['type_epithete'];
|
142 |
$resultat = $this->bdd->recupererTous($requete);
|
| 180 |
|
- |
|
| 181 |
if ($type == 'agg.') { // Ajout de l'infra gen avant le type s'il est égal à agg.
|
- |
|
| 182 |
$html .= ' '.$this->ajouterBaliseInfraGen().
|
- |
|
| 183 |
' '.sprintf($this->typeEpitheteTpl, $this->abbr[$type], $type);
|
- |
|
| 184 |
} else {
|
143 |
return $resultat;
|
| 185 |
$html .= ' '.sprintf($this->typeEpitheteTpl, $this->abbr[$type], $type).
|
- |
|
| 186 |
' '.$this->ajouterBaliseInfraGen();
|
- |
|
| 187 |
}
|
- |
|
| 188 |
return $html;
|
144 |
}
|
| 189 |
}
|
- |
|
| 190 |
|
- |
|
| 191 |
private function ajouterBaliseTypeInfraSp() {
|
- |
|
| 192 |
$html = '';
|
- |
|
| 193 |
$type = $this->compo_nom['type_epithete'];
|
145 |
|
| 194 |
$infraSp = $this->compo_nom['epithete_infra_sp'];
|
- |
|
| 195 |
|
- |
|
| 196 |
if ($infraSp != '') {
|
- |
|
| 197 |
if ($type != '') {
|
- |
|
| 198 |
$this->ajouterTypeEpithete($type);
|
- |
|
| 199 |
$html = ' '.sprintf($this->typeEpitheteTpl, $this->abbr[$type], $type);
|
- |
|
| 200 |
} else {
|
- |
|
| 201 |
$message = "Nom #%s contient un épithète infra-spécifique mais son type n'est pas renseigné.";
|
- |
|
| 202 |
$this->traiterErreur($message, array($this->num));
|
- |
|
| 203 |
}
|
- |
|
| 204 |
}
|
- |
|
| 205 |
return $html;
|
- |
|
| 206 |
}
|
- |
|
| 207 |
|
- |
|
| 208 |
private function ajouterCultivarGpComm() {
|
- |
|
| 209 |
$html = '';
|
- |
|
| 210 |
if ($this->avoirInfo('cultivar_groupe')) {
|
- |
|
| 211 |
$html .= ' '.$this->ajouterCultivarGroupe();
|
- |
|
| 212 |
}
|
- |
|
| 213 |
if ($this->avoirInfo('nom_commercial')) {
|
- |
|
| 214 |
$html .= ' <span class="commercial">'.$this->compo_nom['nom_commercial'].'</span>';
|
- |
|
| 215 |
}
|
- |
|
| 216 |
if ($this->avoirInfo('cultivar')) {
|
- |
|
| 217 |
$html .= ' <span class="cultivar">\''.$this->compo_nom['cultivar'].'\'</span>';
|
- |
|
| 218 |
}
|
- |
|
| 219 |
return $html;
|
- |
|
| 220 |
}
|
- |
|
| 221 |
|
- |
|
| 222 |
private function avoirInfo($valeur) {
|
- |
|
| 223 |
return (isset($this->compo_nom[$valeur]) && $this->compo_nom[$valeur] != '') ? true : false;
|
- |
|
| 224 |
}
|
- |
|
| 225 |
|
- |
|
| 226 |
/**
|
- |
|
| 227 |
* Permet d'ajouter les groupes de cultivar en fonction de la présence d'un cultivar et de la présence d'un grex
|
- |
|
| 228 |
*
|
- |
|
| 229 |
* L'ensemble des individus obtenu par une fécondation particulière s'appelle un le Grex (que pour les orchidées).
|
- |
|
| 230 |
* Au sein du grex, certains individus peuvent se distinguer par des formes, des coloris ou autres qui font que
|
- |
|
| 231 |
* l'obtenteur du grex va les sélectionner.
|
- |
|
| 232 |
* les noms de groupes de cultivars sont suivis de l'abréviation « Gp » et placés entre parenthèses
|
- |
|
| 233 |
* les noms de grex, s'ils sont utilisés devant une épithète de cultivar, ne se mettent pas entre parenthèses
|
- |
|
| 234 |
* ex : Cymbidium Alexanderi gx 'Westonbirt' (cultivar_groupe = Alexanderi gx) ;
|
- |
|
| 235 |
* les noms de groupe se mettent entre parenthèses s'ils sont devant une épithète de cultivar
|
- |
|
| 236 |
* ex : Dracaena fragrans (Deremenis Gp) 'Christianne' (cultivar_groupe = Deremenis)
|
- |
|
| 237 |
* Un grex peut contenir des groupes (rédaction d'un exemple de l'ICNCP)
|
- |
|
| 238 |
* ex : × Rhyncosophrocattleya Marie Lemon Stick grex Francis Suzuki Group
|
- |
|
| 239 |
* ou : × Rhyncosophrocattleya Marie Lemon Stick gx Francis Suzuki Gp
|
- |
|
| 240 |
* @param unknown_type $val
|
- |
|
| 241 |
*
|
- |
|
| 242 |
*/
|
- |
|
| 243 |
private function ajouterCultivarGroupe() {
|
- |
|
| 244 |
$html = '';
|
- |
|
| 245 |
if ($this->avoirInfo('cultivar_groupe')) { //si le champ cultivar_groupe n'est pas vide
|
- |
|
| 246 |
if ($this->compo_nom['cultivar']) { //si il y a un cultivar, on ajoute des parenthèses au group (mais pas au grex)
|
- |
|
| 247 |
if (strrpos($this->compo_nom['cultivar_groupe'], ' gx ') !== false) { //si le grex est composé de groupe
|
- |
|
| 248 |
$tab_gp = explode(' gx ', $this->compo_nom['cultivar_groupe']);
|
- |
|
| 249 |
$html = ' <span class="gp">'.$tab_gp[0].
|
- |
|
| 250 |
' <abbr title="grex">gx </abbr>('.$tab_gp[1].
|
- |
|
| 251 |
' <abbr title="groupe">Gp</abbr>)</span>';
|
- |
|
| 252 |
} elseif (strrpos($this->compo_nom['cultivar_groupe'], ' gx') !== false) { //si il y a un grex et pas de groupe
|
- |
|
| 253 |
$tab_gp = explode(' gx', $this->compo_nom['cultivar_groupe']);
|
- |
|
| 254 |
$html = ' <span class="gp">'.$tab_gp[0].' <abbr title="grex">gx</abbr></span>';
|
- |
|
| 255 |
} else { //si il n'y a pas de grex mais un groupe
|
- |
|
| 256 |
$html = ' <span class="gp">'.$this->compo_nom['cultivar_groupe'].' <abbr title="groupe">Gp</abbr>)</span>';
|
- |
|
| 257 |
}
|
- |
|
| 258 |
} else { //s'il n'y a pas de cultivar
|
- |
|
| 259 |
if (strrpos($this->compo_nom['cultivar_groupe'], ' gx ') !== false) { //si le grex est composé de groupe
|
- |
|
| 260 |
$tab_gp = explode(' gx ', $this->compo_nom['cultivar_groupe']);
|
- |
|
| 261 |
$html = ' <span class="gp">'.$tab_gp[0].
|
146 |
private function lancerRequeteModification($nomsSciHtm) {
|
| 262 |
' <abbr title="grex">gx</abbr>'.$tab_gp[1].
|
147 |
foreach ($nomsSciHtm as $id => $html) {
|
| 263 |
' <abbr title="groupe">Gp</abbr></span>';
|
- |
|
| 264 |
} elseif (strrpos($this->compo_nom['cultivar_groupe'], ' gx') !== false) { //si il y a un grex et pas de groupe
|
148 |
$html = $this->bdd->proteger($html);
|
| Line 265... |
Line -... |
| 265 |
$tab_gp = explode(' gx', $this->compo_nom['cultivar_groupe']);
|
- |
|
| 266 |
$html = ' <span class="gp">'.$tab_gp[0].' <abbr title="grex">gx</abbr></span>';
|
- |
|
| 267 |
} else { //si il n'y a pas de grex mais un groupe
|
- |
|
| 268 |
$html = ' <span class="gp">'.$this->compo_nom['cultivar_groupe'].' <abbr title="groupe">Gp</abbr></span>';
|
- |
|
| 269 |
}
|
- |
|
| 270 |
}
|
- |
|
| 271 |
}
|
149 |
$requete = "UPDATE {$this->table} ".
|
| 272 |
return $html;
|
150 |
"SET nom_sci_html = $html ".
|
| 273 |
}
|
151 |
"WHERE num_nom = $id ";
|
| 274 |
|
152 |
$resultat = $this->bdd->requeter($requete);
|
| 275 |
/**
|
- |
|
| 276 |
*
|
153 |
if ($resultat === false) {
|
| 277 |
* Permet de repérer s'il s'agit d'un hybride (infra-sp, genre, sp) ou d'une chimère.
|
- |
|
| 278 |
* @param unknown_type $val
|
- |
|
| 279 |
* @param unknown_type $type
|
- |
|
| 280 |
*/
|
- |
|
| 281 |
private function verifierHybridite($epithete, $type) {
|
- |
|
| 282 |
$html = '';
|
154 |
throw new Exception("Erreur d'insertion pour le tuple $id");
|
| 283 |
if ($epithete != '') {
|
- |
|
| 284 |
if (substr($epithete, 0, 2) == 'x ') {
|
155 |
}
|
| 285 |
$html = ' <span class=hyb>x <span class="'.$type.'">'.str_replace('x ', '', $epithete).'</span></span>';
|
156 |
}
|
| 286 |
} elseif (substr($epithete, 0, 2) == '+ ') {
|
157 |
}
|
| 287 |
$html = ' <span class=chimere>+ <span class="'.$type.'">'.str_replace('+ ', '', $epithete).'</span></span>';
|
- |
|
| 288 |
} else if (substr_count($epithete, ' x ') > 1) {// Cas d'une formule d'hybridité comprenant des parents hybrides
|
- |
|
| 289 |
$html = ' '.$this->insererBaliseFormuleHyb($epithete);
|
- |
|
| 290 |
} elseif (substr_count($epithete, ' x ') == 1) {// Cas d'une formule d'hybridité simple
|
- |
|
| 291 |
$html = ' '.$this->ajouterFomuleHybridite($epithete, $type);
|
- |
|
| 292 |
} else {
|
- |
|
| 293 |
$html = ' <span class="'.$type.'">'.$epithete.'</span>';
|
- |
|
| 294 |
}
|
- |
|
| 295 |
}
|
- |
|
| 296 |
return $html;
|
- |
|
| 297 |
}
|
- |
|
| 298 |
|
- |
|
| 299 |
private function ajouterFomuleHybridite($formule, $type) {
|
- |
|
| 300 |
$tab_x = explode(' x ', $formule);
|
- |
|
| 301 |
$formule_hyb = array();
|
- |
|
| 302 |
switch ($type) {
|
- |
|
| 303 |
case 'gen' :
|
- |
|
| 304 |
foreach ($tab_x as $hyb) {
|
- |
|
| 305 |
$formule_hyb[] = sprintf($this->genTpl, $hyb);
|
- |
|
| 306 |
}
|
- |
|
| 307 |
break;
|
- |
|
| 308 |
case 'sp' :
|
- |
|
| 309 |
foreach ($tab_x as $hyb) {
|
- |
|
| 310 |
if (substr_count($hyb, ' ') >= 1) {
|
- |
|
| 311 |
list($gen, $sp) = explode(' ', $hyb);
|
- |
|
| 312 |
$formule_hyb[] = sprintf($this->spFHTpl, $gen, $sp);
|
- |
|
| 313 |
} else {
|
- |
|
| 314 |
$avertissement = "Nom #%s : la valeur d'hybride '%s' ne contenait pas d'espace .";
|
- |
|
| 315 |
$this->traiterAvertissement($avertissement, array($this->num, $hyb));
|
- |
|
| 316 |
}
|
- |
|
| 317 |
}
|
- |
|
| 318 |
break;
|
- |
|
| 319 |
case 'infra-sp' :
|
- |
|
| 320 |
foreach ($tab_x as $hyb) {
|
- |
|
| 321 |
list($gen, $sp, $typeEpithete, $infraSp) = explode (' ', $hyb);
|
- |
|
| 322 |
$formule_hyb[] = sprintf($this->infraSpFHTpl, $gen, $sp, $this->abbr[$typeEpithete], $typeEpithete, $infraSp);
|
- |
|
| 323 |
}
|
- |
|
| 324 |
break;
|
- |
|
| 325 |
default : break;
|
- |
|
| 326 |
}
|
- |
|
| 327 |
return $this->insererBaliseFormuleHyb(implode(' x ', $formule_hyb));
|
- |
|
| 328 |
}
|
- |
|
| 329 |
|
- |
|
| 330 |
private function insererBaliseFormuleHyb($formule) {
|
- |
|
| 331 |
return sprintf($this->formuleHybTpl, $formule);
|
- |
|
| 332 |
}
|
- |
|
| 333 |
|
- |
|
| 334 |
private function lancerRequeteModification() {
|
- |
|
| 335 |
foreach ($this->table_requete as $id => $html) {
|
158 |
|
| 336 |
$html = $this->bdd->proteger($html);
|
159 |
private function stopperLaBoucle() {
|
| 337 |
$requete = "UPDATE {$this->table} ".
|
160 |
$stop = false;
|
| 338 |
"SET nom_sci_html = $html ".
|
161 |
static $ligneActuelle = 1;
|