Diff for /loncom/publisher/lonpublisher.pm between versions 1.238 and 1.242

version 1.238, 2008/06/27 18:52:35 version 1.242, 2008/08/01 17:29:57
Line 123  use Apache::loncacc; Line 123  use Apache::loncacc;
 use DBI;  use DBI;
 use Apache::lonnet;  use Apache::lonnet;
 use Apache::loncommon();  use Apache::loncommon();
   use Apache::lonhtmlcommon;
 use Apache::lonmysql;  use Apache::lonmysql;
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::loncfile;  use Apache::loncfile;
Line 274  sub metaread { Line 275  sub metaread {
     }      }
     &metaeval($metastring,$prefix);      &metaeval($metastring,$prefix);
     return '<br /><b>'.&mt('Processed file').':</b> <tt>'.      return '<br /><b>'.&mt('Processed file').':</b> <tt>'.
  &Apache::loncfile::display($fn).'</tt>';   &Apache::loncfile::display($fn).'</tt><br />';
 }  }
   
 #########################################  #########################################
Line 325  string which presents the form field (fo Line 326  string which presents the form field (fo
 #########################################  #########################################
 #########################################  #########################################
 sub textfield {  sub textfield {
     my ($title,$name,$value)=@_;      my ($title,$name,$value,$noline)=@_;
     $value=~s/^\s+//gs;      $value=~s/^\s+//gs;
     $value=~s/\s+$//gs;      $value=~s/\s+$//gs;
     $value=~s/\s+/ /gs;      $value=~s/\s+/ /gs;
Line 333  sub textfield { Line 334  sub textfield {
     $env{'form.'.$name}=$value;      $env{'form.'.$name}=$value;
     return "\n".&Apache::lonhtmlcommon::row_title($title)      return "\n".&Apache::lonhtmlcommon::row_title($title)
            .'<input type="text" name="'.$name.'" size="80" value="'.$value.'" />'             .'<input type="text" name="'.$name.'" size="80" value="'.$value.'" />'
            .&Apache::lonhtmlcommon::row_closure();             .&Apache::lonhtmlcommon::row_closure($noline);
 }  }
   
 sub text_with_browse_field {  sub text_with_browse_field {
     my ($title,$name,$value,$restriction)=@_;      my ($title,$name,$value,$restriction,$noline)=@_;
     $value=~s/^\s+//gs;      $value=~s/^\s+//gs;
     $value=~s/\s+$//gs;      $value=~s/\s+$//gs;
     $value=~s/\s+/ /gs;      $value=~s/\s+/ /gs;
Line 352  sub text_with_browse_field { Line 353  sub text_with_browse_field {
   .'<a href="javascript:opensearcher(\'pubform\',\''.$name.'\');">'    .'<a href="javascript:opensearcher(\'pubform\',\''.$name.'\');">'
           .&mt('Search')            .&mt('Search')
           .'</a>'            .'</a>'
           .&Apache::lonhtmlcommon::row_closure();            .&Apache::lonhtmlcommon::row_closure($noline);
 }  }
   
 sub hiddenfield {  sub hiddenfield {
Line 797  sub fix_ids_and_indices { Line 798  sub fix_ids_and_indices {
                 }                  }
                 if ((($token->[1] eq 'part') || ($token->[1] eq 'problem'))                  if ((($token->[1] eq 'part') || ($token->[1] eq 'problem'))
                     && (!$responsecounter)) {                      && (!$responsecounter)) {
                     my $outstring='<span class="LC_error">'.&mt('Found [_1] without responses',$token->[1]).'</span>';                      my $outstring='<span class="LC_error">'.&mt('Found [_1] without responses. This resource cannot be published.',$token->[1]).'</span>';
                     return ($outstring,1);                      return ($outstring,1);
                 }                  }
     } else {      } else {
Line 886  sub checkonthis { Line 887  sub checkonthis {
   'return_only_error_and_warning_counts' => 1));    'return_only_error_and_warning_counts' => 1));
     my ($errorcount,$warningcount)=split(':',$result);      my ($errorcount,$warningcount)=split(':',$result);
     if (($errorcount) || ($warningcount)) {      if (($errorcount) || ($warningcount)) {
         $r->print('<br /><tt>'.$uri.'</tt>: ');          $r->print('<h3>'.&mt('Warnings and Errors').'</h3>');
  if ($errorcount) {          $r->print('<tt>'.$uri.'</tt>:');
     $r->print('<img src="/adm/lonMisc/bomb.gif" /><span class="LC_error"><b>'.          $r->print('<ul>');
       $errorcount.' '.          if ($warningcount) {
       &mt('error(s)').'</b></span> ');              $r->print('<li><div class="LC_warning">'
  }                       .&mt('[quant,_1,warning]',$warningcount)
  if ($warningcount) {                       .'</div></li>');
     $r->print('<font color="blue">'.          }
       $warningcount.' '.          if ($errorcount) {
       &mt('warning(s)').'</font>');              $r->print('<li><div class="LC_error">'
  }                       .&mt('[quant,_1,error]',$errorcount)
                        .' <img src="/adm/lonMisc/bomb.gif" />'
                        .'</div></li>');
           }
           $r->print('</ul>');
     } else {      } else {
  #$r->print('<font color="green">'.&mt('ok').'</font>');   #$r->print('<font color="green">'.&mt('ok').'</font>');
     }      }
Line 968  sub publish { Line 973  sub publish {
     print $logfile "Copied original file to ".$copyfile."\n";      print $logfile "Copied original file to ".$copyfile."\n";
         } else {          } else {
     print $logfile "Unable to write backup ".$copyfile.':'.$!."\n";      print $logfile "Unable to write backup ".$copyfile.':'.$!."\n";
     return ("<span class=\"LC_error\">Failed to write backup copy, $!,FAIL</span>",1);      return ("<span class=\"LC_error\">".&mt("Failed to write backup copy, [_1], FAIL",$1)."</span>",1);
         }          }
 # ------------------------------------------------------------- IDs and indices  # ------------------------------------------------------------- IDs and indices
   
Line 1044  sub publish { Line 1049  sub publish {
             
     unless ($batch) {      unless ($batch) {
      $scrout.='<h3>'.&mt('Metadata Information').' ' .       $scrout.='<h3>'.&mt('Metadata Information').' ' .
        Apache::loncommon::help_open_topic("Metadata_Description")         &Apache::loncommon::help_open_topic("Metadata_Description")
        . '</h3>';         . '</h3>';
     }      }
   
Line 1195  sub publish { Line 1200  sub publish {
 #   $env{'from.'..} so that it can be used by the phase two handler in  #   $env{'from.'..} so that it can be used by the phase two handler in
 #    batch mode  #    batch mode
   
     my $intr_scrout.=&Apache::lonhtmlcommon::start_pick_box()      my $intr_scrout.='<br />'
                     .'<form name="pubform" action="/adm/publish" method="post">';                      .'<form name="pubform" action="/adm/publish" method="post">';
     unless ($env{'form.makeobsolete'}) {      unless ($env{'form.makeobsolete'}) {
        $intr_scrout.=&Apache::lonhtmlcommon::row_title()         $intr_scrout.='<p>'
                     .'<input type="submit" value="'                      .&mt('Searching for your resource will be based on the following metadata. Please provide as much data as possible.')
                       .'</p>'
                       .'<p><input type="submit" value="'
                     .&mt('Finalize Publication')                      .&mt('Finalize Publication')
                     .'" />'                      .'" /></p>';
                     .&Apache::lonhtmlcommon::row_closure()  
     }      }
       $intr_scrout.=&Apache::lonhtmlcommon::start_pick_box();
     $intr_scrout.=      $intr_scrout.=
  &hiddenfield('phase','two').   &hiddenfield('phase','two').
  &hiddenfield('filename',$env{'form.filename'}).   &hiddenfield('filename',$env{'form.filename'}).
Line 1235  END Line 1242  END
                 .'<input type="button" value="'.&mt('check all').'" onclick="javascript:checkAll(document.pubform.keywords)" />'                  .'<input type="button" value="'.&mt('check all').'" onclick="javascript:checkAll(document.pubform.keywords)" />'
                 .'<input type="button" value="'.&mt('uncheck all').'" onclick="javascript:uncheckAll(document.pubform.keywords)" />'                  .'<input type="button" value="'.&mt('uncheck all').'" onclick="javascript:uncheckAll(document.pubform.keywords)" />'
                 .'</p><br />'                  .'</p><br />'
                 .'<table border="2"><tr>';                  .&Apache::loncommon::start_data_table()
                   .&Apache::loncommon::start_data_table_row();
   
     my $colcount=0;      my $colcount=0;
   
     foreach (sort keys %keywords) {      foreach (sort keys %keywords) {
Line 1258  END Line 1267  END
     }      }
     $env{'form.keywords'}=~s/\,$//;      $env{'form.keywords'}=~s/\,$//;
   
     $keywordout.='</tr></table>'      $keywordout.=&Apache::loncommon::end_data_table_row()
                    .&Apache::loncommon::end_data_table()
                  .&Apache::lonhtmlcommon::row_closure();                   .&Apache::lonhtmlcommon::row_closure();
   
     $intr_scrout.=$keywordout;      $intr_scrout.=$keywordout;
Line 1307  END Line 1317  END
   
     $intr_scrout.=&hiddenfield('lastrevisiondate',time);      $intr_scrout.=&hiddenfield('lastrevisiondate',time);
   
       my $pubowner_last;
       if ($style eq 'prv') {
           $pubowner_last = 1;
       }
     $intr_scrout.=&textfield('Publisher/Owner','owner',      $intr_scrout.=&textfield('Publisher/Owner','owner',
      $metadatafields{'owner'});       $metadatafields{'owner'},$pubowner_last);
   
 # ---------------------------------------------- Retrofix for unused copyright  # ---------------------------------------------- Retrofix for unused copyright
     if ($metadatafields{'copyright'} eq 'free') {      if ($metadatafields{'copyright'} eq 'free') {
Line 1360  END Line 1373  END
                      .&Apache::lonhtmlcommon::row_closure(1);                       .&Apache::lonhtmlcommon::row_closure(1);
         $intr_scrout.=&text_with_browse_field('Suggested Replacement for Obsolete File',          $intr_scrout.=&text_with_browse_field('Suggested Replacement for Obsolete File',
     'obsoletereplacement',      'obsoletereplacement',
     $metadatafields{'obsoletereplacement'});      $metadatafields{'obsoletereplacement'},'',1);
     } else {      } else {
  $intr_scrout.=&hiddenfield('copyright','private');   $intr_scrout.=&hiddenfield('copyright','private');
     }      }
Line 1386  END Line 1399  END
  &hiddenfield('obsolete',1).   &hiddenfield('obsolete',1).
  &text_with_browse_field('Suggested Replacement for Obsolete File',   &text_with_browse_field('Suggested Replacement for Obsolete File',
     'obsoletereplacement',      'obsoletereplacement',
     $metadatafields{'obsoletereplacement'});      $metadatafields{'obsoletereplacement'},'',1);
    }     }
     if (!$batch) {      if (!$batch) {
  $scrout.=$intr_scrout   $scrout.=$intr_scrout
             .&Apache::lonhtmlcommon::row_title()              .&Apache::lonhtmlcommon::end_pick_box()
             .'<input type="submit" value="'              .'<p><input type="submit" value="'
     .&mt($env{'form.makeobsolete'}?'Make Obsolete':'Finalize Publication')      .&mt($env{'form.makeobsolete'}?'Make Obsolete':'Finalize Publication')
             .'" />'.&Apache::lonhtmlcommon::row_closure()              .'" /></p>'
             .'</form>'              .'</form>';
             .&Apache::lonhtmlcommon::end_pick_box();  
     }      }
     return($scrout,0);      return($scrout,0);
 }  }
Line 1597  sub phasetwo { Line 1609  sub phasetwo {
         unless ($srcd=~/^\/home\/httpd\/html\/res/) {          unless ($srcd=~/^\/home\/httpd\/html\/res/) {
             print $logfile "\nPANIC: Target dir is ".$srcd;              print $logfile "\nPANIC: Target dir is ".$srcd;
             $r->print(              $r->print(
  "<span class=\"LC_error\">Invalid target directory, FAIL</span>");   "<span class=\"LC_error\">".&mt('Invalid target directory, FAIL')."</span>");
     return 0;      return 0;
         }          }
         opendir(DIR,$srcd);          opendir(DIR,$srcd);
Line 2122  sub handler { Line 2134  sub handler {
  my $thistype=$1;   my $thistype=$1;
  my $thisembstyle=&Apache::loncommon::fileembstyle($thistype);   my $thisembstyle=&Apache::loncommon::fileembstyle($thistype);
         if ($thistype eq 'page') {  $thisembstyle = 'rat'; }          if ($thistype eq 'page') {  $thisembstyle = 'rat'; }
  $r->print('<h2>'.&mt('Publishing').' '.  
   &Apache::loncommon::filedescription($thistype).' <tt>');  
   
    $r->print('<h2>'.&mt('Publishing [_1]','<tt>'.$thisdisfn.'</tt>').'</h2>');
   
           $r->print('<h3>'.&mt('Resource Details').'</h3>');
   
           $r->print(&Apache::lonhtmlcommon::start_pick_box());
   
           $r->print(&Apache::lonhtmlcommon::row_title(&mt('Type'))
                    .&Apache::loncommon::filedescription($thistype)
                    .&Apache::lonhtmlcommon::row_closure()
                    );
   
           $r->print(&Apache::lonhtmlcommon::row_title(&mt('Link to Resource'))
                    .'<tt>'
                    );
  $r->print(<<ENDCAPTION);   $r->print(<<ENDCAPTION);
 <a href='javascript:void(window.open("/~$cuname/$thisdisfn","cat","height=300,width=500,scrollbars=1,resizable=1,menubar=0,location=1"))'>  <a href='javascript:void(window.open("/~$cuname/$thisdisfn","cat","height=300,width=500,scrollbars=1,resizable=1,menubar=0,location=1"))'>
 $thisdisfn</a>  $thisdisfn</a>
 ENDCAPTION  ENDCAPTION
         $r->print('</tt></h2><b>'.&mt('Target').':</b> <tt>'.          $r->print('</tt>'
   $thisdistarget.'</tt><br />');                   .&Apache::lonhtmlcommon::row_closure()
                       );
   
           $r->print(&Apache::lonhtmlcommon::row_title(&mt('Target'))
                    .'<tt>'.$thisdistarget.'</tt>'
                    );
   # SB - ToDo:   
  if (($cuname ne $env{'user.name'})||($cudom ne $env{'user.domain'})) {   if (($cuname ne $env{'user.name'})||($cudom ne $env{'user.domain'})) {
     $r->print('<h3><font color="red">'.&mt('Co-Author').': '.  #           $r->print(&Apache::lonhtmlcommon::row_title('<span class="LC_warning">'.&mt('Co-Author').'</span>')
       $cuname.&mt(' at ').$cudom.'</font></h3>');              $r->print(&Apache::lonhtmlcommon::row_closure()
                        .&Apache::lonhtmlcommon::row_title(&mt('Co-Author'))
                        .'<span class="LC_warning">'
        .&mt('[_1] at [_2]',$cuname,$cudom)
                        .'</span>'
                        );
  }   }
   
  if (&Apache::loncommon::fileembstyle($thistype) eq 'ssi') {   if (&Apache::loncommon::fileembstyle($thistype) eq 'ssi') {
               $r->print(&Apache::lonhtmlcommon::row_closure()
                        .&Apache::lonhtmlcommon::row_title(&mt('Diffs')));
     $r->print(<<ENDDIFF);      $r->print(<<ENDDIFF);
 <br />  
 <a href='javascript:void(window.open("/adm/diff?filename=/~$cuname/$thisdisfn&versiontwo=priv","cat","height=300,width=500,scrollbars=1,resizable=1,menubar=0,location=1"))'>  <a href='javascript:void(window.open("/adm/diff?filename=/~$cuname/$thisdisfn&versiontwo=priv","cat","height=300,width=500,scrollbars=1,resizable=1,menubar=0,location=1"))'>
 ENDDIFF  ENDDIFF
             $r->print(&mt('Diffs with Current Version').'</a><br />');              $r->print(&mt('Diffs with Current Version').'</a>');
  }   }
           
           $r->print(&Apache::lonhtmlcommon::row_closure(1)
                    .&Apache::lonhtmlcommon::end_pick_box()
                    );
       
 # ------------------ Publishing from $thisfn to $thistarget with $thisembstyle.  # ------------------ Publishing from $thisfn to $thistarget with $thisembstyle.
   
Line 2158  ENDDIFF Line 2197  ENDDIFF
     &publish($thisfn,$thistarget,$thisembstyle);      &publish($thisfn,$thistarget,$thisembstyle);
  $r->print('<hr />'.$outstring);   $r->print('<hr />'.$outstring);
     } else {      } else {
  $r->print('<h3>'.   $r->print('<h3 class="LC_error">'.
   &mt('The document contains errors and cannot be published.').    &mt('The document contains errors and cannot be published.').
   '</h3>');    '</h3>');
     }      }

Removed from v.1.238  
changed lines
  Added in v.1.242


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