\n";
$lignes = static::organize_line($fields);
//initialisation des champs
$typdoc = $authors = $others_authors = $title = $serial_title = $issue_volume = $issue_number = $pagination = $year = $abstract = $lang = $doi = '';
$publication_date = '';
//Parcours
foreach($lignes as $champ=>$value) {
switch($champ){
case 'PT':
$typdoc = $value;
break;
case 'AU':
$authors = $value;
break;
case 'TI' :
$title = $value;
break;
case 'SO':
$serial_title = $value;
break;
case 'VL' :
$issue_volume = $value;
break;
case 'IS':
$issue_number = $value;
break;
case 'PS':
$pagination = $value;
break;
case 'PY':
$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 'AB':
$abstract = $value;
break;
case 'LA':
$lang = $value;
break;
}
}
//SPECIFIQUE LIMAGRAIN...
// On force le type de document
$typdoc = "a";
//Construction du fichier
$data.= "n
".$typdoc."
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($langue){
$data.="\n";
$data.=" ".htmlspecialchars(strtolower(substr($lang,0,3)),ENT_QUOTES,$charset)."";
$data.="\n";
}
if($title){
$data.="\n";
$data.=" ".htmlspecialchars(implode(',',explode('###',$title)),ENT_QUOTES,$charset)."";
$data.="\n";
}
if($pagination){
$data.="\n";
$data.=" ".htmlspecialchars($pagination,ENT_QUOTES,$charset)."\n";
$data.="\n";
}
if($abstract){
$data.="\n";
$data.=" ".htmlspecialchars(implode(',',explode('###',$abstract)),ENT_QUOTES,$charset)."\n";
$data.="\n";
}
if($serial_title){
$data.="\n";
$data.=" ".htmlspecialchars(implode(',',explode('###',$serial_title)),ENT_QUOTES,$charset)."\n";
if($serial_issn) $data.=" ".htmlspecialchars($serial_issn,ENT_QUOTES,$charset)."\n";
$data.=" lnk:perio\n";
$data.="\n";
}
if($issue_number || $issue_volume){
$data.="\n";
if($issue_number && $issue_number)
$data.=" ".htmlspecialchars($issue_volume,ENT_QUOTES,$charset)."(".htmlspecialchars($issue_number,ENT_QUOTES,$charset).")\n";
else if($issue_number && !$issue_volume)
$data.=" ".htmlspecialchars($issue_number,ENT_QUOTES,$charset)."\n";
else if(!$issue_number && $issue_volume)
$data.=" ".htmlspecialchars($issue_volume,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($authors){
$first_auts = array();
$first_auts = explode("###",$authors);
$aut = explode(", ",array_shift($first_auts));
$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(is_array($first_auts) && count($first_auts)){
$others_authors = implode('###',$first_auts);
}
}
if($others_authors){
$others = explode("###",$others_authors);
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($doi){
$doi = trim($doi);
if($doi){
$data.="\n";
$data.=" ".htmlspecialchars($doi,ENT_QUOTES,$charset)."\n";
$data.=" DOI\n";
$data.=" cp_doi_identifier\n";
$data.="\n";
}
}
$data .= "\n";
if (!$error) $r['VALID'] = true; else $r['VALID']=false;
$r['ERROR'] = $error;
$r['DATA'] = $data;
return $r;
}
}