<?php
require_once ('login/user.inc.php');
include ('phpbib/phpbib.inc.php');
?>
<?php include ('header.inc.php'); ?>
<body>
<?php include ('top.inc.php'); ?>
<div id="content">
<?php
if (($_SERVER['REQUEST_METHOD']!='POST'))
{
if ( ereg ( "MSIE" , $_SERVER['HTTP_USER_AGENT'] ))
{
echo "<script language=\"JavaScript1.2\" src=\"phpbib/scripts/validate.js\"></script>\n";
}
else
{
echo "<script language=\"JavaScript1.2\" type=\"application/x-javascript\" src=\"phpbib/scripts/validate.js\"></script>\n";
}
if ( ereg ( "MSIE" , $_SERVER['HTTP_USER_AGENT'] ))
{
echo "<script language=\"JavaScript1.2\">\n";
}
else
{
echo "<script language=\"JavaScript1.2\" type=\"application/x-javascript\">\n";
}
?>
function validatePubMedForm(form)
{
var str = form.term.value;
var re = /^[0-9]*$/;
if (form.term.value == "")
{
alert("Please enter a PubMed number.");
form.term.focus();
return false;
}
if (re.test(str))
{
return true;
}
else
{
alert("\"" + str + "\" is not a number.");
form.term.select();
form.term.focus();
return false;
}
}
function validateDOIForm(form)
{
if (!isDOI(form.term.value))
{
alert ("\"" + form.term.value + "\"" + " is not a valid DOI.");
return false;
}
return true;
}
function validateKeywordsForm(form)
{
if (form.term.value == '')
{
alert ("Please enter at least one keyword");
return false;
}
return true;
}
function validateAuthorsForm(form)
{
var str = '';
str = form.author1.value;
if (form.author2.value != '')
{
str += ' ';
str += form.author2.value;
}
if (form.author3.value != '')
{
str += ' ';
str += form.author3.value;
}
if (str != '')
{
form.term.value = str;
return true;
}
else
{
alert ("Please enter at least one author's name");
return false;
}
}
</script>
<!-- Authors -->
<form name="form1" method="post" action="" onsubmit="return validateAuthorsForm(this)">
<input type="hidden" value="author" name="operation"/>
<table cellpadding="4" border="0" cellspacing="0" width="100%">
<tr>
<td width="100" align="right">Authors:</td>
<td width="300">
<table>
<tr><td><input class="myForm" name="author1" type="text" id="author1" size="40"/></td></tr>
<tr><td><input class="myForm" name="author2" type="text" id="author2" size="40"/></td></tr>
<tr><td><input class="myForm" name="author3" type="text" id="author3" size="40"/></td></tr>
</table>
<input type="hidden" value="" id="term" name="term"/> </td>
<td><input class="myForm" type="submit" name="Submit" value="Search"/></td>
</tr>
</table>
</form>
<hr noshade="noshade" />
<!-- Keywords -->
<form name="form1" method="post" action="" onsubmit="return validateKeywordsForm(this)">
<table cellpadding="4" border="0" cellspacing="0" width="100%">
<tr>
<td width="100" align="right">Keywords:</td>
<td width="300">
<select class="myForm" name="operation">
<option value="title" selected="selected">Title</option>
<option value="abstract">Abstract</option>
<option value="title_abstract">Title & abstract</option>
</select>
<p/>
<input class="myForm" name="term" type="text" id="term" size="40"/></td>
<td><input class="myForm" type="submit" name="Submit" value="Search"/></td>
</tr>
</table>
</form>
<hr noshade="noshade" />
<!-- DOI -->
<form name="form1" method="post" action="" onsubmit="return validateDOIForm(this)">
<input type="hidden" value="doi" name="operation"/>
<table cellpadding="4" border="0" cellspacing="0" width="100%">
<tr>
<td width="100" align="right">DOI:</td>
<td width="300"><input class="myForm" name="term" type="text" id="term" size="10"/></td>
<td><input class="myForm" type="submit" name="Submit" value="Search"/></td>
</tr>
</table>
</form>
<!-- PubMed -->
<hr noshade="noshade" />
<form name="form1" method="post" action="" onsubmit="return validatePubMedForm(this)">
<input type="hidden" value="pmid" name="operation"/>
<table cellpadding="4" border="0" cellspacing="0" width="100%">
<tr>
<td width="100" align="right">PubMed ID:</td>
<td width="300"><input class="myForm" name="term" type="text" id="term" size="10"/></td>
<td><input class="myForm" type="submit" name="Submit" value="Search"/></td>
</tr>
</table>
</form>
<?php
}
else
{
// User has submitted a form
echo "<p>", $_POST['term'], $_POST['operation'], "</p>";
$r = new ReferenceManager();
$count = 0;
$search_id = $r->Search($_POST['term'], $_POST['operation'], $count);
// Display search results
echo "<p>Search had ", $count, "hits.</p>";
// For now dump ids
//foreach($reference_ids as $key=>$value)
//{
// echo $value, "<br/>";
//}
if ($count > 0)
{
//echo $count;
echo "<script language=\"JavaScript\">document.location=\"bib_search_display.php?search_id=$search_id&page=1\";</script>";
}
}
?>
</div>
<?php include ('footer.inc.php'); ?>
</body>
</html>