--- loncom/interface/lonindexer.pm 2004/10/20 10:51:50 1.125 +++ loncom/interface/lonindexer.pm 2005/03/03 07:53:55 1.132 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Directory Indexer # -# $Id: lonindexer.pm,v 1.125 2004/10/20 10:51:50 foxr Exp $ +# $Id: lonindexer.pm,v 1.132 2005/03/03 07:53:55 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -74,31 +74,6 @@ my @Omit = (); -# -# Escapes strings that may have embedded 's that will be put into -# javascript strings as 'strings'. -# The assumptions are: -# There has been no effort to escape ' with \' -# Any \'s in the string are intended to be there as part of the URL -# and must also be escaped. -# Parameters: -# input - The string to escape. -# Returns: -# The escaped string (' replaced by \' and \ replaced by \\). -# -sub javascript_escape { - my ($input) = @_; - - # I imagine a regexp wizard could combine the two expressions below. - # If you do you might want to comment the result. - - $input =~ s/\\/\\\\/g; # Escape the /'s..(must be first)> - $input =~ s/\'/\\\'/g; # Esacpe the 's.... - - return $input; -} - - # ----------------------------- Handling routine called via Apache and mod_perl sub handler { @@ -161,7 +136,7 @@ sub handler { } #Hijack lonindexer to verify a title and be close down. if ($ENV{'form.launch'} eq '2') { - $r->content_type('text/html'); + &Apache::loncommon::content_type($r,'text/html'); my $extra=''; if (defined($ENV{'form.titleelement'}) && $ENV{'form.titleelement'} ne '') { @@ -170,9 +145,12 @@ sub handler { $verify_title=~s/'/\\'/g; $extra='window.opener.document.forms["'.$ENV{'form.form'}.'"].elements["'.$ENV{'form.titleelement'}.'"].value=\''.$verify_title.'\';'; } + my $html=&Apache::lonxml::xmlbegin(); $r->print(< - - + + + ENDSUBM @@ -199,7 +178,7 @@ ENDSUBM $colspan=" colspan='2' "; my $cl=&mt('Close'); $closebutton=< + END } elsif ($ENV{'form.catalogmode'} eq 'groupimport') { @@ -210,11 +189,11 @@ END my $cl=&mt('Close'); my $gi=&mt('Import'); $closebutton=< + END $groupimportbutton=< +onClick="javascript:select_group()" /> END } # Additions made by Matthew to make the browser a little easier to deal @@ -368,11 +347,14 @@ END } # ---------------------------------------------------------------- Print Header + my $html='';#&Apache::lonxml::xmlbegin(); $r->print(< +$html The LearningOnline Network With CAPA Directory Browser + + ENDJS } @@ -841,12 +824,12 @@ sub display_line { 'enctype="application/x-www-form-urlencoded"'. '>'."\n"); $r->print (''."\n"); - $r->print (''."\n"); + $startdir.'" />'."\n"); + $r->print (''."\n"); $r->print ('print (' name="'.$msg.'" height="22" type="image" border="0">'. + $r->print (' name="'.$msg.'" height="22" type="image" border="0" />'. "\n"); - $r->print(&mt("Up")." $tabtag\n"); + $r->print(&mt("Up")." $tabtag\n"); return OK; } # Do we have permission to look at this? @@ -858,7 +841,7 @@ sub display_line { # display domain if ($filecom[1] eq 'domain') { - $r->print (''."\n") + $r->print (''."\n") if ($ENV{'form.dirPointer'} eq "on"); $r->print("$extrafield"); $r->print(""); @@ -866,12 +849,12 @@ sub display_line { my $anchor = $filecom[0]; $anchor =~ s/\///g; $r->print (''); - $r->print (''); + $r->print (''); $r->print ('print (' name="'.$msg.'" height="22" type="image" border="0">'. + $r->print (' name="'.$msg.'" height="22" type="image" border="0" />'. "\n"); - my $quotable_filecom = &javascript_escape($filecom[0]); + my $quotable_filecom = &Apache::loncommon::escape_single($filecom[0]); $r->print ('print (' border="0" />'."\n"); @@ -880,7 +863,7 @@ sub display_line { $r->print("(".$Apache::lonnet::domaindescription{$listname}. ")"); } - $r->print (" $tabtag\n"); + $r->print (" $tabtag\n"); return OK; # display user directory @@ -894,12 +877,12 @@ sub display_line { &begin_form ($r,$curdir); $r->print (''."\n"); - $r->print (''); + $r->print (''); $r->print ('print (' name="'.$msg.'" height="22" type="image" border="0">'. + $r->print (' name="'.$msg.'" height="22" type="image" border="0" />'. "\n"); - my $quotable_curdir = &javascript_escape($curdir); + my $quotable_curdir = &Apache::loncommon::escape_single($curdir); $r->print ('print ($tabtag.''."\n"); + $r->print (''.$tabtag.''."\n"); return OK; } @@ -927,10 +910,10 @@ sub display_line { } # Set the icon for the file my $iconname = &Apache::loncommon::icon($listname); - $r->print(""); + $r->print(""); if ($ENV{'form.catalogmode'} eq 'interactive') { - my $quotable_filelink = &javascript_escape($filelink); + my $quotable_filelink = &Apache::loncommon::escape_single($filelink); $r->print(""); $r->print("". @@ -944,7 +927,7 @@ sub display_line { if ($hash{'store_'.$filelink}) { $r->print("checked"); } - $r->print(">\n"); + $r->print(" />\n"); $r->print("\n"); $r->print(""); $hash{"pre_${fnum}_link"}=$filelink; @@ -979,10 +962,10 @@ sub display_line { my $curdir = $startdir.$filecom[0].'/'; my $anchor = $curdir; $anchor =~ s/\///g; - $r->print (''); + $r->print (''); $r->print ('print (' name="'.$msg.'" height="22" type="image" border="0">'. + $r->print (' name="'.$msg.'" height="22" type="image" border="0" />'. "\n"); } # Filetype icons @@ -991,7 +974,7 @@ sub display_line { if ($filelink=~/\.(page|sequence)$/) { $r->print(''); } - my $quotable_filelink = &javascript_escape($filelink); + my $quotable_filelink = &Apache::loncommon::escape_single($filelink); $r->print (" print(''."print ("\n") if $rem > 0; } - $r->print (''); + $r->print (''); $r->print ('print (' name="'.$msg.'" height="22" type="image" border="0">'. + $r->print (' name="'.$msg.'" height="22" type="image" border="0" />'. "\n"); - my $quotable_curdir = &javascript_escape($curdir); + my $quotable_curdir = &Apache::loncommon::escape_single($curdir); $r->print (''. @@ -1217,9 +1200,9 @@ sub begin_form { '" onSubmit="return rep_dirpath(\''.$dnum.'\''. ',document.forms.fileattr.acts.value)" '. 'enctype="application/x-www-form-urlencoded">'."\n"); - $r->print (''. + $r->print (''. "\n"); - $r->print (''."\n"); + $r->print (''."\n"); $dnum++; } @@ -1257,6 +1240,10 @@ sub cleanup { } } + + + + =head1 NAME Apache::lonindexer - mod_perl module for cross server filesystem browsing