<?
//This function sets the proper refdbc command depending
//on the field that you're searching for
function selectField($kajqueryfield)
{
	$get = "";
	switch($kajqueryfield)
	{
		case "keyword":
			$get = "getkw";
			break;
		case "author":
			$get = "getau";
			break;
		case "editor":
			$get = "geted";
			break;
		case "seditor":
			$get = "getas";
			break;
		case "journalfull":
			$get = "getjf";
			break;
		case "journalabbrev":
			$get = "getjo";
			break;
		case "journalabbrev1":
			$get = "getj1";
			break;
		case "journalabbrev2":
			$get = "getj2";
			break;
	}
	return $get;
}
?>

<!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>RefDB database query form</title>
    <link href="refdbqxhtml.css" type="text/css" rel="stylesheet"/>
    </head>
    <body>
        <h1>RefDB database query form</h1>
        <div class="navigation">
            <h2>Navigation</h2>
            <ul class="navigationMenu">
                <li>
                    <a href="index.html">Login screen</a>
                </li>
                <li>
                    <a href="refdbquery.html">Search references</a>
                </li>
                <li>
                    <a href="refdbkajquery.html">Search keywords, authors, journals</a>
                </li>
                <li>
                    <a href="refdbadd.html">Add new references</a>
                </li>
                <li>
                    <a href="refdbdbquery.php">Change database</a>
                </li>
                <li>
                    <a href="external.php">Search external database</a>
                </li>
                <li>
                    <a href="refdbadmin.php">Administrative Interface</a>
                </li>
                <li>
                    <a href="refdblogout.php">Logout</a>
                </li>
            </ul>
        </div>
        <div class="content">
	     <?
	     	$name = $_SESSION["name"];
		$passwd = $_SESSION["passwd"];
		$database = $_SESSION["database"];
		$refdbc = $_SESSION["refdbc"];

		//build the command
		$cmd = "$refdbc -u $name -w $passwd -d $database -c stdout -C ";
		
		$get = 	selectField($kajqueryfield);

		//kajquery is the search term
		$cmd = $cmd.$get." ".$kajquery;
	     
	     ?>	     	
	      <h2>Results</h2>
                    <h3>Matching <?$kajqueryfield?>(s)</h3>
	     <?
		exec($cmd, $lines);
		foreach($lines as $line)
		{
			print "<p class='result'>$line</p>\n";
		}
	     ?>
	     </div>
	     <div class="footer">
            <p><a href="http://refdb.sourceforge.net">RefDB</a> reference manager and bibliography
                tool V. <!--VERSION-->0.9.8-1<!--/VERSION--></p>
        </div>
  </body>
</html>
