--- rat/lonpageflip.pm 2006/03/06 23:35:43 1.65 +++ rat/lonpageflip.pm 2006/03/06 23:41:07 1.66 @@ -2,7 +2,7 @@ # # Page flip handler # -# $Id: lonpageflip.pm,v 1.65 2006/03/06 23:35:43 www Exp $ +# $Id: lonpageflip.pm,v 1.66 2006/03/06 23:41:07 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -84,6 +84,28 @@ sub hash_src { return ($hash{'src_'.$id},$symb); } +# Inputs are a url, adn a hash ref of +# form name => value pairs +# takes care of properly adding the form name elements and values to the +# the url doing proper escaping of the values and joining with ? or & as +# needed + +sub add_get_param { + my ($url,$form_data) = @_; + my $needs_question_mark = ($url !~ /\?/); + + while (my ($name,$value) = each(%$form_data)) { + if ($needs_question_mark) { + $url.='?'; + $needs_question_mark = 0; + } else { + $url.='&'; + } + $url.=$name.'='.&Apache::lonnet::escape($form_data->{$name}); + } + return $url; +} + sub move { my ($rid,$mapurl,$direction)=@_; my $startoutrid=$rid; @@ -399,7 +421,7 @@ sub handler { &Apache::loncommon::content_type($r,'text/html'); my $url='http://'.$ENV{'HTTP_HOST'}.$redirecturl; - if ($redirectsymb ne '') { $url.=($url=~/\?/?'&':'?').'symb='.&Apache::lonnet::escape($redirectsymb); } + $url = &add_get_param($url, { 'symb' => $redirectsymb}); $r->header_out(Location => $url); return REDIRECT; } else { @@ -433,8 +455,10 @@ ENDSTART foreach my $id (@possibilities) { $r->print( ''. + &add_get_param($multichoicehash{'src_'.$id}, + {'symb' => + $multichoicehash{'symb_'.$id}, + }).'">'. $multichoicehash{'title_'.$id}. ''.$multichoicehash{'type_'.$id}. '');