#!/usr/local/bin/perl5.001
############################################################################
#                                                                          #
# The contents of this file are subject to the WebStone Public License     #
# Version 1.0 (the "License"); you may not use this file except in         #
# compliance with the License. You may obtain a copy of the License        #
# at http://www.mindcraft.com/webstone/license10.html                      #
#                                                                          #
# Software distributed under the License is distributed on an "AS IS"      #
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See      #
# the License for the specific language governing rights and limitations   #
# under the License.                                                       #
#                                                                          #
# The Original Code is WebStone 2.5.                                       #
#                                                                          #
# The Initial Developer of the Original Code is Silicon Graphics, Inc.     #
# and Mindcraft, Inc.. Portions created by Silicon Graphics. and           #
# Mindcraft. are Copyright (C) 1995#1998 Silicon Graphics, Inc. and        #
# Mindcraft, Inc. All Rights Reserved.                                     #
#                                                                          #
# Contributor(s): ______________________________________.                  #
#                                                                          #
############################################################################

# @(#) WebStone-filelist.wpl 2.6@(#)

push(@INC, "$wd/bin");
require('WebStone-common.pl');

@keylist = ();

html_begin("Chose a URL List");

&getconfig();

print CLIENT <<EOF
<FORM METHOD="POST" ACTION="$wd/bin/move-filelist.wpl">
<H2>Choose a URL List (Web site model)</H2>
<P>
<FONT SIZE=+1>
Current URL List:
</FONT>
<UL>
EOF
;

&show_model();

print CLIENT <<EOF
</UL>
<P>
<FONT SIZE=+1>
Click on the file name to see the URLs and weights.
</FONT>
<DL>
EOF
    ;

for $key (sort(keys %filelist)) {
    next if ( $key eq "filelist.bak" || $key eq "filelist");
    print CLIENT "<DD><INPUT TYPE=RADIO NAME=filelist ";
    if ("$filelist{$key}" eq "$filelist{\"filelist\"}") {
	print CLIENT " CHECKED ";
    }
    print CLIENT <<EOF
 VALUE="$wd/conf/$key">
<A HREF="$wd/conf/$key">$key</A>: $filelist{$key}
EOF
}

print CLIENT <<EOF
</DL>
<B>
<FONT SIZE=+1>
<INPUT TYPE="SUBMIT" VALUE="Write conf/filelist">
</FONT>
</B>

EOF
    ;

html_end();

# End of main program

sub getconfig {
    opendir(CONF, "$wd/conf") || die "open $wd/conf: $!";
    %filelist = "";
    foreach $file (sort readdir(CONF)) {
	if ( $file =~ /^filelist.*/ ) {
	    $headtext = &my_head("$wd/conf/$file");
	    $headtext =~ s/\#//;
	    ( $headtext ) = split(':', $headtext);
	    $filelist{$file} = $headtext;
	}
    }
    closedir(CONF);
}

# end
