Diff for /loncom/publisher/lonpublisher.pm between versions 1.109 and 1.113

version 1.109, 2003/02/18 13:20:13 version 1.113, 2003/03/07 17:52:37
Line 117  use File::Copy; Line 117  use File::Copy;
 use Apache::Constants qw(:common :http :methods);  use Apache::Constants qw(:common :http :methods);
 use HTML::LCParser;  use HTML::LCParser;
 use Apache::lonxml;  use Apache::lonxml;
 use Apache::lonhomework;  
 use Apache::loncacc;  use Apache::loncacc;
 use DBI;  use DBI;
 use Apache::lonnet();  use Apache::lonnet();
Line 790  This is the workhorse function of this m Line 789  This is the workhorse function of this m
 backup copies, performs any automatic processing (prior to publication,  backup copies, performs any automatic processing (prior to publication,
 especially for rat and ssi files),  especially for rat and ssi files),
   
   Returns a 2 element array, the first is the string to be shown to the
   user, the second is an error code, either 1 (an error occured) or 0
   (no error occurred)
   
 I<Additional documentation needed.>  I<Additional documentation needed.>
   
 =cut  =cut
Line 806  sub publish { Line 809  sub publish {
     my %allow=();      my %allow=();
   
     unless ($logfile=Apache::File->new('>>'.$source.'.log')) {      unless ($logfile=Apache::File->new('>>'.$source.'.log')) {
  return    return ('<font color=red>No write permission to user directory, FAIL</font>',1);
          '<font color=red>No write permission to user directory, FAIL</font>';  
     }      }
     print $logfile       print $logfile 
 "\n\n================= Publish ".localtime()." Phase One  ================\n";  "\n\n================= Publish ".localtime()." Phase One  ================\n";
Line 821  sub publish { Line 823  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 "<font color=red>Failed to write backup copy, $!,FAIL</font>";      return ("<font color=red>Failed to write backup copy, $!,FAIL</font>",1);
         }          }
 # ------------------------------------------------------------- IDs and indices  # ------------------------------------------------------------- IDs and indices
   
  my ($outstring,$error);   my ($outstring,$error);
  ($outstring,$error,%allow)=&fix_ids_and_indices($logfile,$source,   ($outstring,$error,%allow)=&fix_ids_and_indices($logfile,$source,
  $target);   $target);
  if ($error) { return $outstring; }   if ($error) { return ($outstring,$error); }
 # ------------------------------------------------------------ Construct Allows  # ------------------------------------------------------------ Construct Allows
           
  $scrout.='<h3>Dependencies</h3>';   $scrout.='<h3>Dependencies</h3>';
Line 873  sub publish { Line 875  sub publish {
           my $org;            my $org;
           unless ($org=Apache::File->new('>'.$source)) {            unless ($org=Apache::File->new('>'.$source)) {
              print $logfile "No write permit to $source\n";               print $logfile "No write permit to $source\n";
              return                return ('<font color="red">No write permission to '.$source.
  '<font color="red">No write permission to '.$source.       ', FAIL</font>',1);
  ', FAIL</font>';  
   }    }
           print($org $outstring);            print($org $outstring);
         }          }
Line 1123  END Line 1124  END
     my $copyright_help =      my $copyright_help =
         Apache::loncommon::help_open_topic('Publishing_Copyright');          Apache::loncommon::help_open_topic('Publishing_Copyright');
     $scrout =~ s/DISTRIBUTION:/'DISTRIBUTION: ' . $copyright_help/ge;      $scrout =~ s/DISTRIBUTION:/'DISTRIBUTION: ' . $copyright_help/ge;
     return $scrout.      return ($scrout.'<p><input type="submit" value="Finalize Publication" /></p></form>',0);
         '<p><input type="submit" value="Finalize Publication" /></p></form>';  
 # =============================================================================  # =============================================================================
 # BATCH MODE  # BATCH MODE
 #  #
Line 1152  END Line 1152  END
  $ENV{'form.copyright'}='default';   $ENV{'form.copyright'}='default';
     }       } 
     $ENV{'form.allmeta'}=&Apache::lonnet::escape($allmeta);      $ENV{'form.allmeta'}=&Apache::lonnet::escape($allmeta);
     return $scrout;      return ($scrout,0);
   }    }
 }  }
   
