--- loncom/interface/lonindexer.pm 2004/06/16 23:39:01 1.111 +++ loncom/interface/lonindexer.pm 2004/10/20 10:51:50 1.125 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Directory Indexer # -# $Id: lonindexer.pm,v 1.111 2004/06/16 23:39:01 www Exp $ +# $Id: lonindexer.pm,v 1.125 2004/10/20 10:51:50 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -53,7 +53,6 @@ use Apache::lonmeta; use Apache::File; use Apache::lonlocal; use Apache::lonsource(); -use LONCAPA::lonmetadata(); use GDBM_File; # ---------------------------------------- variables used throughout the module @@ -61,7 +60,8 @@ my %hash; # global user-specific gdbm fi my %dirs; # keys are directories, values are the open/close status my %language; # has the reference information present in language.tab my %dynhash; # hash of hashes for dynamic metadata - +my %dynread; # hash of directories already read for dynamic metadata +my %fieldnames; # Metadata fieldnames # ----- Values which are set by the handler subroutine and are accessible to # ----- other methods. my $extrafield; # default extra table cell @@ -73,6 +73,33 @@ my @Only = (); 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 { my $r = shift; @@ -88,6 +115,7 @@ sub handler { # these global to this package? It is just so wrong....) undef (@Only); undef (@Omit); + %fieldnames=&Apache::lonmeta::fieldnames(); # ------------------------------------- read in machine configuration variables my $iconpath= $r->dir_config('lonIconsURL') . "/"; @@ -135,9 +163,10 @@ sub handler { if ($ENV{'form.launch'} eq '2') { $r->content_type('text/html'); my $extra=''; - if (defined($ENV{'form.titleelement'})) { + if (defined($ENV{'form.titleelement'}) && + $ENV{'form.titleelement'} ne '') { my $verify_title = &Apache::lonnet::gettitle($ENV{'form.acts'}); - &Apache::lonnet::logthis("Hrrm $ENV{'form.acts'} -- $verify_title"); +# &Apache::lonnet::logthis("Hrrm $ENV{'form.acts'} -- $verify_title"); $verify_title=~s/'/\\'/g; $extra='window.opener.document.forms["'.$ENV{'form.form'}.'"].elements["'.$ENV{'form.titleelement'}.'"].value=\''.$verify_title.'\';'; } @@ -145,7 +174,9 @@ sub handler {