--- loncom/interface/lonindexer.pm 2005/06/17 20:15:51 1.135 +++ loncom/interface/lonindexer.pm 2006/05/31 16:22:10 1.143 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Directory Indexer # -# $Id: lonindexer.pm,v 1.135 2005/06/17 20:15:51 www Exp $ +# $Id: lonindexer.pm,v 1.143 2006/05/31 16:22:10 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -116,7 +116,7 @@ sub handler { my $closebutton=''; my $groupimportbutton=''; my $colspan=''; - + $extrafield=''; my $diropendb = "/home/httpd/perl/tmp/$env{'user.domain'}_$env{'user.name'}_indexer.db"; @@ -133,7 +133,7 @@ sub handler { { if ($env{'form.launch'} eq '1') { &start_fresh_session(); - } + } #Hijack lonindexer to verify a title and be close down. if ($env{'form.launch'} eq '2') { &Apache::loncommon::content_type($r,'text/html'); @@ -145,11 +145,7 @@ 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(< - + my $js = < function load() { window.opener.document.forms["$env{'form.form'}"] @@ -159,11 +155,13 @@ sub handler { window.close(); } - - - - ENDSUBM + $r->print(&Apache::loncommon::start_page(undef,$js, + {'only_body' =>1, + 'add_entries' => + {'onload' => "load();"},} + ). + &Apache::loncommon::end_page()); return OK; } @@ -347,14 +345,7 @@ END } # ---------------------------------------------------------------- Print Header - my $html='';#&Apache::lonxml::xmlbegin(); - $r->print(< -The LearningOnline Network With CAPA Directory Browser - - - + my $js = <<"ENDHEADER"; - - ENDHEADER -my ($headerdom)=($uri=~/^\/res\/(\w+)\//); -$r->print(&Apache::loncommon::bodytag('Browse Resources',undef,undef,undef, - $headerdom)); + + my ($headerdom)=($uri=~/^\/res\/(\w+)\//); + $r->print(&Apache::loncommon::start_page('Browse Resources',$js, + {'domain' => $headerdom,})); # - Evaluate actions from previous page (both cumulatively and chronologically) if ($env{'form.catalogmode'} eq 'groupimport') { my $acts=$env{'form.acts'}; @@ -598,7 +588,7 @@ END $r->print(''); # --------------------------------------------------- end the output and return - $r->print(''."\n"); + $r->print(&Apache::loncommon::end_page()."\n"); } if(! $c->aborted()) { # write back into the temporary file @@ -714,16 +704,19 @@ sub dynmetaread { } # Actually get the data %dynhash= - (%dynhash,&Apache::lonmeta::get_dynamic_metadata_from_sql($uri)); + (%dynhash,&Apache::lonmeta::get_dynamic_metadata_from_sql($uri.'/')); # Remember that we got it $dynread{$uri}=1; } } sub initdebug { - my $html=&Apache::lonxml::xmlbegin(); + my $start_page= + &Apache::loncommon::start_page('Debug',undef, + {'only_body' => 1,}); + $start_page =~ s/\n/ /g; return < + ENDJS } sub writedebug { - my $text = shift; - return ""; + my ($text) = @_; + return ""; } # -------------------- filters out files based on extensions (returns an array) @@ -1057,35 +1050,13 @@ sub display_line { &dynmetaprint($r,$filelink,'comefrom_list'); &dynmetaprint($r,$filelink,'sequsage_list'); &dynmetaprint($r,$filelink,'dependencies'); + &dynmetaprint($r,$filelink,'course_list'); $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). + my $output=&showpreview($filelink); + $r->print(' '.($output eq '' ? ' ':$output). " \n"); } $r->print("\n"); @@ -1177,6 +1148,40 @@ sub display_line { } +sub showpreview { + my ($filelink)=@_; + my ($curfext)=($filelink=~/\.(\w+)$/); + 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); + if ($output=~/LONCAPAACCESSCONTROLERRORSCREEN/s) { + $output=''; + } else { + open(FH,">$cache"); + print FH $output; + close(FH); + } + } + $output=''.$output.''; + } elsif ($embstyle eq 'img') { + $output=''; + } elsif ($filelink=~/^\/res\/(\w+)\/(\w+)\//) { + $output=''; + } + return $output; +} + sub dynmetaprint { my ($r,$filelink,$item)=@_; if ($dynhash{$filelink}->{$item}) { @@ -1237,6 +1242,7 @@ sub cleanup { if (tied(%hash)){ &Apache::lonnet::logthis('Cleanup indexer: hash'); } + return OK; }