--- loncom/interface/lonindexer.pm 2002/01/17 14:10:44 1.34 +++ loncom/interface/lonindexer.pm 2002/03/06 20:28:19 1.35 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Directory Indexer # -# $Id: lonindexer.pm,v 1.34 2002/01/17 14:10:44 harris41 Exp $ +# $Id: lonindexer.pm,v 1.35 2002/03/06 20:28:19 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -106,8 +106,9 @@ 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'}); + #------------------------------------------------------------------- my $closebutton=''; my $groupimportbutton=''; my $colspan=''; @@ -154,12 +155,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("print(""); $r->print("". "\n"); @@ -747,21 +798,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 +814,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 +963,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