--- loncom/interface/lonindexer.pm 2001/12/13 13:59:22 1.30 +++ loncom/interface/lonindexer.pm 2002/03/06 22:01:06 1.36 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Directory Indexer # -# $Id: lonindexer.pm,v 1.30 2001/12/13 13:59:22 harris41 Exp $ +# $Id: lonindexer.pm,v 1.36 2002/03/06 22:01:06 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -41,6 +41,8 @@ # 8/28,10/15,11/28,11/29 Scott Harrison # 11/30 Matthew Hall # 12/11,12/13 Scott Harrison +# YEAR=2002 +# 1/17 Scott Harrison # ### @@ -78,10 +80,6 @@ my $extrafield; # default extra table ce my $fnum; # file counter my $dnum; # directory counter -# ---------------------------------------------------------------------- BEGIN -sub BEGIN { -} - # ----------------------------- Handling routine called via Apache and mod_perl sub handler { my $r = shift; @@ -108,8 +106,10 @@ sub handler { my $uri=$r->uri; # -------------------------------------- see if called from an interactive mode - &get_unprocessed_cgi(); - + # Get the parameters from the query string + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, + ['catalogmode','launch','acts','mode','form','element']); + #------------------------------------------------------------------- my $closebutton=''; my $groupimportbutton=''; my $colspan=''; @@ -156,12 +156,36 @@ END onClick="javascript:select_group()"> END } - + # Additions made by Matthew to make the browser a little easier to deal + # with in the future. + # + # $mode (at this time) indicates if we are in edit mode. + # $form is the name of the form that the URL is placed when the + # selection is made. + # $element is the name of the element in $formname which receives + # the URL. + &Apache::lonxml::debug('Checking mode, form, element'); + &setvalues(\%hash,'form_mode' ,\%ENV,'form.mode' ); + &setvalues(\%hash,'form_form' ,\%ENV,'form.form' ); + &setvalues(\%hash,'form_element',\%ENV,'form.element'); + + my $mode = $ENV{'form.mode'}; + my ($form,$element); + if ($mode eq 'edit') { + $form = $ENV{'form.form'}; + $element = $ENV{'form.element'}; + } + &Apache::lonxml::debug("mode=$mode form=$form element=$element"); # ------ set catalogmodefunctions to have extra needed javascript functionality my $catalogmodefunctions=''; if ($ENV{'form.catalogmode'} eq 'interactive' or $ENV{'form.catalogmode'} eq 'groupimport') { - $catalogmodefunctions=<print(""); + my $titleesc=$title; + $titleesc=~s/\'/\\'/; #' (clean up this spare quote + $r->print(""); $r->print("". "\n"); $r->print(""); @@ -747,21 +799,12 @@ sub begin_form { $dnum++; } -# ----------- grab unprocessed CGI variables that may have been appended to URL -sub get_unprocessed_cgi { - foreach (split(/&/,$ENV{'QUERY_STRING'})) { - my ($name, $value) = split(/=/,$_); - $value =~ tr/+/ /; - $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; - if ($name eq 'catalogmode' or $name eq 'launch' or $name eq 'acts') { - $ENV{'form.'.$name}=$value; - } - } -} - # --------- settings whenever the user causes the indexer window to be launched sub start_fresh_session { delete $hash{'mode_catalog'}; + delete $hash{'form_mode'}; + delete $hash{'form_form'}; + delete $hash{'form_element'}; foreach (keys %hash) { if ($_ =~ /^pre_/) { delete $hash{$_}; @@ -772,6 +815,19 @@ sub start_fresh_session { } } +# ------------------------------------------------------------------- setvalues +sub setvalues { + # setvalues is used in registerurl to synchronize the database + # hash and environment hashes + my ($H1,$h1key,$H2,$h2key) =@_; + # + if (exists $H2->{$h2key}) { + $H1->{$h1key} = $H2->{$h2key}; + } elsif (exists $H1->{$h1key}) { + $H2->{$h2key} = $H1->{$h1key}; + } +} + 1; =head1 NAME @@ -908,11 +964,6 @@ begin_form - prints the beginning of a f =item * -get_unprocessed_cgi - grab unprocessed CGI variables that may have been -appended to URL - -=item * - start_fresh_session - settings whenever the user causes the indexer window to be launched