                                                                                                
<?php
//-->-->-->-->-->-->-->-->-->-->-->-->-->-->

   include "/home/waggacwc/public_html/refurb/RETRO-GLOBALS.php";

   include "$LIBRARYPATH/fnHtmlFileSelect.php";
   include_once "$LIBRARYPATH/fnDirectoryListing.php";
   include_once "$LIBRARYPATH/fnFillWebTemplate.php";
   include_once "$LIBRARYPATH/fnMessageToHtml.php";
   include_once "$LIBRARYPATH/fnHyperlinkPlainText.php";

   $sFilePath = $_REQUEST['file'];
   $sFilePath = str_replace('\\', '/', $sFilePath);
   $sFilePath = preg_replace('#[/]+#', '/', $sFilePath);
   $sFilePathEncoded = htmlspecialchars($sFilePath);
   $sFilePathUrlEncoded = htmlspecialchars(urlencode($sFilePath));

   if (preg_match("/\./", $sFilePath))
   {
     $sConfigurationFilePath = 
       preg_replace("/\.[^\.]*$/", ".conf", $sFilePath);
   }
   else
   {
     $sConfigurationFilePath = $sFilePath.".conf";
   }

   $sConfigurationFilePathEncoded = 
      htmlspecialchars($sConfigurationFilePath);

   $sDocumentTemplateFileName = "";

   if (file_exists($sDocumentConfigFilePath))
   {
     $aaDocumentSettings = parse_ini_file($sDocumentConfigFilePath);
     $sDocumentTemplatePath = $aaDocumentSettings['document-template-path'];
     $sDocumentTemplatePath = trim($sDocumentTemplatePath);

     $sDocumentTemplateFileName = 
       basename($sDocumentTemplateFilePath);
     $sDocumentTocLocation = $aaDocumentSettings['table-of-contents-location'];
   }

   $aaTextLines = file($ADMINTEMPLATE);
   $sAdminTemplateContents = implode('', $aaTextLines);

   $sPageContent = "
              = Document Configuration
            
       Document: $sFilePathEncoded
   
       You can use this page to configure the way the document appears
       when it is published as a web-page. For example you can choose
       the HTML template into which the document will be inserted.

     ";

    $sPageContent = fnMessageToHtml($sPageContent);

    $sPageContent = $sPageContent."
    <form action = 'configure-document.php' 
          method = 'get'>
    <br>
    <em>Select a template for the document (from the templates folder)</em>
    <br> ".
    fnHtmlFileSelect($TEMPLATEPATH, 'template-file', $sDocumentTemplatePath).
    "<br>
    <input   type = 'submit'  value = 'Update these settings'>
    <input   type = 'hidden'  name = 'file'  value = '$sFilePathEncoded'>
    </form>
    ";

    $sPage = fnFillWebTemplate(
      $sAdminTemplateContents, $sPageContent, $sPageTitle);   
    echo $sPage;

//--<--<--<--<--<--<--<--<--<--<--<--<--<--<
?>



                                                                                                