version 1.15, 2011/11/03 00:30:32
|
version 1.22, 2023/07/23 13:16:29
|
Line 34 use strict;
|
Line 34 use strict;
|
use Apache::File; |
use Apache::File; |
use File::Copy; |
use File::Copy; |
use Apache::Constants qw(:common :http :methods); |
use Apache::Constants qw(:common :http :methods); |
use Apache::loncacc; |
|
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::lonhtmlcommon(); |
use Apache::lonhtmlcommon(); |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonnet; |
use Apache::lonnet; |
use lib '/home/httpd/lib/perl/'; |
use lib '/home/httpd/lib/perl/'; |
use LONCAPA; |
use LONCAPA; |
|
use HTML::Entities(); |
|
|
|
|
sub latextrans { |
sub latextrans { |
Line 252 sub phaseone {
|
Line 252 sub phaseone {
|
$r->print( |
$r->print( |
&Apache::lonhtmlcommon::start_pick_box() |
&Apache::lonhtmlcommon::start_pick_box() |
.&Apache::lonhtmlcommon::row_title(&mt('Select actions to attempt')) |
.&Apache::lonhtmlcommon::row_title(&mt('Select actions to attempt')) |
|
.'<label>' |
.'<input type="checkbox" name="linefeed" checked="checked" /> ' |
.'<input type="checkbox" name="linefeed" checked="checked" /> ' |
.&mt('Linefeeds, formfeeds, and carriage returns') |
.&mt('Linefeeds, formfeeds, and carriage returns') |
.'<br />' |
.'</label><br />' |
|
.'<label>' |
.'<input type="checkbox" name="empty" checked="checked" /> ' |
.'<input type="checkbox" name="empty" checked="checked" /> ' |
.&mt('Empty tags') |
.&mt('Empty tags') |
.'<br />' |
.'</label><br />' |
|
.'<label>' |
.'<input type="checkbox" name="lower" checked="checked" /> ' |
.'<input type="checkbox" name="lower" checked="checked" /> ' |
.&mt('Lower casing') |
.&mt('Lower casing') |
.'<br />' |
.'</label><br />' |
|
.'<label>' |
.'<input type="checkbox" name="symbol" checked="checked" /> ' |
.'<input type="checkbox" name="symbol" checked="checked" /> ' |
.&mt('Symbol font') |
.&mt('Symbol font') |
|
.'</label>' |
.&Apache::lonhtmlcommon::row_closure(1) |
.&Apache::lonhtmlcommon::row_closure(1) |
.&Apache::lonhtmlcommon::end_pick_box() |
.&Apache::lonhtmlcommon::end_pick_box() |
); |
); |
Line 286 sub phasetwo {
|
Line 291 sub phasetwo {
|
} |
} |
close(IN); |
close(IN); |
} |
} |
|
# Check if any selection was made |
|
if ($env{'form.linefeed'} ne 'on' && |
|
$env{'form.empty'} ne 'on' && |
|
$env{'form.lower'} ne 'on' && |
|
$env{'form.symbol'} ne 'on') { |
|
$r->print( |
|
'<p class="LC_warning">' |
|
.&mt('Please select at least one option.') |
|
.'</p>' |
|
.'<p><a href="javascript:history.back();">'.&mt('Back').'</p>' |
|
); |
|
return; |
|
} |
|
|
my $uri="/priv/$udom/$uname".$fn; |
my $uri="/priv/$udom/$uname".$fn; |
my $result=&Apache::lonnet::ssi_body($uri, |
my $result=&Apache::lonnet::ssi_body($uri, |
('grade_target'=>'web', |
('grade_target'=>'web', |
Line 340 sub phasetwo {
|
Line 359 sub phasetwo {
|
.'<li><a href="'.$newuri.'" target="prev">' |
.'<li><a href="'.$newuri.'" target="prev">' |
.&mt('Open (and edit) cleaned up file in new window') |
.&mt('Open (and edit) cleaned up file in new window') |
.'</a></li>' |
.'</a></li>' |
.'<li><a href="/adm/diff?filename='.&escape($uri) |
.'<li><a href="' |
.'&versionone=priv&filetwo='.&escape($newuri).'" target="prev">' |
.&HTML::Entities::encode( |
|
'/adm/diff?filename='.&escape($uri) |
|
.'&versionone=priv&filetwo='.&escape($newuri)) |
|
.'" target="prev">' |
.&mt('Show diffs in new window') |
.&mt('Show diffs in new window') |
.'</a></li>' |
.'</a></li>' |
.'</ul>' |
.'</ul>' |
Line 364 sub phasethree {
|
Line 386 sub phasethree {
|
my $newfn=$main.'_Auto_Cleaned_Up.'.$ext; |
my $newfn=$main.'_Auto_Cleaned_Up.'.$ext; |
my $new=$r->dir_config('lonDocRoot')."/priv/$udom/$uname".$newfn; |
my $new=$r->dir_config('lonDocRoot')."/priv/$udom/$uname".$newfn; |
if ($env{'form.accept'}) { |
if ($env{'form.accept'}) { |
$r->print( |
$r->print( |
'<p class="LC_info">' |
'<p class="LC_info">' |
.&mt('Accepting changes') |
.&mt('Accepting changes...') |
.'</p>' |
.'</p>' |
); |
); |
move($new,$old); |
move($new,$old); |
} else { |
} else { |
$r->print( |
$r->print( |
'<p class="LC_info">' |
'<p class="LC_info">' |
.&mt('Rejecting changes') |
.&mt('Rejecting changes...') |
.'</p>' |
.'</p>' |
); |
); |
unlink($new); |
unlink($new); |
} |
} |
|
$r->print( |
|
'<p>' |
|
.&Apache::lonhtmlcommon::confirm_success(&mt('Done'))); |
|
'</p>' |
} |
} |
|
|
# ---------------------------------------------------------------- Main Handler |
# ---------------------------------------------------------------- Main Handler |
Line 410 sub handler {
|
Line 436 sub handler {
|
my $uname; |
my $uname; |
my $udom; |
my $udom; |
|
|
($uname,$udom)=&Apache::loncacc::constructaccess($fn); |
($uname,$udom)=&Apache::lonnet::constructaccess($fn); |
unless (($uname) && ($udom)) { |
unless (($uname) && ($udom)) { |
$r->log_reason($uname.' at '.$udom. |
$r->log_reason($uname.' at '.$udom. |
' trying to cleanup file '.$env{'form.filename'}. |
' trying to cleanup file '.$env{'form.filename'}. |
Line 419 sub handler {
|
Line 445 sub handler {
|
return HTTP_NOT_ACCEPTABLE; |
return HTTP_NOT_ACCEPTABLE; |
} |
} |
|
|
$fn=~s{^/priv/$LONCAPA::domain_re/$LONCAPA::username_re}{}; |
|
|
|
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
|
|
# Breadcrumbs |
# Breadcrumbs |
my $brcrum = [{'href' => &Apache::loncommon::authorspace(), |
my $text = 'Authoring Space'; |
'text' => 'Construction 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' => '', |
{'href' => '', |
'text' => 'Cleanup XML Document'}]; |
'text' => 'Cleanup XML Document'}]; |
|
|
|
$fn=~s{^/priv/$LONCAPA::domain_re/$LONCAPA::username_re}{}; |
|
|
$r->print(&Apache::loncommon::start_page('Cleanup XML Document', |
$r->print(&Apache::loncommon::start_page('Cleanup XML Document', |
undef, |
undef, |
{'bread_crumbs' => $brcrum,})); |
{'bread_crumbs' => $brcrum,})); |
Line 437 sub handler {
|
Line 472 sub handler {
|
'<form action="/adm/cleanup" method="post">'. |
'<form action="/adm/cleanup" method="post">'. |
'<input type="hidden" name="filename" value="'.$env{'form.filename'}.'" />'); |
'<input type="hidden" name="filename" value="'.$env{'form.filename'}.'" />'); |
unless ($fn=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm|sty)$/) { |
unless ($fn=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm|sty)$/) { |
$r->print(&mt('Cannot cleanup this filetype')); |
$r->print('<p class="LC_warning">'.&mt('Cannot cleanup this filetype').'</p>'); |
} else { |
} else { |
if ($env{'form.phase'} eq 'three') { |
if ($env{'form.phase'} eq 'three') { |
&phasethree($r,$fn,$uname,$udom); |
&phasethree($r,$fn,$uname,$udom); |
Line 451 sub handler {
|
Line 486 sub handler {
|
$dir=~s{[^/]+$}{}; |
$dir=~s{[^/]+$}{}; |
$r->print( |
$r->print( |
'</form>' |
'</form>' |
.&Apache::lonhtmlcommon::start_funclist() |
.&Apache::lonhtmlcommon::actionbox( |
.&Apache::lonhtmlcommon::add_item_funclist( |
['<a href="/priv/'.$udom.'/'.$uname.$fn.'">'. |
'<a href="/priv/'.$udom.'/'.$uname.$fn.'">'.&mt('Back to Source File').'</a>') |
&mt('Back to Source File').'</a>', |
.&Apache::lonhtmlcommon::add_item_funclist( |
'<a href="/priv/'.$udom.'/'.$uname.$dir.'">'. |
'<a href="/priv/'.$udom.'/'.$uname.$dir.'">'.&mt('Back to Source Directory').'</a>') |
&mt('Back to Source Directory').'</a>']) |
.&Apache::lonhtmlcommon::end_funclist() |
|
.&Apache::loncommon::end_page() |
.&Apache::loncommon::end_page() |
); |
); |
|
|