344 |
jpm |
1 |
<?php
|
|
|
2 |
// Encodage : UTF-8
|
|
|
3 |
// +-------------------------------------------------------------------------------------------------------------------+
|
|
|
4 |
/**
|
|
|
5 |
* Découpage des citations bibliographiques.
|
|
|
6 |
*
|
|
|
7 |
* Description : classe permettant de découper les citations.
|
|
|
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: DecoupageCitation.class.php 1873 2009-03-31 10:07:24Z Jean-Pascal MILCENT $
|
|
|
14 |
*/
|
|
|
15 |
// +-------------------------------------------------------------------------------------------------------------------+
|
|
|
16 |
class DecoupageCitation extends Decoupage {
|
|
|
17 |
|
|
|
18 |
private $expression_principale = array();
|
|
|
19 |
private $expression_page = array();
|
|
|
20 |
|
|
|
21 |
function DecoupageCitation()
|
|
|
22 |
{
|
|
|
23 |
parent::__construct();
|
|
|
24 |
|
|
|
25 |
// Biblio
|
|
|
26 |
$this->expression_principale[1] = '/^(?:, |)(?:('.$this->Com.')|)(?:('.$this->In.'), |)(?:'.$this->Bib.'|)(?: ('.$this->Inf.')|)$/u';
|
|
|
27 |
// Biblio à exclure
|
|
|
28 |
$this->expression_principale[2] = '/^,? ('.$this->HomCourt.')$/u';
|
|
|
29 |
|
|
|
30 |
// Biblio : abréviation publi et précision (volume, tome, édition...)
|
|
|
31 |
$this->expression_ref[1] = '/^([^,$]+)(.*)$/u';//
|
|
|
32 |
|
|
|
33 |
// Pages début et fin
|
|
|
34 |
$this->expression_page[1] = '/^(\d+)-(\d+)$/u';//
|
|
|
35 |
// Page unique
|
|
|
36 |
$this->expression_page[2] = '/^(\d+)(?:\.|)$/u';//
|
|
|
37 |
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
public function decouper($citation)
|
|
|
41 |
{
|
|
|
42 |
$aso_nom_decompo = array( 'num_nomenc' => '', 'num_taxo' => '',
|
|
|
43 |
'in_auteur' => '', 'abreviation' => '', 'precision' => '',
|
|
|
44 |
'annee' => '', 'source_biblio_exclure' => '',
|
|
|
45 |
'info_combinaison' => '', 'page_debut' => null,'page_fin' => null,
|
|
|
46 |
'page_erreur_mark' => '', 'page_erreur_notes' => '');
|
|
|
47 |
$aso_nom_decompo['citation_complete'] = $citation;
|
|
|
48 |
while ($citation != '') {
|
|
|
49 |
$morceau = array();
|
|
|
50 |
if (preg_match($this->expression_principale[1], $citation, $morceau)) {// Biblio
|
|
|
51 |
$aso_nom_decompo['info_combinaison'] = $morceau[1];
|
|
|
52 |
$aso_nom_decompo['in_auteur'] = $morceau[2];
|
|
|
53 |
$aso_publi = $this->decouperPubli($morceau[3]);
|
|
|
54 |
$aso_nom_decompo['abreviation'] = $aso_publi['abreviation'];
|
|
|
55 |
$aso_nom_decompo['precision'] = $aso_publi['precision'];
|
|
|
56 |
$aso_nom_decompo['pages'] = $morceau[4];
|
|
|
57 |
$aso_pages = $this->decouperPages($morceau[4]);
|
|
|
58 |
$aso_nom_decompo['page_debut'] = $aso_pages['page_debut'];
|
|
|
59 |
$aso_nom_decompo['page_fin'] = $aso_pages['page_fin'];
|
|
|
60 |
$aso_nom_decompo['page_erreur_mark'] = $aso_pages['erreur_mark'];
|
|
|
61 |
$aso_nom_decompo['page_erreur_notes'] = $aso_pages['erreur_notes'];
|
|
|
62 |
$aso_nom_decompo['annee'] = $morceau[5];
|
|
|
63 |
$citation = $morceau[6];
|
|
|
64 |
} else if (preg_match($this->expression_principale[2], $citation, $morceau)) {// Nom d'sp.
|
|
|
65 |
$aso_nom_decompo['source_biblio_exclure'] = $morceau[1];
|
|
|
66 |
$citation = $morceau[2];
|
|
|
67 |
} else {// Erreurs
|
|
|
68 |
$aso_nom_decompo['erreur_mark'] = 'erreur';
|
|
|
69 |
$aso_nom_decompo['erreur_notes'] = $citation;
|
|
|
70 |
$citation = '';
|
|
|
71 |
}
|
|
|
72 |
}
|
|
|
73 |
return $aso_nom_decompo;
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
public function decouperPubli($ref)
|
|
|
77 |
{
|
|
|
78 |
$ref = trim($ref);
|
|
|
79 |
$aso_ref = array('abreviaton' => null,'precision' => null, 'erreur_mark' => '', 'erreur_notes' => '');
|
|
|
80 |
if (preg_match($this->expression_ref[1], $ref, $morceau)) {
|
|
|
81 |
$aso_ref['abreviation'] = $morceau[1];
|
|
|
82 |
$aso_ref['precision'] = preg_replace('/^\s*,\s*/', '', $morceau[2]);
|
|
|
83 |
} else {// Erreurs
|
|
|
84 |
$aso_ref['erreur_mark'] = 'erreur';
|
|
|
85 |
$aso_ref['erreur_notes'] = $ref;
|
|
|
86 |
}
|
|
|
87 |
return $aso_ref;
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
public function decouperPages($pages)
|
|
|
91 |
{
|
|
|
92 |
$pages = trim($pages);
|
|
|
93 |
$aso_pages = array('page_debut' => null,'page_fin' => null, 'erreur_mark' => '', 'erreur_notes' => '');
|
|
|
94 |
if (preg_match($this->expression_page[1], $pages, $morceau)) {
|
|
|
95 |
$aso_pages['page_debut'] = $morceau[1];
|
|
|
96 |
$aso_pages['page_fin'] = $morceau[2];
|
|
|
97 |
} else if (preg_match($this->expression_page[2], $pages, $morceau)) {
|
|
|
98 |
$aso_pages['page_debut'] = $morceau[1];
|
|
|
99 |
} else {// Erreurs
|
|
|
100 |
$aso_pages['erreur_mark'] = 'erreur';
|
|
|
101 |
$aso_pages['erreur_notes'] = $pages;
|
|
|
102 |
}
|
|
|
103 |
return $aso_pages;
|
|
|
104 |
}
|
|
|
105 |
}
|
|
|
106 |
?>
|