--- loncom/publisher/lonpublisher.pm 2009/05/14 11:13:49 1.258 +++ loncom/publisher/lonpublisher.pm 2010/01/06 04:19:20 1.265.2.1 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Publication Handler # -# $Id: lonpublisher.pm,v 1.258 2009/05/14 11:13:49 bisitz Exp $ +# $Id: lonpublisher.pm,v 1.265.2.1 2010/01/06 04:19:20 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1641,7 +1641,8 @@ sub phasetwo { my $srcf=$2; my $srct=$3; my $srcd=$1; - unless ($srcd=~/^\/home\/httpd\/html\/res/) { + my $docroot = $Apache::lonnet::perlvar{'lonDocRoot'}; + unless ($srcd=~/^\Q$docroot\E\/res/) { print $logfile "\nPANIC: Target dir is ".$srcd; $r->print( "".&mt('Invalid target directory, FAIL').""); @@ -1667,11 +1668,10 @@ sub phasetwo { if (copy($target,$copyfile)) { print $logfile "Copied old target to ".$copyfile."\n"; - $r->print('

'.&mt('Copied old target file').'

'); + $r->print(&Apache::lonhtmlcommon::confirm_success(&mt('Copied old target file'))); } else { print $logfile "Unable to write ".$copyfile.':'.$!."\n"; - $r->print("".&mt('Failed to copy old target'). - ", $!, ".&mt('FAIL').""); + $r->print(&Apache::lonhtmlcommon::confirm_success(&mt('Failed to copy old target').", $!",1)); return 0; } @@ -1681,13 +1681,12 @@ sub phasetwo { if (copy($target.'.meta',$copyfile)) { print $logfile "Copied old target metadata to ".$copyfile."\n"; - $r->print('

'.&mt('Copied old metadata').'

') + $r->print(&Apache::lonhtmlcommon::confirm_success(&mt('Copied old metadata'))); } else { print $logfile "Unable to write metadata ".$copyfile.':'.$!."\n"; if (-e $target.'.meta') { - $r->print( - "". -&mt('Failed to write old metadata copy').", $!, ".&mt('FAIL').""); + $r->print(&Apache::lonhtmlcommon::confirm_success( + &mt('Failed to write old metadata copy').", $!",1)); return 0; } } @@ -1720,25 +1719,29 @@ sub phasetwo { if (copy($source,$copyfile)) { print $logfile "\nCopied original source to ".$copyfile."\n"; - $r->print('

'.&mt('Copied source file').'

'); + $r->print(&Apache::lonhtmlcommon::confirm_success(&mt('Copied source file'))); } else { print $logfile "\nUnable to write ".$copyfile.':'.$!."\n"; - $r->print("". - &mt('Failed to copy source').", $!, ".&mt('FAIL').""); + $r->print(&Apache::lonhtmlcommon::confirm_success( + &mt('Failed to copy source').", $!",1)); return 0; } +# ---------------------------------------------- Delete local tmp-preview files + unlink($copyfile.'.tmp'); +# ---------------------------- Delete local GCI Test Assembly tn-preview files + unlink($copyfile.'.tn'); # --------------------------------------------------------------- Copy Metadata $copyfile=$copyfile.'.meta'; if (copy($source.'.meta',$copyfile)) { print $logfile "\nCopied original metadata to ".$copyfile."\n"; - $r->print('

'.&mt('Copied metadata').'

'); + $r->print(&Apache::lonhtmlcommon::confirm_success(&mt('Copied metadata'))); } else { print $logfile "\nUnable to write metadata ".$copyfile.':'.$!."\n"; - $r->print( - "".&mt('Failed to write metadata copy').", $!, ".&mt('FAIL').""); + $r->print(&Apache::lonhtmlcommon::confirm_success( + &mt('Failed to write metadata copy').", $!",1)); return 0; } $r->rflush; @@ -1746,7 +1749,8 @@ sub phasetwo { # ------------------------------------------------------------- Trigger updates push(@{$modified_urls},[$target,$source]); unless ($registered_cleanup) { - $r->register_cleanup(\¬ify); + my $handlers = $r->get_handlers('PerlCleanupHandler'); + $r->set_handlers('PerlCleanupHandler' => [\¬ify,@{$handlers}]); $registered_cleanup=1; } @@ -1769,15 +1773,22 @@ sub phasetwo { my $thissrcdir=$thissrc; $thissrcdir=~s/\/[^\/]+$/\//; - - $r->print( - '
'. - &mt('View Published Version').''. - '

'. - &mt('Back to Source').'

'. - '

'. - &mt('Back to Source Directory').'

'); + $r->print(&Apache::loncommon::head_subbox( + &Apache::lonhtmlcommon::start_funclist(). + &Apache::lonhtmlcommon::add_item_funclist( + ''. + &mt('View Published Version'). + ''). + &Apache::lonhtmlcommon::add_item_funclist( + ''. + &mt('Back to Source'). + ''). + &Apache::lonhtmlcommon::add_item_funclist( + ''. + &mt('Back to Source Directory'). + ''). + &Apache::lonhtmlcommon::end_funclist()) + ); } return 1; } @@ -2163,10 +2174,25 @@ sub handler { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; + # Breadcrumbs + &Apache::lonhtmlcommon::clear_breadcrumbs(); + &Apache::lonhtmlcommon::add_breadcrumb({ + 'text' => 'Construction Space', + 'href' => &Apache::loncommon::authorspace(), + }); + &Apache::lonhtmlcommon::add_breadcrumb({ + 'text' => 'Resource Publication', + 'href' => '', + }); + my $js=''; - $r->print(&Apache::loncommon::start_page('Resource Publication',$js)); + $r->print(&Apache::loncommon::start_page('Resource Publication',$js) + .&Apache::lonhtmlcommon::breadcrumbs() + .&Apache::loncommon::head_subbox( + &Apache::loncommon::CSTR_pageheader()) # FIXME crumbs broken? + ); my $thisfn=$fn; @@ -2267,7 +2293,6 @@ ENDDIFF } } else { &phasetwo($r,$thisfn,$thistarget,$thisembstyle,$thisdistarget); - $r->print('
'); } } $r->print(&Apache::loncommon::end_page());