Diff for /loncom/publisher/loncleanup.pm between versions 1.10 and 1.11

version 1.10, 2008/12/24 07:58:34 version 1.11, 2009/09/09 17:58:37
Line 36  use File::Copy; Line 36  use File::Copy;
 use Apache::Constants qw(:common :http :methods);  use Apache::Constants qw(:common :http :methods);
 use Apache::loncacc;  use Apache::loncacc;
 use Apache::loncommon();  use Apache::loncommon();
   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/';
Line 248  sub htmlclean { Line 249  sub htmlclean {
   
 sub phaseone {  sub phaseone {
     my ($r,$fn,$uname,$udom)=@_;      my ($r,$fn,$uname,$udom)=@_;
     $r->print(&mt('Select actions to attempt:').      $r->print(
       '<br /><input type="checkbox" name="linefeed" checked="checked" /> '.          &Apache::lonhtmlcommon::start_pick_box()
       &mt('Linefeeds, formfeeds, and carriage returns').         .&Apache::lonhtmlcommon::row_title(&mt('Select actions to attempt'))
       '<br /><input type="checkbox" name="empty" checked="checked" /> '.         .'<input type="checkbox" name="linefeed" checked="checked" /> '
       &mt('Empty tags').         .&mt('Linefeeds, formfeeds, and carriage returns')
       '<br /><input type="checkbox" name="lower" checked="checked" /> '.         .'<br />'
       &mt('Lower casing').         .'<input type="checkbox" name="empty" checked="checked" /> '
       '<br /><input type="checkbox" name="symbol"checked="checked" /> '.         .&mt('Empty tags')
       &mt('Symbol font').         .'<br />'
       '<input type="hidden" name="phase" value="two" />'.         .'<input type="checkbox" name="lower" checked="checked" /> '
       '<p><input type="submit" value="'.&mt('Cleanup').'" /></p>');         .&mt('Lower casing')
          .'<br />'
          .'<input type="checkbox" name="symbol" checked="checked" /> '
          .&mt('Symbol font')
          .&Apache::lonhtmlcommon::row_closure(1)
          .&Apache::lonhtmlcommon::end_pick_box()
       );
   
       $r->print(
           '<input type="hidden" name="phase" value="two" />'
          .'<p>'
          .'<input type="submit" value="'.&mt('Next').'" />'
          .'</p>'
       );
 }  }
   
 sub phasetwo {  sub phasetwo {
       # Check original file
     my ($r,$fn,$uname,$udom)=@_;      my ($r,$fn,$uname,$udom)=@_;
     open(IN,'/home/'.$uname.'/public_html/'.$fn);      open(IN,'/home/'.$uname.'/public_html/'.$fn);
     my $text='';      my $text='';
Line 274  sub phasetwo { Line 289  sub phasetwo {
  ('grade_target'=>'web',   ('grade_target'=>'web',
   'return_only_error_and_warning_counts' => 1));    'return_only_error_and_warning_counts' => 1));
     my ($errorcount,$warningcount)=split(':',$result);      my ($errorcount,$warningcount)=split(':',$result);
     $r->print(&mt('Original file').': '.  
       $errorcount.' '.&mt('error(s)').', '.      # Display results for original file
       $warningcount.' '.&mt('warning(s)'));      $r->print(
           &Apache::lonhtmlcommon::start_pick_box()
          .&Apache::lonhtmlcommon::row_title(&mt('Original file'))
          .&Apache::lonhtmlcommon::confirm_success(
              &mt('[quant,_1,error]',$errorcount), $errorcount)
          .'<br />'
          .&Apache::lonhtmlcommon::confirm_success(
              &mt('[quant,_1,warning]',$warningcount), $warningcount)
          .&Apache::lonhtmlcommon::row_closure()
       );
   
       # Clean up file
     $text=&htmlclean($text,1,      $text=&htmlclean($text,1,
                ($env{'form.linefeed'} ne 'on'),                 ($env{'form.linefeed'} ne 'on'),
                ($env{'form.empty'} ne 'on'),                 ($env{'form.empty'} ne 'on'),
Line 289  sub phasetwo { Line 315  sub phasetwo {
     close(OUT);      close(OUT);
     my $newuri='/~'.$uname.$newfn;      my $newuri='/~'.$uname.$newfn;
     $result=&Apache::lonnet::ssi_body($newuri,      $result=&Apache::lonnet::ssi_body($newuri,
  ('grade_target'=>'web',                                           ('grade_target'=>'web',
   'return_only_error_and_warning_counts' => 1));                                            'return_only_error_and_warning_counts' => 1));
     ($errorcount,$warningcount)=split(':',$result);      ($errorcount,$warningcount)=split(':',$result);
     $r->print('<br />'.&mt('Cleaned up file').': '.  
       $errorcount.' '.&mt('error(s)').', '.      # Display results for cleaned up file
       $warningcount.' '.&mt('warning(s)').      $r->print(
               '<br /><a href="'.$newuri.'" target="prev">'.          &Apache::lonhtmlcommon::row_title(&mt('Cleaned up file'))
       &mt('Open (and edit) cleaned up file in new window').'</a>'.         .&Apache::lonhtmlcommon::confirm_success(
               '<br /><a href="/adm/diff?filename='.&escape($uri).             &mt('[quant,_1,error]',$errorcount), $errorcount)
       '&versionone=priv&filetwo='.         .'<br />'
       &escape($newuri).'" target="prev">'.         .&Apache::lonhtmlcommon::confirm_success(
       &mt('Show diffs in new window').'</a><br />'.             &mt('[quant,_1,warning]',$warningcount), $warningcount)
       '<input type="hidden" name="phase" value="three" />'.         .&Apache::lonhtmlcommon::row_closure()
       '<input type="submit" name="accept" value="'.&mt('Accept Result').'" />'.      );
       '<input type="submit" name="reject" value="'.&mt('Reject Result').'" />'  
       );      # Display actions
       $r->print(
           &Apache::lonhtmlcommon::row_title(&mt('Actions'))
          .'<ul>'
          .'<li><a href="'.$newuri.'" target="prev">'
          .&mt('Open (and edit) cleaned up file in new window')
          .'</a></li>'
          .'<li><a href="/adm/diff?filename='.&escape($uri)
          .'&versionone=priv&filetwo='.&escape($newuri).'" target="prev">'
          .&mt('Show diffs in new window')
          .'</a></li>'
          .'</ul>'
          .&Apache::lonhtmlcommon::row_closure(1)
          .&Apache::lonhtmlcommon::end_pick_box()
          .'<p>'
          .'<input type="hidden" name="phase" value="three" />'
          .'<input type="submit" name="accept" value="'
          .&mt('Clean Up').'" />'
          .' <input type="submit" name="reject" value="'
          .&mt('Cancel').'" />'
          .'</p>'
       );
 }  }
   
 sub phasethree {  sub phasethree {
Line 314  sub phasethree { Line 361  sub phasethree {
     my $newfn=$main.'_Auto_Cleaned_Up.'.$ext;      my $newfn=$main.'_Auto_Cleaned_Up.'.$ext;
     my $new='/home/'.$uname.'/public_html'.$newfn;      my $new='/home/'.$uname.'/public_html'.$newfn;
     if ($env{'form.accept'}) {      if ($env{'form.accept'}) {
  $r->print(&mt('Accepting changes'));   $r->print(
           '<p class="LC_info">'
          .&mt('Accepting changes')
          .'</p>'
       );
         move($new,$old);          move($new,$old);
     } else {      } else {
  $r->print(&mt('Rejeting changes'));   $r->print(
           '<p class="LC_info">'
          .&mt('Rejecting changes')
          .'</p>'
       );
         unlink($new);          unlink($new);
     }      }
 }  }
Line 367  sub handler { Line 422  sub handler {
     &Apache::loncommon::content_type($r,'text/html');      &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;      $r->send_http_header;
   
     $r->print(&Apache::loncommon::start_page('Cleanup XML Document'));      # Breadcrumbs
       my $brcrum = [{'href' => &Apache::loncommon::authorspace(),
                      'text' => 'Construction Space'},
                     {'href' => '',
                      'text' => 'Cleanup XML Document'}];
   
       $r->print(&Apache::loncommon::start_page('Cleanup XML Document',
                                                undef,
                                                {'bread_crumbs' => $brcrum,}));
     $r->print('<h2>'.$fn.'</h2>'.      $r->print('<h2>'.$fn.'</h2>'.
               '<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'}.'" />');
Line 384  sub handler { Line 447  sub handler {
     }      }
     my $dir=$fn;      my $dir=$fn;
     $dir=~s/\/[^\/]+$/\//;      $dir=~s/\/[^\/]+$/\//;
     $r->print('</form>'.      $r->print(
       '<br /><a href="/priv/'.$uname.'/'.$fn.'">'.&mt('Back to Source File').'</a>'.          '</form>'
               '<br /><a href="/priv/'.$uname.'/'.$dir.'">'.&mt('Back to Source Directory').'</a>'.         .&Apache::lonhtmlcommon::start_funclist()
       &Apache::loncommon::end_page());         .&Apache::lonhtmlcommon::add_item_funclist(
               '<a href="/priv/'.$uname.'/'.$fn.'">'.&mt('Back to Source File').'</a>')
          .&Apache::lonhtmlcommon::add_item_funclist(
               '<a href="/priv/'.$uname.'/'.$dir.'">'.&mt('Back to Source Directory').'</a>')
          .&Apache::lonhtmlcommon::end_funclist()
          .&Apache::loncommon::end_page()
       );
   
     return OK;        return OK;  
 }  }
   

Removed from v.1.10  
changed lines
  Added in v.1.11


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>