--- loncom/interface/lonindexer.pm 2004/06/17 20:43:04 1.114 +++ loncom/interface/lonindexer.pm 2005/02/17 08:50:20 1.130 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Directory Indexer # -# $Id: lonindexer.pm,v 1.114 2004/06/17 20:43:04 www Exp $ +# $Id: lonindexer.pm,v 1.130 2005/02/17 08:50:20 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -60,6 +60,7 @@ 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. @@ -72,6 +73,8 @@ my @Only = (); my @Omit = (); + + # ----------------------------- Handling routine called via Apache and mod_perl sub handler { my $r = shift; @@ -133,24 +136,31 @@ 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'})) { + 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"); $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 @@ -177,7 +187,7 @@ END ' border="0" />'; $colspan=" colspan='2' "; my $cl=&mt('Close'); - my $gi=&mt('Group Import'); + my $gi=&mt('Import'); $closebutton=< END @@ -337,11 +347,14 @@ END } # ---------------------------------------------------------------- Print Header + my $html=&Apache::lonxml::xmlbegin(); $r->print(< +$html The LearningOnline Network With CAPA Directory Browser + + ENDJS } @@ -821,7 +854,8 @@ sub display_line { $diropen.'.gif"'); $r->print (' name="'.$msg.'" height="22" type="image" border="0">'. "\n"); - $r->print ('print (' border="0" />'."\n"); $r->print (&mt("Domain")." - $listname "); @@ -848,7 +882,9 @@ sub display_line { '.gif"'); $r->print (' name="'.$msg.'" height="22" type="image" border="0">'. "\n"); - $r->print (''); my $domain=(split(m|/|,$startdir))[2]; @@ -876,16 +912,10 @@ sub display_line { my $iconname = &Apache::loncommon::icon($listname); $r->print(""); - my $metafile = $Apache::lonnet::perlvar{'lonDocRoot'}.$pathprefix. - $filecom[0].'.meta'; - if (-e $metafile) { - $metafile=1; - } else { - $metafile=0; - } if ($ENV{'form.catalogmode'} eq 'interactive') { + my $quotable_filelink = &Apache::loncommon::escape_single($filelink); $r->print(""); + $quotable_filelink,"')\">"); $r->print("". "\n"); $r->print(""); @@ -944,11 +974,14 @@ sub display_line { if ($filelink=~/\.(page|sequence)$/) { $r->print(''); } - $r->print (" print (" $listname "); - $r->print (" (print (" (metadata) "); $r->print("\n"); @@ -986,36 +1019,9 @@ sub display_line { $r->print(' '.($lang eq '' ? ' ' : $lang). " \n"); } - if ($hash{'display_attrs_7'} == 1) { - my $output=''; - my $embstyle=&Apache::loncommon::fileembstyle($curfext); - if ($embstyle eq 'ssi') { - my $cache=$Apache::lonnet::perlvar{'lonDocRoot'}.$filelink. - '.tmp'; - if ((!$ENV{'form.updatedisplay'}) && - (-e $cache)) { - open(FH,$cache); - $output=join("\n",); - close(FH); - } else { - $output=&Apache::lonnet::ssi_body($filelink); - open(FH,">$cache"); - print FH $output; - close(FH); - } - $output=''.$output.''; - } elsif ($embstyle eq 'img') { - $output=''; - } elsif ($filelink=~/^\/res\/(\w+)\/(\w+)\//) { - $output=''; - } - $r->print(' '.($output eq '' ? ' ':$output). - " \n"); - } if ($hash{'display_attrs_8'} == 1) { # statistics + &dynmetaread($filelink); $r->print(""); &dynmetaprint($r,$filelink,'count'); &dynmetaprint($r,$filelink,'course'); @@ -1034,8 +1040,10 @@ sub display_line { if ($hash{'display_attrs_10'} == 1) { my $source = &Apache::lonnet::metadata($filelink,'sourceavail'); if($source eq 'open') { - my $sourcelink = &Apache::lonsource::make_link($filelink); - $r->print(''."print(''."Yes "."\n"); } else { #A cuddled else. :P @@ -1044,6 +1052,7 @@ sub display_line { } if ($hash{'display_attrs_11'} == 1) { # links + &dynmetaread($filelink); $r->print(''); &dynmetaprint($r,$filelink,'goto_list'); &dynmetaprint($r,$filelink,'comefrom_list'); @@ -1051,6 +1060,35 @@ sub display_line { &dynmetaprint($r,$filelink,'dependencies'); $r->print(''); } + if ($hash{'display_attrs_7'} == 1) { +# Show resource + my $output=''; + my $embstyle=&Apache::loncommon::fileembstyle($curfext); + if ($embstyle eq 'ssi') { + my $cache=$Apache::lonnet::perlvar{'lonDocRoot'}.$filelink. + '.tmp'; + if ((!$ENV{'form.updatedisplay'}) && + (-e $cache)) { + open(FH,$cache); + $output=join("\n",); + close(FH); + } else { + $output=&Apache::lonnet::ssi_body($filelink); + open(FH,">$cache"); + print FH $output; + close(FH); + } + $output=''.$output.''; + } elsif ($embstyle eq 'img') { + $output=''; + } elsif ($filelink=~/^\/res\/(\w+)\/(\w+)\//) { + $output=''; + } + $r->print(' '.($output eq '' ? ' ':$output). + " \n"); + } $r->print("\n"); } @@ -1082,7 +1120,9 @@ sub display_line { 'folder_pointer_'.$diropen.'.gif"'); $r->print (' name="'.$msg.'" height="22" type="image" border="0">'. "\n"); - $r->print (''. "\n"); $r->print ("$listname\n"); @@ -1121,18 +1161,18 @@ sub display_line { $r->print(' '.($lang eq '' ? ' ' : $lang). " \n"); } - if ($hash{'display_attrs_7'} == 1) { - $r->print(' '); - } if ($hash{'display_attrs_8'} == 1) { $r->print(' '); } - if ($hash{'display_attrs_10'} == 1) { + if ($hash{'display_attrs_10'} == 1) { $r->print(' '); } if ($hash{'display_attrs_11'} == 1) { $r->print(' '); } + if ($hash{'display_attrs_7'} == 1) { + $r->print(' '); + } $r->print(''); } @@ -1200,6 +1240,10 @@ sub cleanup { } } + + + + =head1 NAME Apache::lonindexer - mod_perl module for cross server filesystem browsing