<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
            "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- License: public domain.
     Distribution: http://lcr.math.ist.utl.pt/texdoc-php/ 
     Author: Joao P Matos jmatos@math.ist.utl.pt -->
<head>
<title>Sections</title>
<?php
include("css.php");
?>
</head>
<body>
<h3>Sections</h3>
<table>
<?php

include("config.php");

### Changes should make possible to use an arbitrary set of texmf trees

### Detecting the absolute location of this script both 
### in the file system and url space

$ourfs = dirname($_SERVER['SCRIPT_FILENAME']);
$oururl = dirname($_SERVER['PHP_SELF']);

##### Parse the texdoc data files


$numsec=0;
$query = "";
if ( $_SERVER['QUERY_STRING'] <> "" )
{
  $query= "&amp;" . $_SERVER['QUERY_STRING'];
}
while (list( $treekey, $treepath) = each($texmftrees['fs']))
{
  if ($_GET[$treekey] <> "no")
    {
      if ($treekey == "local")
	{
	  $class = " class=\"local\" ";
	}
      else
	{
	  $class = "";
	}
      $texdocdat=$treepath . "texdoctk/" . $texmftrees['datname'][$treekey] ;
      if (file_exists($texdocdat))
	{
	  $row = 0;
	  $handle = fopen ($texdocdat,"r");
	  while ($data[$row] = fgetcsv ($handle, 1000, ";")) 
	    {
	      if ( strpos($data[$row][0],"#") === false )
		{
		  if ( count($data[$row]) == 1 )
		    {
#### Check for repeated section names
#### likely with more than one data file
		      $sectionname = str_replace("@", "", $data[$row][0]);
		      if (! $section or ! in_array($sectionname, $section))
			{
			  $section[$numsec] = $sectionname;
			  echo "<tr><td><a  " . $class . " href=\"items.php?section=" . $section[$numsec] . $query . "\" target=\"items\">" . $section[$numsec] . "</a></td></tr>\n";
			  $numsec=$numsec+1;
			}
		    }
		}
	      $row++;
	    }
	  fclose ($handle);
	}
    }
}

?>
</table>
</body>
</html>