--- loncom/publisher/loncleanup.pm 2006/05/30 12:47:41 1.8
+++ loncom/publisher/loncleanup.pm 2023/07/23 13:16:29 1.22
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to cleanup XML files
#
-# $Id: loncleanup.pm,v 1.8 2006/05/30 12:47:41 www Exp $
+# $Id: loncleanup.pm,v 1.22 2023/07/23 13:16:29 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -34,12 +34,13 @@ use strict;
use Apache::File;
use File::Copy;
use Apache::Constants qw(:common :http :methods);
-use Apache::loncacc;
use Apache::loncommon();
+use Apache::lonhtmlcommon();
use Apache::lonlocal;
use Apache::lonnet;
use lib '/home/httpd/lib/perl/';
use LONCAPA;
+use HTML::Entities();
sub latextrans {
@@ -248,35 +249,81 @@ sub htmlclean {
sub phaseone {
my ($r,$fn,$uname,$udom)=@_;
- $r->print(&mt('Select actions to attempt:').
- '
'.
- &mt('Linefeeds, formfeeds, and carriage returns').
- '
'.
- &mt('Empty tags').
- '
'.
- &mt('Lower casing').
- '
'.
- &mt('Symbol font').
- ''.
- '
' + .'' + .'
' + ); } sub phasetwo { + # Check original file my ($r,$fn,$uname,$udom)=@_; - open(IN,'/home/'.$uname.'/public_html/'.$fn); my $text=''; - while (my $line=' + .&mt('Please select at least one option.') + .'
' + .'' + ); + return; } - close(IN); - my $uri='/~'.$uname.$fn; + + my $uri="/priv/$udom/$uname".$fn; my $result=&Apache::lonnet::ssi_body($uri, ('grade_target'=>'web', 'return_only_error_and_warning_counts' => 1)); my ($errorcount,$warningcount)=split(':',$result); - $r->print(&mt('Original file').': '. - $errorcount.' '.&mt('error(s)').', '. - $warningcount.' '.&mt('warning(s)')); + + # Display results for original file + $r->print( + &Apache::lonhtmlcommon::start_pick_box() + .&Apache::lonhtmlcommon::row_title(&mt('Original file')) + .&Apache::lonhtmlcommon::confirm_success( + &mt('[quant,_1,error]',$errorcount), $errorcount) + .'' + .'' + .'' + .' ' + .'
' + ); } sub phasethree { my ($r,$fn,$uname,$udom)=@_; - my $old='/home/'.$uname.'/public_html/'.$fn; + my $old=$r->dir_config('lonDocRoot')."/priv/$udom/$uname".$fn; my ($main,$ext)=($fn=~/^(.*)\.(\w+)/); my $newfn=$main.'_Auto_Cleaned_Up.'.$ext; - my $new='/home/'.$uname.'/public_html'.$newfn; + my $new=$r->dir_config('lonDocRoot')."/priv/$udom/$uname".$newfn; if ($env{'form.accept'}) { - $r->print(&mt('Accepting changes')); + $r->print( + '' + .&mt('Accepting changes...') + .'
' + ); move($new,$old); } else { - $r->print(&mt('Rejeting changes')); + $r->print( + '' + .&mt('Rejecting changes...') + .'
' + ); unlink($new); } + $r->print( + '' + .&Apache::lonhtmlcommon::confirm_success(&mt('Done'))); + '
' } # ---------------------------------------------------------------- Main Handler @@ -335,7 +419,7 @@ sub handler { if ($env{'form.filename'}) { $fn=$env{'form.filename'}; - $fn=~s/^http\:\/\/[^\/]+//; + $fn=~s{^https?\://[^/]+}{}; } else { $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}. ' unspecified filename for cleanup', $r->filename); @@ -352,8 +436,7 @@ sub handler { my $uname; my $udom; - ($uname,$udom)= - &Apache::loncacc::constructaccess($fn,$r->dir_config('lonDefDomain')); + ($uname,$udom)=&Apache::lonnet::constructaccess($fn); unless (($uname) && ($udom)) { $r->log_reason($uname.' at '.$udom. ' trying to cleanup file '.$env{'form.filename'}. @@ -362,17 +445,34 @@ sub handler { return HTTP_NOT_ACCEPTABLE; } - $fn=~s/\/\~(\w+)//; - &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; - $r->print(&Apache::loncommon::start_page('Cleanup XML Document')); + # Breadcrumbs + my $text = 'Authoring Space'; + my $href = &Apache::loncommon::authorspace($fn); + if ($env{'request.course.id'}) { + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + if ($href eq "/priv/$cdom/$cnum/") { + $text = 'Course Authoring Space'; + } + } + my $brcrum = [{'href' => $href, + 'text' => $text}, + {'href' => '', + 'text' => 'Cleanup XML Document'}]; + + $fn=~s{^/priv/$LONCAPA::domain_re/$LONCAPA::username_re}{}; + + $r->print(&Apache::loncommon::start_page('Cleanup XML Document', + undef, + {'bread_crumbs' => $brcrum,})); $r->print('