<?
# Netlogo Publication Script
# http://bcrc.bio.umass.edu/netlogo/index.phps

# (c) 2004 Steven Brewer; Biology Computer Resource Center
# Free Software under the Creative Commons Attribution License:
# http://creativecommons.org/licenses/by/2.0/

# Set the title, which should match the file name of the this file as well 
# as the nlogo and html files all in the same directory

$title="lac_operon";

# If you want to have the simulation load when you visit a directory URL,
# add "index.php" to the DirectoryIndex directive in httpd.conf and then
# create a symbolic link to this file from index.php, e.g.
#   ln -s lac_operon.php index.php

# You may need to adjust where the file looks for the netlogoLite.jar files

# this routine parses the html file, grabbing the line with the 
# dimensions of the applet and truncating the top;
$fp fopen ("${title}.html""r");
  
$line=0;
  while (!
feof ($fp)) {
    
$buffer fgets($fp4096);
    if(
preg_match("/^\s+width=.*/",$buffer,$matches)) {
      
$width $buffer;
    }
    if(
$line>58) {
      
$rest .= $buffer;
    }
  
$line++;
  }

?>
<html>
<head>
<title><? echo $title?></title>
</head>
<body>

<h2><? echo $title?></h2>
<p><form action="<? echo $title?>.php">Use Netlogo 1.3: 
<?
# We present a form that let's people select which Netlogo engine to use
if ($old) {
echo 
"<input type=checkbox name=old checked>\n";
}
else {
  echo 
"<input type=checkbox name=old >\n";
}
?>
<input type=submit value="Go!"></form>

<p>
<?
if($old) {
?>
<p>
<applet code="nLogo.window.Applet"
        archive="../../NetLogoLite-1.3.jar"
<? echo $width?>
  <param name="DefaultModel"
         value="<? echo $title?>.nlogo">
  <param name="ShowOutput"
         value="true">
</applet>
<?
}
else {
?>
<applet code="org.nlogo.window.Applet"
        archive="../../NetLogoLite.jar"
<? echo $width?>
  <param name="DefaultModel"
         value="<? echo $title?>.nlogo">
  <param name="ShowOutput"
         value="false">
</applet>
<?
}
?>
</p>
<p>created with
<a target="_blank" href="http://ccl.northwestern.edu/netlogo/">NetLogo</a></p>

<p>view/download model file:
<a href="<? echo $title?>.nlogo"><? echo $title?>.nlogo</a>
</p>

<?
echo $rest;
 
?>