\n";
$lignes = organize_line($fields);
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':
//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 $error = "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($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':
//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':
//Numéro de bulletin
$bull_num = $value;
break;
case 'VL':
//Volume
$bull_vol = $value;
break;
case 'AB':
//Résumé
$resume = $value;
break;
case 'JF':
//Titre du pério
$perio_title = $value;
break;
default:
$data .= '';
break;
}
}
//Construction du fichier
$data.= "n
a
a
2
1
i\n";
//Soyons sûr que le microtime ne sera plus le même..
usleep(1);
$data.="\n";
$data.=htmlspecialchars(microtime(),ENT_QUOTES,$charset);
$data.="\n";
if($titre){
$data.="\n";
$data.=" ".htmlspecialchars($titre,ENT_QUOTES,$charset)."";
if($titre_other) $data.=" ".htmlspecialchars($titre_other,ENT_QUOTES,$charset)."";
$data.="\n";
}
if($editeur_nom || $publication_date || $editeur_ville){
$data.="\n";
if($editeur_ville) $data.=" ".htmlspecialchars($editeur_ville,ENT_QUOTES,$charset)."\n";
if($editeur_nom) $data.=" ".htmlspecialchars($editeur_nom,ENT_QUOTES,$charset)."\n";
if($publication_date) $data.=" ".htmlspecialchars($publication_date,ENT_QUOTES,$charset)."";
$data.="\n";
}
if($start_page || $end_page){
$data.="\n";
if($start_page && $end_page) $data.=" ".htmlspecialchars($start_page."-".$end_page,ENT_QUOTES,$charset)."\n";
if(!$start_page && $end_page) $data.=" ".htmlspecialchars($end_page,ENT_QUOTES,$charset)."\n";
if($start_page && !$end_page) $data.=" ".htmlspecialchars($start_page,ENT_QUOTES,$charset)."\n";
$data.="\n";
}
if($notes){
$note = explode('###',$notes);
$doi ="";
$pubmedid = "";
for($i=0;$i 9000){
$word =wordwrap($note[$i],9000,"####");
$words = explode("####",$word);
for($j=0;$j\n";
$data.=" ".htmlspecialchars($words[$j],ENT_QUOTES,$charset)."\n";
$data.="\n";
}
} else {
$data.="\n";
$data.=" ".htmlspecialchars($note[$i],ENT_QUOTES,$charset)."\n";
$data.="\n";
}
}
}
}
if($resume){
$data.="\n";
$data.=" ".htmlspecialchars($resume,ENT_QUOTES,$charset)."\n";
$data.="\n";
}
if($perio_title){
$data.="\n";
$data.=" ".htmlspecialchars($perio_title,ENT_QUOTES,$charset)."\n";
if($infos_issn) $data.=" ".htmlspecialchars($infos_issn,ENT_QUOTES,$charset)."\n";
$data.=" lnk:perio\n";
$data.="\n";
}
if($bull_num || $bull_vol){
$data.="\n";
if($bull_num && $bull_vol)
$data.=" "."vol. ".htmlspecialchars($bull_vol,ENT_QUOTES,$charset).", no. ".htmlspecialchars($bull_num,ENT_QUOTES,$charset)."\n";
else if($bull_num && !$bull_vol)
$data.=" no. ".htmlspecialchars($bull_num,ENT_QUOTES,$charset)."\n";
else if(!$bull_num && $bull_vol)
$data.=" vol. ".htmlspecialchars($bull_vol,ENT_QUOTES,$charset)."\n";
if($date_sql)
$data.=" ".htmlspecialchars($date_sql,ENT_QUOTES,$charset)."\n";
if($mention_date)
$data.=" ".htmlspecialchars($mention_date,ENT_QUOTES,$charset)."\n";
$data.=" lnk:bull\n";
$data.="\n";
}
if($keywords){
$mots = explode('###',$keywords);
for($i=0;$i\n";
$data.=" ".htmlspecialchars($mots[$i],ENT_QUOTES,$charset)."\n";
$data.="\n";
}
}
if($auteur_principal){
$aut = explode(", ",$auteur_principal);
$data.="\n";
$data.=" ".htmlspecialchars($aut[0],ENT_QUOTES,$charset)."\n";
$data.=" ".htmlspecialchars($aut[1],ENT_QUOTES,$charset)."\n";
if($aut[2]) $data.=" ".htmlspecialchars($aut[2],ENT_QUOTES,$charset)."\n";
$data.="\n";
}
if($collectivite){
$collectivites = explode("###",$collectivite);
if((count($collectivites) == 1) && !$auteur_principal) {
$coll_elt = explode(", ",$collectivites[0],2);
$coll_nom = $coll_elt[0];
$coll_pays = trim(substr($coll_elt[1],(strrpos($coll_elt[1],", ")+1)));
$coll_lieu = trim(substr($coll_elt[1],0,-(strlen($coll_pays)+2)));
$data.="\n";
$data.=" ".htmlspecialchars($coll_nom,ENT_QUOTES,$charset)."\n";
$data.=" ".htmlspecialchars($coll_lieu,ENT_QUOTES,$charset)."\n";
$data.=" ".htmlspecialchars($coll_pays,ENT_QUOTES,$charset)."\n";
$data.="\n";
} else {
for($i=0;$i\n";
$data.=" ".htmlspecialchars($coll_nom,ENT_QUOTES,$charset)."\n";
$data.=" ".htmlspecialchars($coll_lieu,ENT_QUOTES,$charset)."\n";
$data.=" ".htmlspecialchars($coll_pays,ENT_QUOTES,$charset)."\n";
$data.="\n";
}
}
}
if($autres_auteurs){
$others = explode("###",$autres_auteurs);
for($i=0;$i\n";
$data.=" ".htmlspecialchars($aut[0],ENT_QUOTES,$charset)."\n";
$data.=" ".htmlspecialchars($aut[1],ENT_QUOTES,$charset)."\n";
if($aut[2]) $data.=" ".htmlspecialchars($aut[2],ENT_QUOTES,$charset)."\n";
$data.="\n";
}
}
if($auteur_secondaire){
$secs = explode("###",$auteur_secondaire);
for($i=0;$i\n";
$data.=" ".htmlspecialchars($aut[0],ENT_QUOTES,$charset)."\n";
$data.=" ".htmlspecialchars($aut[1],ENT_QUOTES,$charset)."\n";
if($aut[2]) $data.=" ".htmlspecialchars($aut[2],ENT_QUOTES,$charset)."\n";
$data.="\n";
}
}
if($url){
$data.="\n";
$data.=" ".htmlspecialchars($url,ENT_QUOTES,$charset)."";
$data.="\n";
}
if($subtype){
$data.="\n";
$data.=" ".htmlspecialchars($subtype,ENT_QUOTES,$charset)."\n";
$data.=" Sub-Type\n";
$data.=" subtype\n";
$data.="\n";
}
if($doi){
$doi = trim(str_replace("doi:","",$doi));
if($doi){
$data.="\n";
$data.=" ".htmlspecialchars($doi,ENT_QUOTES,$charset)."\n";
$data.=" DOI id\n";
$data.=" pmi_doi_identifier\n";
$data.="\n";
}
}
if($pubmedid){
$pubmedid = trim(str_replace("PubMed ID:","",$pubmedid));
if($pubmedid){
$data.="\n";
$data.=" ".htmlspecialchars($pubmedid,ENT_QUOTES,$charset)."\n";
$data.=" Numéro PUBMED\n";
$data.=" pmi_xref_dbase_id\n";
$data.="\n";
}
}
$data .= "\n";
if (!$error) $r['VALID'] = true; else $r['VALID']=false;
$r['ERROR'] = $error;
$r['DATA'] = $data;
return $r;
}
?>