Subversion Repositories eFlore/Projets.eflore-projets

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
344 jpm 1
<?php
2
// Encodage : UTF-8
3
// +-------------------------------------------------------------------------------------------------------------------+
4
/**
5
* Découpage des intitulés auteurs
6
*
7
* Description : classe permettant de découper les intitulés d'auteurs.
8
*
9
//Auteur original :
10
* @author       Jean-Pascal MILCENT <jpm@tela-botanica.org>
11
* @copyright	Tela-Botanica 1999-2009
12
* @licence		GPL v3 & CeCILL v2
13
* @version		$Id: DecoupageAuteur.class.php 1873 2009-03-31 10:07:24Z Jean-Pascal MILCENT $
14
*/
15
// +-------------------------------------------------------------------------------------------------------------------+
16
class DecoupageAuteur extends Decoupage {
17
 
18
	private $expression = array();
19
	private $expression_in = array();
20
 
21
    public function __construct()
22
    {
23
		parent::__construct();
24
 
25
		$this->expresion[2] = '/^\s*\(([^)]+?)\) ('.$this->Auteur.') ex ('.$this->Auteur.')('.$this->Date.')?\s*$/u';
26
		$this->expresion[3] = '/^\s*\(([^)]+?)\) ('.$this->Auteur.')('.$this->Date.')?\s*$/u';
27
		$this->expresion[5] = '/^\s*('.$this->Auteur.') ex ('.$this->Auteur.')('.$this->Date.')?\s*$/u';
28
		$this->expresion[6] = '/^\s*('.$this->Auteur.')('.$this->Date.')?\s*$/u';
29
		$this->expresion[7] = '/^\s*\(([^)]+?)\) ('.$this->Auteur.'),? ('.$this->ComNom.')\s*$/u';
30
		$this->expresion[8] = '/^\s*\(('.$this->Auteur.') ex ('.$this->Auteur.')\) ('.$this->ComNom.')\s*$/u';
31
		$this->expresion[9] = '/^\s*('.$this->Auteur.') ex ('.$this->Auteur.'),? ('.$this->ComNom.')\s*$/u';
32
		$this->expresion[10] = '/^\s*\(('.$this->Auteur.')\) ('.$this->ComNom.')\s*$/u';
33
		$this->expresion[11] = '/^\s*('.$this->Auteur.'),? ('.$this->ComNom.')\s*$/u';
34
		$this->expresion[12] = '/^\s*('.$this->ComNom.')\s*$/u';
35
		$this->expresion[13] = '/^\s*\(('.$this->Auteur.')\) ('.$this->Auteur.'),? ('.$this->InAut.')\s*$/u';
36
		$this->expresion[14] = '/^\s*\(('.$this->Auteur.') ex ('.$this->Auteur.')\) ('.$this->InAut.')\s*$/u';
37
		$this->expresion[15] = '/^\s*('.$this->Auteur.') ex ('.$this->Auteur.'),? ('.$this->InAut.')\s*$/u';
38
		$this->expresion[16] = '/^\s*\(('.$this->Auteur.')\) ('.$this->InAut.')\s*$/u';
39
		$this->expresion[17] = '/^\s*('.$this->Auteur.') ('.$this->InAut.')\s*$/u';
40
		$this->expresion[18] = '/^\s*('.$this->Auteur.'),? ('.$this->InAut.')\s*$/u';
41
		$this->expresion[19] = '/^\s*('.$this->InAut.')\s*$/u';
42
 
43
		$this->expresion_in[1] = '/^\s*[iI]n ('.$this->Auteur.') ?('.$this->ComNom.')?\s*$/u';
44
		$this->expresion_in[2] = '/^\s*[iI]n ('.$this->NumAuteur.') ?('.$this->ComNom.')?\s*$/u';
45
    }
46
 
47
    public function decouper($str_intitule)
48
    {
49
		$aso_intitule = array(	'auteur_basio_ex' => '', 'auteur_basio' => '',
50
								'auteur_modif_ex' => '', 'auteur_modif' => '',
51
								'date' => '', 'annee' => '', 'commentaires_nomenclaturaux' => '',
52
								'citation_in_auteur' => '', 'integration_ok' => 1,
53
								'erreur_mark' => '', 'erreur_notes' => '');
54
		if ($str_intitule != '') {
55
			$morceau = array();
56
			//Gestion des intitulés auteurs SANS commentaires nomenclaturaux
57
	         if (preg_match($this->expresion[6], $str_intitule, $morceau)) {
58
				$aso_intitule['auteur_basio'] = $morceau[1];
59
				$aso_intitule['date'] = $morceau[2];
60
				$aso_date = $this->decouperDate($aso_intitule['date']);
61
				$aso_intitule['annee'] = $aso_date['annee'];
62
			} else if (preg_match($this->expresion[5], $str_intitule, $morceau)) {
63
				$aso_intitule['auteur_basio_ex'] = $morceau[1];
64
				$aso_intitule['auteur_basio'] = $morceau[2];
65
				$aso_intitule['date'] = $morceau[3];
66
				$aso_date = $this->decouperDate($aso_intitule['date']);
67
				$aso_intitule['annee'] = $aso_date['annee'];
68
			} else if (preg_match($this->expresion[3], $str_intitule, $morceau)) {
69
				$aso_auteur = $this->decouperAuteurEx($morceau[1]);
70
				$aso_intitule{'auteur_basio_ex'} = $aso_auteur['auteur_ex'];
71
				$aso_intitule{'auteur_basio'} = $aso_auteur['auteur'];
72
				$aso_intitule['erreur_mark'] = $aso_auteur['erreur_mark'];
73
				$aso_intitule['erreur_notes'] = $str_intitule;
74
				$aso_intitule{'auteur_modif'} = $morceau[2];
75
				$aso_intitule{'date'} = $morceau[3];
76
				$aso_date = $this->decouperDate($aso_intitule['date']);
77
				$aso_intitule['annee'] = $aso_date['annee'];
78
			} else if (preg_match($this->expresion[2], $str_intitule, $morceau)) {
79
				$aso_auteur = $this->decouperAuteurEx($morceau[1]);
80
				$aso_intitule{'auteur_basio_ex'} = $aso_auteur['auteur_ex'];
81
				$aso_intitule{'auteur_basio'} = $aso_auteur['auteur'];
82
				$aso_intitule['erreur_mark'] = $aso_auteur['erreur_mark'];
83
				$aso_intitule['erreur_notes'] = $str_intitule;
84
				$aso_intitule{'auteur_modif_ex'} = $morceau[2];
85
				$aso_intitule{'auteur_modif'} = $morceau[3];
86
				$aso_intitule{'date'} = $morceau[4];
87
				$aso_date = $this->decouperDate($aso_intitule['date']);
88
				$aso_intitule['annee'] = $aso_date['annee'];
89
			} else if (preg_match($this->expresion[7], $str_intitule, $morceau)) {
90
				// Gestion des intitulés auteurs AVEC commentaires nomenclaturaux
91
				$aso_auteur = $this->decouperAuteurEx($morceau[1]);
92
				$aso_intitule{'auteur_basio_ex'} = $aso_auteur['auteur_ex'];
93
				$aso_intitule{'auteur_basio'} = $aso_auteur['auteur'];
94
				$aso_intitule['erreur_mark'] = $aso_auteur['erreur_mark'];
95
				$aso_intitule['erreur_notes'] = $str_intitule;
96
				$aso_intitule{'auteur_modif'} = $morceau[2];
97
				$aso_intitule{'commentaires_nomenclaturaux'} = $morceau[3];
98
			} else if (preg_match($this->expresion[8], $str_intitule, $morceau)) {
99
				$aso_intitule{'auteur_basio_ex'} = $morceau[1];
100
				$aso_intitule{'auteur_basio'} = $morceau[2];
101
				$aso_intitule{'commentaires_nomenclaturaux'} = $morceau[3];
102
			} else if (preg_match($this->expresion[9], $str_intitule, $morceau)) {
103
				$aso_intitule{'auteur_basio_ex'} = $morceau[1];
104
				$aso_intitule{'auteur_basio'} = $morceau[2];
105
				$aso_intitule{'commentaires_nomenclaturaux'} = $morceau[3];
106
			} else if (preg_match($this->expresion[10], $str_intitule, $morceau)) {
107
				$aso_intitule{'auteur_basio'} = $morceau[1];
108
				$aso_intitule{'commentaires_nomenclaturaux'} = $morceau[2];
109
			} else if (preg_match($this->expresion[11], $str_intitule, $morceau)) {
110
				$aso_intitule{'auteur_basio'} = $morceau[1];
111
				$aso_intitule{'commentaires_nomenclaturaux'} = $morceau[2];
112
			} else if (preg_match($this->expresion[12], $str_intitule, $morceau)) {
113
				$aso_intitule{'commentaires_nomenclaturaux'} = $morceau[1];
114
			} else if (preg_match($this->expresion[13], $str_intitule, $morceau)) {
115
				// Gestion des intitulés auteurs AVEC "in"
116
				$aso_intitule{'auteur_basio'} = $morceau[1];
117
				$aso_intitule{'auteur_modif'} = $morceau[2];
118
				$aso_intitule{'citation_in_auteur'} = $morceau[3];
119
			} else if (preg_match($this->expresion[14], $str_intitule, $morceau)) {
120
				$aso_intitule{'auteur_basio_ex'} = $morceau[1];
121
				$aso_intitule{'auteur_basio'} = $morceau[2];
122
				$aso_intitule{'citation_in_auteur'} = $morceau[3];
123
			} else if (preg_match($this->expresion[15], $str_intitule, $morceau)) {
124
				$aso_intitule{'auteur_basio_ex'} = $morceau[1];
125
				$aso_intitule{'auteur_basio'} = $morceau[2];
126
				$aso_intitule{'citation_in_auteur'} = $morceau[3];
127
			} else if (preg_match($this->expresion[16], $str_intitule, $morceau)) {
128
				$aso_intitule{'auteur_basio'} = $morceau[1];
129
				$aso_intitule{'citation_in_auteur'} = $morceau[2];
130
			} else if (preg_match($this->expresion[17], $str_intitule, $morceau)) {
131
				$aso_intitule{'auteur_basio'} = $morceau[1];
132
				$aso_intitule{'citation_in_auteur'} = $morceau[2];
133
			} else if (preg_match($this->expresion[18], $str_intitule, $morceau)) {
134
				$aso_intitule{'auteur_basio'} = $morceau[1];
135
				$aso_intitule{'citation_in_auteur'} = $morceau[2];
136
			} else if (preg_match($this->expresion[19], $str_intitule, $morceau)) {
137
				$aso_intitule{'citation_in_auteur'} = $morceau[1];
138
			} else {
139
				$aso_intitule['erreur_mark'] = 'erreur';
140
				$aso_intitule['erreur_notes'] .= $str_intitule;
141
			}
142
		}
143
		return $aso_intitule;
144
    }
145
 
146
    public function decouperIn($str_intitule)
147
    {
148
	    $aso_intitule = array(	'in_intitule_auteur' => '', 'in_commentaire_nomenclatural' => '',
149
	                        	'erreur_mark' => '', 'erreur_notes' => '');
150
	    if ($str_intitule != '') {
151
	    	$morceau = array();
152
	    	if (preg_match($this->expresion_in[1], $str_intitule, $morceau)) {
153
	            $aso_intitule{'in_intitule_auteur'} = $morceau[1];
154
	            $aso_intitule{'in_commentaire_nomenclatural'} = $morceau[2];
155
	    	} else if (preg_match($this->expresion_in[2], $str_intitule, $morceau)) {
156
	            $aso_intitule{'in_intitule_auteur'} = $morceau[1];
157
	            $aso_intitule{'in_commentaire_nomenclatural'} = $morceau[2];
158
	    	} else {
159
	            $aso_intitule['erreur_mark'] = 'erreur';
160
				$aso_intitule['erreur_notes'] .= $str_intitule;
161
	    	}
162
	    }
163
	    return $aso_intitule;
164
    }
165
 
166
    private function decouperAuteurEx($chaine) {
167
		$aso_retour = array('auteur_ex' => '', 'auteur' => '', 'erreur_mark' => '', 'erreur_notes' => '');
168
		if (preg_match($this->expresion[5], $chaine, $morceau)) {
169
			$aso_retour['auteur_ex'] = $morceau[1];
170
			$aso_retour['auteur'] = $morceau[2];
171
		} else if (preg_match($this->expresion[6], $chaine, $morceau)) {
172
			$aso_retour['auteur'] = $morceau[1];
173
		} else {
174
			$aso_retour['erreur_mark'] = 'erreur';
175
			$aso_retour['erreur_notes'] = $chaine;
176
		}
177
		return $aso_retour;
178
	}
179
 
180
	private function decouperDate($chaine)
181
	{
182
		$aso_retour = array('annee' => '');
183
		if (preg_match('/^\[(\d{4})]\$/', $chaine, $morceau = array())) {
184
			$aso_retour['annee'] = $morceau[1];
185
		}
186
		return $aso_retour;
187
	}
188
}
189
?>