Line 1201  sub phasetwo { Line 1201  sub phasetwo {
     $target=~s/\/+/\//g;      $target=~s/\/+/\//g;
   
     if ($target=~/\_\_\_/) {      if ($target=~/\_\_\_/) {
  return    $r->print(
  '<font color=red>Unsupported character combination "<tt>___</tt>" in filename, FAIL</font>';   '<font color=red>Unsupported character combination "<tt>___</tt>" in filename, FAIL</font>');
           return 0;
     }      }
     $distarget=~s/\/+/\//g;      $distarget=~s/\/+/\//g;
     my $logfile;      my $logfile;
     unless ($logfile=Apache::File->new('>>'.$source.'.log')) {      unless ($logfile=Apache::File->new('>>'.$source.'.log')) {
  return    $r->print(
             '<font color=red>No write permission to user directory, FAIL</font>';          '<font color=red>No write permission to user directory, FAIL</font>');
           return 0;
     }      }
     print $logfile       print $logfile 
         "\n================= Publish ".localtime()." Phase Two  ================\n";          "\n================= Publish ".localtime()." Phase Two  ================\n";
Line 1471  sub batchpublish { Line 1473  sub batchpublish {
   
 # phase one takes  # phase one takes
 #  my ($source,$target,$style,$batch)=@_;  #  my ($source,$target,$style,$batch)=@_;
     $r->print('<p>'.&publish($srcfile,$targetfile,$thisembstyle,1).'</p>');      my ($outstring,$error)=&publish($srcfile,$targetfile,$thisembstyle,1);
       $r->print('<p>'.$outstring.'</p>');
 # phase two takes  # phase two takes
 # my ($source,$target,$style,$distarget,batch)=@_;  # my ($source,$target,$style,$distarget,batch)=@_;
 # $ENV{'form.allmeta'},$ENV{'form.title'},$ENV{'form.author'},...  # $ENV{'form.allmeta'},$ENV{'form.title'},$ENV{'form.author'},...
     $r->print('<p>');      if (!$error) {
     &phasetwo($r,$srcfile,$targetfile,$thisembstyle,$thisdistarget,1);   $r->print('<p>');
     $r->print('</p>');   &phasetwo($r,$srcfile,$targetfile,$thisembstyle,$thisdistarget,1);
    $r->print('</p>');
       }
     return '';      return '';
 }  }
   
Line 1592  sub handler { Line 1597  sub handler {
   
 # -------------------------------------------------------------- Check filename  # -------------------------------------------------------------- Check filename
   
   my $fn=$ENV{'form.filename'};    my $fn=&Apache::lonnet::unescape($ENV{'form.filename'});
   
       
   unless ($fn) {     unless ($fn) { 
Line 1722  unless ($ENV{'form.phase'} eq 'two') { Line 1727  unless ($ENV{'form.phase'} eq 'two') {
 # ------------------ Publishing from $thisfn to $thistarget with $thisembstyle.  # ------------------ Publishing from $thisfn to $thistarget with $thisembstyle.
   
        unless ($ENV{'form.phase'} eq 'two') {         unless ($ENV{'form.phase'} eq 'two') {
          $r->print(     my ($outstring,$error)=&publish($thisfn,$thistarget,$thisembstyle);
           '<hr />'.&publish($thisfn,$thistarget,$thisembstyle));     $r->print('<hr />'.$outstring);
        } else {         } else {
            $r->print('<hr />');             $r->print('<hr />');
            &phasetwo($r,$thisfn,$thistarget,$thisembstyle,$thisdistarget);              &phasetwo($r,$thisfn,$thistarget,$thisembstyle,$thisdistarget); 
        }           }
   
   }    }
   $r->print('</body></html>');    $r->print('</body></html>');
   

Removed from v.1.109  
changed lines
  Added in v.1.113


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