Location: PHPKode > projects > Taxonomic Search Engine > get.php
<?php

// $Id: get.php,v 1.1.1.1 2005/05/19 10:31:10 rdmpage Exp $

/* This page is displayed in a hidden frame. When user clicks on a row in the other frame
 this page is called, it talks to the remopte database, formats the results, and uses DOM
 to display the result in the other frame */
 
header('Content-Type: text/html; charset=utf-8');

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="portal.css" type="text/css" media="screen" /> 
</head>
<body bgcolor="#eeeeFF">


<script type="text/javascript">
function replaceContent(s)
{
    var newText = parent.topFrame.document.createTextNode
	(" DOM methods are cool, are <i>they not</i>?");
    var content = parent.topFrame.document.getElementById("contentDiv");
    content.innerHTML = s;
}
</script>



<?php

require_once("config.inc.php");
require_once("lib.xml.inc.php");
require("Net/HTTP/Client.php");
require_once("nusoap.php");
require_once("XPath.class.php");
require_once("xslt.php");



include("wrapper.php");
include("itis_wrapper.php");
include("funindex_wrapper.php");
include("ipni_wrapper.php");
include("ubio_wrapper.php");
include("ncbi_wrapper.php");




$lsid = $_GET['lsid'];

$format = $_GET['format'];

if($format == "")
{
		$format = 'html';
}

echo "<h2>$format</h2>";

//echo "<h2>$lsid</h2>";

$parts = explode (":", $lsid);
$authority = $parts[0];
$namespace = $parts[1];
$id = $parts[2];

if (!isset($lsid))
{
	echo "</body></html>";
	exit;
}
	

	
	

//echo $authority, ":", $namespace, ":", $id;

$source;

if ($authority == "itis.usda.gov")
{
		$source = new ITISWrapper;	
}
else if ($authority == "indexfungorum.org")
{
		$source = new FunindexWrapper;
}else if ($authority == "ubio.org")
{
		$source = new uBioWrapper;
}
else if ($authority == "ipni.org")
{
		$source = new IPNIWrapper;
}
else if ($authority == "ncbi.nlm.nih.gov")
{
		$source = new NCBIWrapper;
}

if (!isset($source))
{
		echo "Opps, not implemented yet";
}
else
{

	$xml = 	$source->GetDataForID($id);
	
	//echo $xml;

/*
$s = "";
	
if (1)
{
	$s = "<pre>";
	$s .= $xml;
	$s .= "</pre>";
	// Raw XML
	//$s = "<pre>";
	//$s .= js_string($xml);
	//$s .= "</pre>";
	//echo $s;

//	$s = "<b>Hello</b>";

	//$s = str_replace ("\n", "", $s);
	//$s = str_replace ("\r", "", $s);
	//$s = str_replace ('"', '\"', $s);

	//$s = nl2br($s);
	
	//$s = str_replace ("&amp;", "&", $s);
	//$s = htmlspecialchars ($s, ENT_QUOTES);

//	$s = str_replace("\n", "", $s);
//	$s = str_replace("\r", "", $s);

	
	//$s = str_replace("<", "&lt;", $s);
	//$s = str_replace(">", "&gt;", $s);
	$s = str_replace("\"", "&quot;", $s);
	$s = str_replace("'", "&#039;", $s);

	echo $s;

	
	$s = js_string($s);
*/

// Different display modes

// Possibilities
// Nice report
// Raw XML to debug/understand
// RDF (as preparation for LSID) 

$xslt_file = "";
if ($format == "xml")
{
	// XML nicely formatted using Oliver Becker's XML to HTML verbatim formatter
	$xslt_file = "xsl/xmlverbatim.xsl";
}
else if ($format == "html")
{
	// My HTML report format	
	$xslt_file = "xsl/taxon_html.xsl";

}
		if ($config['sabcmd'] != '')
		{	
			// Transform using external sablot processor
			$xpresult = XSLT_Buffer ($xml, $xslt_file);
			
					if (strpos ( $xpresult,"[code:" ))
					{
						echo $xpresult;
					}
					
					//echo $xpresult;
			
		}
		else
		{
			// Use XSLT extension
			$xslt_processor = xslt_create();
			$xslt = join ("", file($xslt_file));
			$arg_buffer = array("/xml" => $xml, "/xslt" => $xslt);
			$xp = xslt_create() or die ("Could not create XSLT processor");
			if (!($xpresult = xslt_process($xp, "arg:/xml", "arg:/xslt", NULL, $arg_buffer)))
			{
				echo "An error occurred: " . xslt_error($xp) . "(error code " . xslt_errno($xp) . ")";
			}
			xslt_free($xp);
		}
		
				
		//echo $xpresult;
		
		//$s = str_replace ('"', '\"', $xpresult);
		//$s = str_replace ("'", "&#039;", $s);
		//$s = str_replace ('\'', "", $s);
		//$s = str_replace ("\n", "", $s);
		//$s = str_replace ("\r", "", $s);
		
		//$s = nl2br($s);
		
		//echo "$s";
		
		//echo $format;
		
		$form = "<form name=\"form1\" method=\"get\" action=\"get.php\" target=\"mainFrame\">";
		$form .= "<label>Format:</label>";
  		$form .= "<select name=\"format\">";
    	$form .= "<option value=\"xml\"";
    	if ($format == "xml")
    	{
	    		$form .= " selected";
    	}
    	
    	$form .= ">xml</option>";
    	$form .= "<option value=\"html\"";
   		if ($format == "html")
    	{
	    		$form .= " selected";
    	}
     	$form .= ">html</option>";
  		$form .= "</select>";
  		$form .= "<input type=\"submit\" name=\"Submit\" value=\"Go\">";
  		$form .= "<input type=\"hidden\" name=\"lsid\" value=\"$lsid\">";
  		$form .= "<p></p>";

		$s = $form;
		$s .= $xpresult;
		$s .= "</form>";
		
		// Replace single quote with &#039; to avoid breaking JavaScript
		$s = str_replace ("'", "&#039;", $s);
		// Ensure string is on one line
		$s = js_string($s);
		
		echo "<pre>$s</pre>";
		
//		echo "<script type=\"text/javascript\">replaceContent('<div id=\"taxon\">  <i>Apus apus</i></div>');</script>";

		// Display in other frame
		echo "<script type=\"text/javascript\">replaceContent('$s');</script>";

		
?>
		
		

<?php
	
}




?>

</body>
</html>
Return current item: Taxonomic Search Engine