Changeset 24926


Ignore:
Timestamp:
01/09/12 11:27:26 (9 years ago)
Author:
davidb
Message:

shifted generation of the initial HTML form into a subroutine

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/html-to-expeditee/trunk/src/src/cgi-bin/html-to-expeditee.pl.in

    r24924 r24926  
    3030
    3131
    32 sub main
     32sub generate_html_form
    3333{
    34 
    35 #    $ENV{'QUERY_STRING'} = "a=set-import-metadata&c=espresso-music&d=HASH012d6f72cde5dc48162f4a1d.1&metaname=annotation&metapos=0&metavalue=adfadfad";
    36 #    $ENV{'QUERYSTRING'} = "a=set-import-metadata&c=espresso-music&d=HASH012d6f72cde5dc48162f4a1d.1&metaname=annotation&metapos=0&metavalue=adfadfad";
    37 #    $ENV{'REQUEST_METHOD'} = "GET";
    38 
    39 
    40     my $gsdl_cgi = new gsdlCGI();
    41 
    42     # Load the Greenstone modules that we need to use
    43     $gsdl_cgi->setup_gsdl();
    44 
    45     my $gsdlhome = $ENV{'GSDLHOME'};   
    46     $gsdl_cgi->checked_chdir($gsdlhome);
    47 
    48     require cgiactions::HtmlToExpediteeAction;
    49    
    50     # Useful debug statement for seeing what packages have been included
    51 ####    printf("%-45s%-s\n",$_,$INC{$_}) foreach (sort keys %INC);
    52    
    53     $gsdl_cgi->parse_cgi_args();
    54 
    55     # We don't want the gsdlCGI module to return errors and warnings in XML
    56     $gsdl_cgi->{'xml'} = 0;
    57 
    58     my $collect = $gsdl_cgi->clean_param("c");   
    59     my $cl = $gsdl_cgi->clean_param("cl");   
    60 
    61     # Establish collect_dir using defining 'site' along the way if GS3
    62 
    63     my $site = undef;
    64     my $isGSDL2 = undef;
    65 
    66     if ($gsdl_cgi->greenstone_version() == 2) {
    67         $isGSDL2 = 1;
    68     }
    69     else {
    70         $isGSDL2 = 0;
    71 
    72     # GS3 (and possible future versions) make use of 'site'
    73     $site = $gsdl_cgi->clean_param("site");   
    74     if (!defined $site) {
    75         $gsdl_cgi->generate_error("No site specified.");
    76     }
    77     }
    78 
    79     my $fn = $gsdl_cgi->clean_param("fn");     # frame number
    80 
    81     if (defined $fn) {
    82 
    83     my $action = new HtmlToExpediteeAction($gsdl_cgi,$iis6_mode);
    84 
    85     $action->do_action();
    86 
    87 
    88     }
    89     else {
    90    
    91     my $html_form = <<EOT;
     34    my ($isGSDL2,$site,$collect,$cl) = @_;
     35
     36    my $html_form = <<EOT;
    9237<html>
    9338  <head>
     
    325270EOT
    326271
    327 
    328         print "Content-type:text/html\n\n";
    329         print $html_form;
    330 
     272    print "Content-type:text/html\n\n";
     273    print $html_form;
     274}
     275
     276sub main
     277{
     278
     279#    $ENV{'QUERY_STRING'} = "a=set-import-metadata&c=espresso-music&d=HASH012d6f72cde5dc48162f4a1d.1&metaname=annotation&metapos=0&metavalue=adfadfad";
     280#    $ENV{'QUERYSTRING'} = "a=set-import-metadata&c=espresso-music&d=HASH012d6f72cde5dc48162f4a1d.1&metaname=annotation&metapos=0&metavalue=adfadfad";
     281#    $ENV{'REQUEST_METHOD'} = "GET";
     282
     283
     284    my $gsdl_cgi = new gsdlCGI();
     285
     286    # Load the Greenstone modules that we need to use
     287    $gsdl_cgi->setup_gsdl();
     288
     289    my $gsdlhome = $ENV{'GSDLHOME'};   
     290    $gsdl_cgi->checked_chdir($gsdlhome);
     291
     292    require cgiactions::HtmlToExpediteeAction;
     293   
     294    # Useful debug statement for seeing what packages have been included
     295####    printf("%-45s%-s\n",$_,$INC{$_}) foreach (sort keys %INC);
     296   
     297    $gsdl_cgi->parse_cgi_args();
     298
     299    # We don't want the gsdlCGI module to return errors and warnings in XML
     300    $gsdl_cgi->{'xml'} = 0;
     301
     302    my $fn = $gsdl_cgi->clean_param("fn");     # frame number
     303
     304    if (defined $fn) {
     305
     306    my $action = new HtmlToExpediteeAction($gsdl_cgi,$iis6_mode);
     307
     308    $action->do_action();
     309
     310    }
     311    else {
     312    # generate form, pre-filled out with any useful values such
     313    # as the collection and classifier value
     314
     315    my $collect = $gsdl_cgi->clean_param("c");   
     316    my $cl = $gsdl_cgi->clean_param("cl");   
     317
     318    # Establish collect_dir using defining 'site' along the way if GS3
     319
     320    my $site = undef;
     321    my $isGSDL2 = undef;
     322
     323    if ($gsdl_cgi->greenstone_version() == 2) {
     324        $isGSDL2 = 1;
     325    }
     326    else {
     327        $isGSDL2 = 0;
     328       
     329        # GS3 (and possible future versions) make use of 'site'
     330        $site = $gsdl_cgi->clean_param("site");   
     331        if (!defined $site) {
     332        $gsdl_cgi->generate_error("No site specified.");
     333        }
     334    }
     335
     336    generate_html_form($isGSDL2,$site,$collect,$cl);
    331337    }
    332338}
Note: See TracChangeset for help on using the changeset viewer.