<?
include ("connection.php");
print "<title>ANISEED CURATOR - Add an article</title>";

include ("frames_header.php");




$pmid=$_POST["pmid"];

if (strlen($pmid)==0) print "<center><br><b><i>Please, Enter a PMID first !</i></b><br></center>";




$resource=curl_init("http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?id=$pmid&db=pubmed&report=xml");
curl_setopt($resource, CURLOPT_RETURNTRANSFER, 1);
$contents=curl_exec($resource);
curl_close($resource);



//print $contents;
//Nom de l'article
$contents2=str_replace("&lt;ArticleTitle&gt;","§",$contents);
$contents2=str_replace("&lt;/ArticleTitle&gt;","§",$contents2);
$tab=split("§",$contents2);
$title=$tab[1];

//Nom du journal
$contents2=str_replace("&lt;MedlineTA&gt;","§",$contents);
$contents2=str_replace("&lt;/MedlineTA&gt;","§",$contents2);
$tab=split("§",$contents2);
$paper=$tab[1];

//Nom des auteurs
$contents2=str_replace("&lt;LastName&gt;","§",$contents);
$contents2=str_replace("&lt;/LastName&gt;","§",$contents2);
$tab=split("§",$contents2);
for ($i=1;$i<count($tab)-1;$i++)
	if ($i%2!=0) $auteurN[count($auteurN)]=$tab[$i];
$contents2=str_replace("&lt;Initials&gt;","§",$contents);
$contents2=str_replace("&lt;/Initials&gt;","§",$contents2);
$tab=split("§",$contents2);
for ($i=1;$i<count($tab)-1;$i++)
	if ($i%2!=0) $auteurI[count($auteurI)]=$tab[$i];
$auteur="";
for ($i=0;$i<count($auteurN)-1;$i++)
$auteur.=$auteurN[$i]." ".$auteurI[$i].", ";
$auteur.=$auteurN[count($auteurN)-1]." ".$auteurI[count($auteurN)-1];

//Le volume
$contents2=str_replace("&lt;Volume&gt;","§",$contents);
$contents2=str_replace("&lt;/Volume&gt;","§",$contents2);
$tab=split("§",$contents2);
$volume=$tab[1];

//L'issue
$contents2=str_replace("&lt;Issue&gt;","§",$contents);
$contents2=str_replace("&lt;/Issue&gt;","§",$contents2);
$tab=split("§",$contents2);
$issue=$tab[1];

//L'année
$contents2=str_replace("&lt;Year&gt;","§",$contents);
$contents2=str_replace("&lt;/Year&gt;","§",$contents2);
$tab=split("§",$contents2);
$year=$tab[1];

//la page
$contents2=str_replace("&lt;MedlinePgn&gt;","§",$contents);
$contents2=str_replace("&lt;/MedlinePgn&gt;","§",$contents2);
$tab=split("§",$contents2);
$page=$tab[1];


$paper.=". ".$year." ".$month.";".$volume."(".$issue."):".$page;




print "<center><h2>Add a new Article in the database</h2></center><br>
<center><b>STEP2 : Validate the informations on the article you request<br></b></center>
<br>
";

?>
<form name="formu" action="add-article3.php" method="POST">
<?

print "<TABLE >
	<center>
	<tr>
	<td><i>PubmedID: </i></td>
	<td> <input type=text size=20 name=pmid value=\"$pmid\"></td>
	</tr>
	<tr>
	<td><i>Title: </i></td>
	<td> <input type=text size=100 name=title value=\"$title\"></td>
	</tr>
	<tr>
	<td><i>Paper: </i></td>
	<td> <input type=text size=50 name=paper value=\"$paper\"></td>
	</tr>
	<tr>
	<td><i>Authors </i></td>
	<td> <input type=text size=100 name=author value=\"$auteur\"></td>
	</tr>
	<tr>
	<td><i>URL: </i></td>
	<td> <input type=text size=50 name=url></td>
	</tr>
	<tr>
	<td><i>Comments: </i></td>
	<td> <input type=text size=\"100\" name=comments></td>
	</tr>
	<tr>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	</tr>
	<tr>
	<td>&nbsp;</td>
	<td>&nbsp;</td>
	</tr>
	<tr>
";
?>
<td>
&nbsp;
</td>
</tr>

<center><input name="submit" type="image" src="pictures/button-submit.jpg" onClick="submit"></center>

</form>






<?

include ("frames_footer.php");

?>
