* @copyright Tela-Botanica 1999-2009 * @licence GPL v3 & CeCILL v2 * @version $Id: DecoupageAuteur.class.php 1873 2009-03-31 10:07:24Z Jean-Pascal MILCENT $ */ // +-------------------------------------------------------------------------------------------------------------------+ class DecoupageAuteur extends Decoupage { private $expression = array(); private $expression_in = array(); public function __construct() { parent::__construct(); $this->expresion[2] = '/^\s*\(([^)]+?)\) ('.$this->Auteur.') ex ('.$this->Auteur.')('.$this->Date.')?\s*$/u'; $this->expresion[3] = '/^\s*\(([^)]+?)\) ('.$this->Auteur.')('.$this->Date.')?\s*$/u'; $this->expresion[5] = '/^\s*('.$this->Auteur.') ex ('.$this->Auteur.')('.$this->Date.')?\s*$/u'; $this->expresion[6] = '/^\s*('.$this->Auteur.')('.$this->Date.')?\s*$/u'; $this->expresion[7] = '/^\s*\(([^)]+?)\) ('.$this->Auteur.'),? ('.$this->ComNom.')\s*$/u'; $this->expresion[8] = '/^\s*\(('.$this->Auteur.') ex ('.$this->Auteur.')\) ('.$this->ComNom.')\s*$/u'; $this->expresion[9] = '/^\s*('.$this->Auteur.') ex ('.$this->Auteur.'),? ('.$this->ComNom.')\s*$/u'; $this->expresion[10] = '/^\s*\(('.$this->Auteur.')\) ('.$this->ComNom.')\s*$/u'; $this->expresion[11] = '/^\s*('.$this->Auteur.'),? ('.$this->ComNom.')\s*$/u'; $this->expresion[12] = '/^\s*('.$this->ComNom.')\s*$/u'; $this->expresion[13] = '/^\s*\(('.$this->Auteur.')\) ('.$this->Auteur.'),? ('.$this->InAut.')\s*$/u'; $this->expresion[14] = '/^\s*\(('.$this->Auteur.') ex ('.$this->Auteur.')\) ('.$this->InAut.')\s*$/u'; $this->expresion[15] = '/^\s*('.$this->Auteur.') ex ('.$this->Auteur.'),? ('.$this->InAut.')\s*$/u'; $this->expresion[16] = '/^\s*\(('.$this->Auteur.')\) ('.$this->InAut.')\s*$/u'; $this->expresion[17] = '/^\s*('.$this->Auteur.') ('.$this->InAut.')\s*$/u'; $this->expresion[18] = '/^\s*('.$this->Auteur.'),? ('.$this->InAut.')\s*$/u'; $this->expresion[19] = '/^\s*('.$this->InAut.')\s*$/u'; $this->expresion_in[1] = '/^\s*[iI]n ('.$this->Auteur.') ?('.$this->ComNom.')?\s*$/u'; $this->expresion_in[2] = '/^\s*[iI]n ('.$this->NumAuteur.') ?('.$this->ComNom.')?\s*$/u'; } public function decouper($str_intitule) { $aso_intitule = array( 'auteur_basio_ex' => '', 'auteur_basio' => '', 'auteur_modif_ex' => '', 'auteur_modif' => '', 'date' => '', 'annee' => '', 'commentaires_nomenclaturaux' => '', 'citation_in_auteur' => '', 'integration_ok' => 1, 'erreur_mark' => '', 'erreur_notes' => ''); if ($str_intitule != '') { $morceau = array(); //Gestion des intitulés auteurs SANS commentaires nomenclaturaux if (preg_match($this->expresion[6], $str_intitule, $morceau)) { $aso_intitule['auteur_basio'] = $morceau[1]; $aso_intitule['date'] = $morceau[2]; $aso_date = $this->decouperDate($aso_intitule['date']); $aso_intitule['annee'] = $aso_date['annee']; } else if (preg_match($this->expresion[5], $str_intitule, $morceau)) { $aso_intitule['auteur_basio_ex'] = $morceau[1]; $aso_intitule['auteur_basio'] = $morceau[2]; $aso_intitule['date'] = $morceau[3]; $aso_date = $this->decouperDate($aso_intitule['date']); $aso_intitule['annee'] = $aso_date['annee']; } else if (preg_match($this->expresion[3], $str_intitule, $morceau)) { $aso_auteur = $this->decouperAuteurEx($morceau[1]); $aso_intitule{'auteur_basio_ex'} = $aso_auteur['auteur_ex']; $aso_intitule{'auteur_basio'} = $aso_auteur['auteur']; $aso_intitule['erreur_mark'] = $aso_auteur['erreur_mark']; $aso_intitule['erreur_notes'] = $str_intitule; $aso_intitule{'auteur_modif'} = $morceau[2]; $aso_intitule{'date'} = $morceau[3]; $aso_date = $this->decouperDate($aso_intitule['date']); $aso_intitule['annee'] = $aso_date['annee']; } else if (preg_match($this->expresion[2], $str_intitule, $morceau)) { $aso_auteur = $this->decouperAuteurEx($morceau[1]); $aso_intitule{'auteur_basio_ex'} = $aso_auteur['auteur_ex']; $aso_intitule{'auteur_basio'} = $aso_auteur['auteur']; $aso_intitule['erreur_mark'] = $aso_auteur['erreur_mark']; $aso_intitule['erreur_notes'] = $str_intitule; $aso_intitule{'auteur_modif_ex'} = $morceau[2]; $aso_intitule{'auteur_modif'} = $morceau[3]; $aso_intitule{'date'} = $morceau[4]; $aso_date = $this->decouperDate($aso_intitule['date']); $aso_intitule['annee'] = $aso_date['annee']; } else if (preg_match($this->expresion[7], $str_intitule, $morceau)) { // Gestion des intitulés auteurs AVEC commentaires nomenclaturaux $aso_auteur = $this->decouperAuteurEx($morceau[1]); $aso_intitule{'auteur_basio_ex'} = $aso_auteur['auteur_ex']; $aso_intitule{'auteur_basio'} = $aso_auteur['auteur']; $aso_intitule['erreur_mark'] = $aso_auteur['erreur_mark']; $aso_intitule['erreur_notes'] = $str_intitule; $aso_intitule{'auteur_modif'} = $morceau[2]; $aso_intitule{'commentaires_nomenclaturaux'} = $morceau[3]; } else if (preg_match($this->expresion[8], $str_intitule, $morceau)) { $aso_intitule{'auteur_basio_ex'} = $morceau[1]; $aso_intitule{'auteur_basio'} = $morceau[2]; $aso_intitule{'commentaires_nomenclaturaux'} = $morceau[3]; } else if (preg_match($this->expresion[9], $str_intitule, $morceau)) { $aso_intitule{'auteur_basio_ex'} = $morceau[1]; $aso_intitule{'auteur_basio'} = $morceau[2]; $aso_intitule{'commentaires_nomenclaturaux'} = $morceau[3]; } else if (preg_match($this->expresion[10], $str_intitule, $morceau)) { $aso_intitule{'auteur_basio'} = $morceau[1]; $aso_intitule{'commentaires_nomenclaturaux'} = $morceau[2]; } else if (preg_match($this->expresion[11], $str_intitule, $morceau)) { $aso_intitule{'auteur_basio'} = $morceau[1]; $aso_intitule{'commentaires_nomenclaturaux'} = $morceau[2]; } else if (preg_match($this->expresion[12], $str_intitule, $morceau)) { $aso_intitule{'commentaires_nomenclaturaux'} = $morceau[1]; } else if (preg_match($this->expresion[13], $str_intitule, $morceau)) { // Gestion des intitulés auteurs AVEC "in" $aso_intitule{'auteur_basio'} = $morceau[1]; $aso_intitule{'auteur_modif'} = $morceau[2]; $aso_intitule{'citation_in_auteur'} = $morceau[3]; } else if (preg_match($this->expresion[14], $str_intitule, $morceau)) { $aso_intitule{'auteur_basio_ex'} = $morceau[1]; $aso_intitule{'auteur_basio'} = $morceau[2]; $aso_intitule{'citation_in_auteur'} = $morceau[3]; } else if (preg_match($this->expresion[15], $str_intitule, $morceau)) { $aso_intitule{'auteur_basio_ex'} = $morceau[1]; $aso_intitule{'auteur_basio'} = $morceau[2]; $aso_intitule{'citation_in_auteur'} = $morceau[3]; } else if (preg_match($this->expresion[16], $str_intitule, $morceau)) { $aso_intitule{'auteur_basio'} = $morceau[1]; $aso_intitule{'citation_in_auteur'} = $morceau[2]; } else if (preg_match($this->expresion[17], $str_intitule, $morceau)) { $aso_intitule{'auteur_basio'} = $morceau[1]; $aso_intitule{'citation_in_auteur'} = $morceau[2]; } else if (preg_match($this->expresion[18], $str_intitule, $morceau)) { $aso_intitule{'auteur_basio'} = $morceau[1]; $aso_intitule{'citation_in_auteur'} = $morceau[2]; } else if (preg_match($this->expresion[19], $str_intitule, $morceau)) { $aso_intitule{'citation_in_auteur'} = $morceau[1]; } else { $aso_intitule['erreur_mark'] = 'erreur'; $aso_intitule['erreur_notes'] .= $str_intitule; } } return $aso_intitule; } public function decouperIn($str_intitule) { $aso_intitule = array( 'in_intitule_auteur' => '', 'in_commentaire_nomenclatural' => '', 'erreur_mark' => '', 'erreur_notes' => ''); if ($str_intitule != '') { $morceau = array(); if (preg_match($this->expresion_in[1], $str_intitule, $morceau)) { $aso_intitule{'in_intitule_auteur'} = $morceau[1]; $aso_intitule{'in_commentaire_nomenclatural'} = $morceau[2]; } else if (preg_match($this->expresion_in[2], $str_intitule, $morceau)) { $aso_intitule{'in_intitule_auteur'} = $morceau[1]; $aso_intitule{'in_commentaire_nomenclatural'} = $morceau[2]; } else { $aso_intitule['erreur_mark'] = 'erreur'; $aso_intitule['erreur_notes'] .= $str_intitule; } } return $aso_intitule; } private function decouperAuteurEx($chaine) { $aso_retour = array('auteur_ex' => '', 'auteur' => '', 'erreur_mark' => '', 'erreur_notes' => ''); if (preg_match($this->expresion[5], $chaine, $morceau)) { $aso_retour['auteur_ex'] = $morceau[1]; $aso_retour['auteur'] = $morceau[2]; } else if (preg_match($this->expresion[6], $chaine, $morceau)) { $aso_retour['auteur'] = $morceau[1]; } else { $aso_retour['erreur_mark'] = 'erreur'; $aso_retour['erreur_notes'] = $chaine; } return $aso_retour; } private function decouperDate($chaine) { $aso_retour = array('annee' => ''); if (preg_match('/^\[(\d{4})]\$/', $chaine, $morceau = array())) { $aso_retour['annee'] = $morceau[1]; } return $aso_retour; } } ?>