Subversion Repositories eFlore/Projets.eflore-projets

Compare Revisions

Ignore whitespace Rev 352 → Rev 353

/trunk/scripts/bibliotheque/GenerateurNomSciHtml.php
26,6 → 26,7
);
 
private $nomSciTpl = '<span class="sci">%s</span>';
 
private $nomSupraGenTpl = '<span class="supra_gen">%s</span>';
private $genTpl = '<span class="gen">%s</span>';
private $infraGenTpl = '<span class="infra-gen">%s</span>';
32,8 → 33,20
private $spFHTpl = '<span class="gen">%s</span> <span class="sp">%s</span>';
private $typeEpitheteTpl = '<abbr class="type_epithete" title="%s">%s</abbr>';
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>';
 
private $hybrideTpl = '<span class="hyb">× <span class="%s">%s</span></span>';
private $chimereTpl = '<span class="chimere">+ <span class="%s">%s</span></span>';
private $formuleHybTpl = '<span class="formule-hyb">%s</span>';
private $hybriditeTpl = '<span class="%s">%s</span>';
 
private $gpGxAvecCvarTpl = '<span class="gp">%s <abbr title="grex">gx</abbr>(%s <abbr title="groupe">Gp</abbr>)</span>';
private $gpGxSansCvarTpl = '<span class="gp">%s <abbr title="grex">gx</abbr>%s <abbr title="groupe">Gp</abbr></span>';
private $gxTpl = '<span class="gp">%s <abbr title="grex">gx</abbr></span>';
private $gpAvecCvarTpl = '<span class="gp">(%s <abbr title="groupe">Gp</abbr>)</span>';
private $gpSansCvarTpl = '<span class="gp">%s <abbr title="groupe">Gp</abbr></span>';
private $commTpl = '<span class="commercial">%s</span>';
private $cvarTpl = '<span class="cultivar">\'%s\'</span>';
 
public function generer(Array $nomsDecomposes) {
$nomsSciHtml = array();
foreach ($nomsDecomposes as $infos) {
133,10 → 146,10
$html .= ' '.$this->ajouterCultivarGroupe();
}
if ($this->avoirInfo('nom_commercial')) {
$html .= ' <span class="commercial">'.$this->compo_nom['nom_commercial'].'</span>';
$html .= ' '.sprintf($this->commTpl, $this->compo_nom['nom_commercial']);
}
if ($this->avoirInfo('cultivar')) {
$html .= ' <span class="cultivar">\''.$this->compo_nom['cultivar'].'\'</span>';
$html .= ' '.sprintf($this->cvarTpl, $this->compo_nom['cultivar']);
}
return $html;
}
164,43 → 177,30
*/
private function ajouterCultivarGroupe() {
$html = '';
// si le champ cultivar_groupe n'est pas vide
if ($this->avoirInfo('cultivar_groupe')) {
$groupe = $this->compo_nom['cultivar_groupe'];
//si le champ cultivar_groupe n'est pas vide
$groupe = trim($this->compo_nom['cultivar_groupe']);
 
// Sélection des templates
$tplGx = $this->gxTpl;
$tplGpGx = $this->gpGxSansCvarTpl;
$tplGp = $this->gpSansCvarTpl;
// s'il y a un cultivar, on ajoute des parenthèses au groupe (mais pas au grex)
if ($this->avoirInfo('cultivar')) {
//si il y a un cultivar, on ajoute des parenthèses au group (mais pas au grex)
if (strrpos($groupe, ' gx ') !== false) {
//si le grex est composé de groupe
$gpEtGx = explode(' gx ', $groupe);
$html = ' <span class="gp">'.
$gpEtGx[0].' '.'<abbr title="grex">gx</abbr>'.
' '.
'('.$gpEtGx[1].' <abbr title="groupe">Gp</abbr>)'.
'</span>';
} elseif (strrpos($groupe, ' gx') !== false) {
//si il y a un grex et pas de groupe
$gx = str_replace(' gx', '', $groupe);
$html = ' <span class="gp">'.$gx.' <abbr title="grex">gx</abbr></span>';
} else { //si il n'y a pas de grex mais un groupe
$html = ' <span class="gp">('.$groupe.' <abbr title="groupe">Gp</abbr>)</span>';
}
} else { //s'il n'y a pas de cultivar
if (strrpos($groupe, ' gx ') !== false) {
//si le grex est composé de groupe
$gpEtGx = explode(' gx ', $groupe);
$html = ' <span class="gp">'.
$gpEtGx[0].' <abbr title="grex">gx</abbr>'.
' '.
$gpEtGx[1].' <abbr title="groupe">Gp</abbr>'.
'</span>';
} elseif (strrpos($groupe, ' gx') !== false) {
//si il y a un grex et pas de groupe
$gx = str_replace(' gx', '', $groupe);
$html = ' <span class="gp">'.$gx.' <abbr title="grex">gx</abbr></span>';
} else { //si il n'y a pas de grex mais un groupe
$html = ' <span class="gp">'.$groupe.' <abbr title="groupe">Gp</abbr></span>';
}
$tplGpGx = $this->gpGxAvecCvarTpl;
$tplGp = $this->gpAvecCvarTpl;
}
 
// Création du HTML du groupe de cultivar
if (strrpos($groupe, ' gx ') !== false) {//si le grex est composé de groupe
$gpEtGx = explode(' gx ', $groupe);
$html = sprintf($tplGpGx, $gpEtGx[0], $gpEtGx[1]);
} else if (preg_match('/ gx$/', $groupe)) {//s'il y a un grex et pas de groupe
$gx = str_replace(' gx', '', $groupe);
$html = sprintf($tplGx, $gx);
} else { //s'il n'y a pas de grex mais un groupe
$html = sprintf($tplGp, $groupe);
}
}
return $html;
}
215,17 → 215,17
$html = '';
if ($epithete != '') {
if (substr($epithete, 0, 2) == 'x ') {
$html = ' <span class="hyb">x <span class="'.$type.'">'.str_replace('x ', '', $epithete).'</span></span>';
$hybride = str_replace('x ', '', $epithete);
$html = ' '.sprintf($this->hybrideTpl, $type, $hybride);
} elseif (substr($epithete, 0, 2) == '+ ') {
$html = ' <span class="chimere">+ <span class="'.$type.'">'.str_replace('+ ', '', $epithete).'</span></span>';
} else if (substr_count($epithete, ' x ') > 1) {
// Cas d'une formule d'hybridité comprenant des parents hybrides
$hybride = str_replace('+ ', '', $epithete);
$html = ' '.sprintf($this->chimereTpl, $type, $hybride);
} else if (substr_count($epithete, ' x ') > 1) {// Cas d'une formule d'hybridité comprenant des parents hybrides
$html = ' '.$this->insererBaliseFormuleHyb($epithete);
} elseif (substr_count($epithete, ' x ') == 1) {
// Cas d'une formule d'hybridité simple
} elseif (substr_count($epithete, ' x ') == 1) {// Cas d'une formule d'hybridité simple
$html = ' '.$this->ajouterFomuleHybridite($epithete, $type);
} else {
$html = ' <span class="'.$type.'">'.$epithete.'</span>';
} else {// Autre cas...
$html = ' '.sprintf($this->hybriditeTpl, $type, $epithete);
}
}
return $html;