19,7 → 19,7 |
private $version = array('titre', 'acronyme', 'version', 'date_prod', |
'auteur_principal', 'coordinateur', 'editeur', 'contact', |
'contributeur', |
'dom_tax', 'dom_geo', 'dom_code', |
'classification', 'dom_tax', 'dom_geo', 'dom_code', |
'source', 'copyright', 'licence', 'referencement'); |
private $referentiel = null; |
private $traitementDao = null; |
99,7 → 99,7 |
$version = array(); |
foreach ($this->version as $champ) { |
if (isset($_POST[$champ])) { |
$version[$champ] = strip_tags(stripslashes($_POST[$champ])); |
$version[$champ] = stripslashes($_POST[$champ]); |
} else { |
$version[$champ] = $this->getValeurParDefaut($champ); |
|
121,7 → 121,9 |
*/ |
public function demanderTraitement() { |
if ($this->verifierMetadonnees()) { |
$this->ajouterTraitement($this->referentiel, self::SCRIPT_A_LANCER); |
$parametres = $this->instancierChampsVersionnage(); |
$parametres_serialises = serialize($parametres); |
$this->ajouterTraitementParametre($this->referentiel, $parametres_serialises, self::SCRIPT_A_LANCER); |
} |
$this->afficherInterface(); |
} |
131,7 → 133,18 |
*/ |
public function verifierMetadonnees() { |
$ok = true; |
$ok = ($this->verifierChampsObligatoires()) ? true : false; |
if (! $this->verifierChampsObligatoires()) { |
$ok = false; |
} |
if (! $this->verifierChampsMajuscule()) { |
$ok = false; |
} |
if (! $this->verifierChampsContact()) { |
$ok = false; |
} |
if (! $this->verifierChampsCourriel()) { |
$ok = false; |
} |
return $ok; |
} |
|
143,6 → 156,7 |
'auteur_principal' => 'Auteur Principal', |
'coordinateur' => 'coordinateur', |
'contact' => 'Courriel de contact', |
'classification' => 'Classification par défaut', |
'dom_tax' => 'Domaine taxonomique', |
'dom_geo' => 'Domaine géographique', |
'dom_code' => 'Codes botaniques utilisés', |
155,5 → 169,84 |
} |
return $ok; |
} |
|
public function verifierChampsMajuscule() { |
$ok = true; |
$champs_en_majuscule = array('acronyme' => 'Acronyme'); |
foreach ($champs_en_majuscule as $champ_id => $champ_nom) { |
if (isset($_POST[$champ_id]) && ! $this->verifierMajusculeSansAccent($_POST[$champ_id])) { |
$this->addMessage("Le champ '$champ_nom' doit être obligatoirement composé de majuscules non accentuées."); |
$ok = false; |
} |
} |
return $ok; |
} |
|
/** |
* Vérifie la mise en majuscule |
*/ |
public function verifierMajusculeSansAccent($txt) { |
$ok = (preg_match('/^[A-Z]+$/', $txt)) ? true : false; |
return $ok; |
} |
|
public function verifierChampsContact() { |
$ok = true; |
$champs_contact = array('auteur_principal' => 'Auteur Principal', |
'coordinateur' => 'coordinateur', |
'contributeur' => 'Auteurs/Contributeurs'); |
foreach ($champs_contact as $champ_id => $champ_nom) { |
if (isset($_POST[$champ_id]) && ! $this->verifierContact($_POST[$champ_id])) { |
$this->addMessage("Le champ '$champ_nom' n'est pas au format : Prénom1 NOM1 (Organisation1) <courriel1>, Prénom2 NOM2 (Organisation2) <courriel2>."); |
$ok = false; |
} |
} |
return $ok; |
} |
|
/** |
* Vérifie que le texte est au format : |
* Prénom1 NOM1 (Organisation1) <courriel1>, |
* Prénom2 NOM2 (Organisation2) <courriel2>. |
*/ |
public function verifierContact($txt) { |
$ok = true; |
if ($txt != '') { |
$pp = Pattern::PRENOM; |
$pn = Pattern::NOM; |
$po = "\([^\)]+\)";// Pattern organisation |
$pc = Pattern::COURRIEL; |
|
$contacts = explode(',', $txt); |
foreach ($contacts as $contact) { |
$contact = trim($contact); |
if (! preg_match("/^$pp $pn $po <$pc>(?:|.)$/u", $contact)) { |
$ok = false; |
} |
} |
} |
return $ok; |
} |
|
public function verifierChampsCourriel() { |
$ok = true; |
$champs_courriel = array('contact' => 'Courriel de contact'); |
foreach ($champs_courriel as $champ_id => $champ_nom) { |
if (isset($_POST[$champ_id]) && ! $this->verifierCourriel($_POST[$champ_id])) { |
$this->addMessage("Le champ '$champ_nom' ne comptient pas une adresse de courriel valide."); |
$ok = false; |
} |
} |
return $ok; |
} |
|
/** |
* Vérifie que le texte est une adresse de courriel valide. |
*/ |
public function verifierCourriel($txt) { |
$pattern_courriel = Pattern::COURRIEL; |
$ok = (preg_match('/^'.$pattern_courriel.'+$/', $txt)) ? true : false; |
return $ok; |
} |
} |
?> |