#!/usr/local/bin/perl5
#!/usr/local/bin/perl5 -w
# swap those above lines as needed!

# Purpose: Generate a form that lets the user set more options than are presented at the bottom of each page, then go back to the page they called this form up from

require "cgi-lib-24.pl";

MAIN:
{
  # Read in all the variables set by the form
  &ReadParse(*input);

  # Print the header
  print &PrintHeader;

  # print &HtmlTop ("On-line streetplan advanced options editor");
  $modbod =  &HtmlTop ("On-line streetplan advanced options editor");
  $modbod =~ s/<body/<body bgcolor="#0f8fff"/;
  print $modbod;

  $optionhelp = '../doc/tech/getplan-args.html';

  # $featuretype = $input{'type'};

  $outputmode=$input{'output'};
  $outputmode = 'html' if $outputmode eq '';
  $selected{$outputmode} = " selected";

  $expertise = $input{'ex'};
  if ($expertise eq '')
  {
      $expertise = 0;
  }
  $selexpertise{$expertise} = " selected";

  ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
  @months = ("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
  @days = ("sun","mon","tue","wed","thu","fri","sat");
  $monthnow = $months[$mon];
  $daynow = $days[$wday];
  $hournow = $hour;
  $selmonth{$monthnow} = " selected";
  $selday{$daynow} = " selected";
  $selhour{$hournow} = " selected";

  if ($input{'parts'} eq 'head')
  {
      $selparts{'head'} = " selected";
  } elsif ($input{'parts'} eq 'body')
  {
      $selparts{'body'} = " selected";
  } else {
      $selparts{'all'} = " selected";
  }

  $type = $input{'type'};
  if ($type eq '')
  {
      $type = "road";
  }
  $graphics=' checked' if $input{'graphics'} eq 'on';
  $detail=' checked' if $input{'detail'} eq 'on';
  $debug=' checked' if $input{'debug'} eq 'on';
  $verbose=' checked' if $input{'verbose'} eq 'on';
  $helpful=' checked' if $input{'helpful'} ne 'off';
  $edit=' checked' if $input{'edit'} eq 'on';
  $pictures=' checked' if $input{'pictures'} eq 'on';
  $unvetted=' checked' if $input{'unvetted'} ne 'off';
  $hide_unvetted=' checked' if $input{'hide_unvetted'} eq 'on';
  $hide_edit=' checked' if $input{'hide_edit'} eq 'on';
  $all_edit_links=' checked' if $input{'all_edit_links'} eq 'on';
  # $=' checked' if $input{''} eq 'on';

  print <<ENDOFTEXT;

<form action="getplan.cgi" METHOD="GET">

<input type="hidden" name="name" value="$input{'name'}">
<input type="hidden" name="type" value="$type">

<ul>
  <li> Output mode:
       <select name="output">
	 <option value="html-pre"$selected{'html-pre'}>preformatted html (ASCII graphics)
	 <option value="html"$selected{'html'}>HTML
	 <option value="vrml"$selected{'vrml'}>VRML
	 <option value="parsed"$selected{'parsed'}>parsed attribute data (for debug)
	 <option value="grid"$selected{'grid'}>grid listing (for debug)
	 <option value="raw"$selected{'raw'}>raw attribute data (for debug)
	 <option value="data"$selected{'data'}>merged attribute data (for other programs)
       </select>
  <li> <a href="$optionhelp#graphics">Graphics</a> (html only): <input type="checkbox" name="graphics"$graphics> -- these are the little standard pictures from the database
  <li> <a href="$optionhelp#detail">Detail</a>: <input type="checkbox" name="detail"$detail>
  <li> <a href="$optionhelp#verbose">Verbose</a>: <input type="checkbox" name="verbose"$verbose>
  <li> <a href="$optionhelp#helpful">Helpful</a>: <input type="checkbox" name="helpful"$helpful>
  <li> <a href="$optionhelp#debug">Debug</a>: <input type="checkbox" name="debug"$debug>
  <li> <a href="$optionhelp#edit">Edit</a>: <input type="checkbox" name="edit"$edit>
  <li> <a href="$optionhelp#pictures">Pictures</a>: <input type="checkbox" name="pictures"$pictures> -- these are the individual pictures from web sites
  <li> Include <a href="$optionhelp#unvetted">unvetted</a> entries: <input type="checkbox" name="unvetted"$unvetted>
  <li> <a href="$optionhelp#hide_unvetted">Hide</a> unvetted link: <input type="checkbox" name="hide_unvetted"$hide_unvetted>
  <li> <a href="$optionhelp#hide_edit">Hide</a> edit links: <input type="checkbox" name="hide_edit"$hide_edit>
  <li> <a href="$optionhelp#all_edit_links">Always</a> show edit links: <input type="checkbox" name="all_edit_links"$all_edit_links>
  <li> Part of page:
       <select name="parts">
         <option value="all"$selparts{'all'}>all
         <option value="head"$selparts{'head'}>head
         <option value="body"$selparts{'body'}>body
       </select>
  <li> Date:
    <ul>
      <li> <a href="$optionhelp#month">Month</a>:
           <select name="month">
             <option value="jan"$selmonth{'jan'}>January
             <option value="feb"$selmonth{'feb'}>February
             <option value="mar"$selmonth{'mar'}>March
             <option value="apr"$selmonth{'apr'}>April
             <option value="may"$selmonth{'may'}>May
             <option value="jun"$selmonth{'jun'}>June
             <option value="jul"$selmonth{'jul'}>July
             <option value="aug"$selmonth{'aug'}>August
             <option value="sep"$selmonth{'sep'}>September
             <option value="oct"$selmonth{'oct'}>October
             <option value="nov"$selmonth{'nov'}>November
             <option value="dec"$selmonth{'dec'}>December
           </select>
      <li> <a href="$optionhelp#day">Day</a>:
           <select name="day">
             <option value="sun"$selday{'sun'}>Sunday
             <option value="mon"$selday{'mon'}>Monday
             <option value="tue"$selday{'tue'}>Tuesday
             <option value="wed"$selday{'wed'}>Wednesday
             <option value="thu"$selday{'thu'}>Thursday
             <option value="fri"$selday{'fri'}>Friday
             <option value="sat"$selday{'sat'}>Saturday
           </select>
      <li> <a href="$optionhelp#hour">Hour</a>:
           <select name="hour">
             <option value="0"$selhour{0}>midnight
             <option value="1"$selhour{1}>1
             <option value="2"$selhour{2}>2
             <option value="3"$selhour{3}>3
             <option value="4"$selhour{4}>4
             <option value="5"$selhour{5}>5
             <option value="6"$selhour{6}>6
             <option value="7"$selhour{7}>7
             <option value="8"$selhour{8}>8
             <option value="9"$selhour{9}>9
             <option value="10"$selhour{10}>10
             <option value="11"$selhour{11}>11
             <option value="12"$selhour{12}>noon
             <option value="12"$selhour{12}>12
             <option value="13"$selhour{13}>13
             <option value="14"$selhour{14}>14
             <option value="15"$selhour{15}>15
             <option value="16"$selhour{16}>16
             <option value="17"$selhour{17}>17
             <option value="18"$selhour{18}>18
             <option value="19"$selhour{19}>19
             <option value="20"$selhour{20}>20
             <option value="21"$selhour{21}>21
             <option value="22"$selhour{22}>22
             <option value="23"$selhour{23}>23
           </select>
    </ul>
	<li> <a href="$optionhelp#ex"}Expertise level</a>:
             <select name="ex">
	       <option value="0"$selexpertise{0}>Aspirant
	       <option value="1"$selexpertise{1}>Novice
	       <option value="2"$selexpertise{2}>Professed
	       <option value="3"$selexpertise{3}>Abbot
	       <option value="4"$selexpertise{4}>Hermit
	       <option value="5"$selexpertise{5}>Recluse
             </select>
</ul>

<p><a href="$optionhelp#extra">Extra</a> field: <input type="text" name="extra" value="$input{'extra'}"></p>

<p> <input type="submit" value="Return to viewing $input{'name'}"></p>

</form>

<hr>

<h2><a href="$optionhelp#special">Special</a> views</h2>

<form action="getplan.cgi" METHOD="GET">

<input type="hidden" name="name" value="$input{'name'}">
<input type="hidden" name="type" value="$input{'type'}">
<input type="hidden" name="special" value="&lt;pre&gt;\{haiku\}&lt;/pre&gt;">
<input type="hidden" name="special_page_start" value="&lt;p&gt;Before we read the possible haiku, here may be a prose description:\{description\}&lt;p&gt;&lt;h2&gt;Haiku&lt;/h2&gt;">
<input type="hidden" name="special_page_end" value="&lt;hr&gt;&lt;hr&gt;">

<p> <input type="submit" value="View $input{'name'} as haiku"></p>

</form>

ENDOFTEXT



  print "\n<hr>\n<a href=\"http://www.cb1.com/cb1/\"><img align=\"right\" alt=\"CB1 home\" src=\"../../www/small-CB1-home.gif\"></a>\n";

  # Close the document cleanly.
  print &HtmlBot;
}
