\n";
$lignes = static::organize_line($fields);
//initialisation des champs
$titre = $titre_other = $editeur_nom = $editeur_ville = $auteur_principal = $infos_isbn = $infos_issn = $url = $mention_date = $date_sql = '';
$subtype = $notes = $start_page = $end_page = $keywords = $collectivite = $bull_num = $bull_vol = $resume = $perio_title = '';
$auteur_secondaire = $autres_auteurs = $doi = '';
//Parcours
foreach($lignes as $champ=>$value) {
switch($champ){
case 'CT':
case 'TI':
case 'T1':
//Titre principal
$titre = $value;
break;
case 'T2':
//Autre info sur titre
$titre_other = $value;
break;
case 'PB':
//Editeur
$editeur_nom = $value;
break;
case 'CY':
//Editeur
$editeur_ville = $value;
break;
case 'AU':
case 'A3':
case 'A4':
//Autres auteurs
$autres_auteurs = $value;
break;
case 'A1':
//Auteur principal
$auteur_principal = $value;
break;
case 'A2':
//Auteur secondaire
$auteur_secondaire = $value;
break;
case 'SN':
//ISBN/ISSN
$code = trim($value);
$pos = strpos($code,"(");
if ($pos !== false) $code = substr($code,0,$pos);
if(isISBN($code)){
$infos_isbn=$code;
} elseif(isISSN($code)){
$infos_issn=$code;
} else {
$infos_isbn=$infos_issn=$code;
$warning = "wrong ISBN/ISSN \n";
}
break;
case 'UR':
//URL
$url = $value;
break;
case 'PY':
//Date de publication (YYYY/MM/DD)
$dates = explode("/",$value);
if($dates[0]) $year = $dates[0];
if($dates[1]) $month = $dates[1];
if($dates[2]) $day = $dates[2];
$publication_date = $year;
if(!isset($lignes['Y1']) && $year && $month && $day){
$date_sql = str_replace("/","-",$value);
$mention_date = $value;
} else if($year && $month && !$day){
$date_sql = $year."-".$month."-01";
$mention_date = $year."/".$month;
} else if($year && !$month && !$day){
$date_sql = $year."-01-01";
$mention_date = $year;
}
break;
case 'Y1' :
$dates = explode("/",$value);
if($dates[0]) $year = $dates[0];
if($dates[1]) $month = $dates[1];
if($dates[2]) $day = $dates[2];
if(!isset($lignes['PY'])){
$publication_date = $year;
}
if($year && $month && $day){
$date_sql = str_replace("/","-",$value);
$mention_date = $value;
} else if($year && $month && !$day){
$date_sql = $year."-".$month."-01";
$mention_date = $year."/".$month;
} else if($year && !$month && !$day){
$date_sql = $year."-01-01";
$mention_date = $year;
}
break;
case 'TY':
//Document type
switch($value){
case 'ABST':
$subtype='Abstract';
break;
case 'BOOK':
$subtype='Book';
break;
case 'CHAP':
$subtype='Chapter';
break;
case 'COMP':
$subtype='Computing Program';
break;
case 'CONF':
$subtype='Conference Proceedings';
break;
case 'INPR':
$subtype='Preprint';
break;
case 'NEWS':
case 'JFULL':
$subtype='Journal';
break;
case 'MGZN':
case 'JOUR':
$subtype='Article';
break;
case 'MAP':
$subtype='Map';
break;
case 'UNPB':
case 'RPRT':
$subtype='Report';
break;
case 'SLIDE':
$subtype='Presentation';
break;
case 'THES':
$subtype='Thesis';
break;
default :
$subtype='Article';
break;
}
break;
case 'N1':
case 'N2':
//Notes
if($notes){
$notes.='###';
}
$notes.= $value;
break;
case 'SP':
//Start page
$start_page = $value;
break;
case 'EP':
//End page
$end_page = $value;
break;
case 'KW':
//Mots cles
$keywords = $value;
break;
case 'AD':
//Collectivite
$collectivite = $value;
break;
case 'IS':
case 'IP':
//Numéro de bulletin
$bull_num = $value;
break;
case 'VL':
case 'VI':
//Volume
$bull_vol = $value;
break;
case 'AB':
//Résumé
$resume = $value;
break;
case 'JF':
//Titre complet du pério
$perio_title = $value;
break;
case 'JO' :
//Titre standard du pério
if(!isset($lignes['JF'])){
$perio_title = $value;
}
break;
case 'DO' :
//Numéro de DOI
$doi = $value;
default:
$data .= '';
break;
}
}
//Construction du fichier
$data.= "