Diff for /loncom/publisher/lonpublisher.pm between versions 1.119 and 1.120

version 1.119, 2003/03/17 16:58:09 version 1.120, 2003/03/29 05:58:12
Line 242  sub metaread { Line 242  sub metaread {
     my ($logfile,$fn)=@_;      my ($logfile,$fn)=@_;
     unless (-e $fn) {      unless (-e $fn) {
  print($logfile 'No file '.$fn."\n");   print($logfile 'No file '.$fn."\n");
         return '<br><b>No file:</b> <tt>'.$fn.'</tt>';          return '<br /><b>No file:</b> <tt>'.$fn.'</tt>';
     }      }
     print($logfile 'Processing '.$fn."\n");      print($logfile 'Processing '.$fn."\n");
     my $metastring;      my $metastring;
Line 251  sub metaread { Line 251  sub metaread {
      $metastring=join('',<$metafh>);       $metastring=join('',<$metafh>);
     }      }
     &metaeval($metastring);      &metaeval($metastring);
     return '<br><b>Processed file:</b> <tt>'.$fn.'</tt>';      return '<br /><b>Processed file:</b> <tt>'.$fn.'</tt>';
 }  }
   
 #########################################  #########################################
Line 304  string which presents the form field (fo Line 304  string which presents the form field (fo
 #########################################  #########################################
 sub textfield {  sub textfield {
     my ($title,$name,$value)=@_;      my ($title,$name,$value)=@_;
     return "\n<p><b>$title:</b><br>".      return "\n<p><b>$title:</b></p><br />".
            '<input type="text" name="'.$name.'" size=80 value="'.$value.'" />';             '<input type="text" name="'.$name.'" size=80 value="'.$value.'" />';
 }  }
   
Line 317  sub selectbox { Line 317  sub selectbox {
     my ($title,$name,$value,$functionref,@idlist)=@_;      my ($title,$name,$value,$functionref,@idlist)=@_;
     my $uctitle=uc($title);      my $uctitle=uc($title);
     my $selout="\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:".      my $selout="\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:".
  "</b></font><br />".'<select name="'.$name.'">';   "</b></font></p><br />".'<select name="'.$name.'">';
     foreach (@idlist) {      foreach (@idlist) {
         $selout.='<option value=\''.$_.'\'';          $selout.='<option value=\''.$_.'\'';
         if ($_ eq $value) {          if ($_ eq $value) {
Line 841  sub publish { Line 841  sub publish {
            unless ($style eq 'rat') {              unless ($style eq 'rat') { 
               $allowstr.="\n".'<allow src="'.$thisdep.'" />';                $allowstr.="\n".'<allow src="'.$thisdep.'" />';
    }     }
            $scrout.='<br>';             $scrout.='<br />';
            unless ($thisdep=~/\*/) {             unless ($thisdep=~/\*/) {
        $scrout.='<a href="'.$thisdep.'">';         $scrout.='<a href="'.$thisdep.'">';
            }             }
Line 969  sub publish { Line 969  sub publish {
  }   }
     }      }
     if ($chparms) {      if ($chparms) {
  $scrout.='<p><b>New parameters or stored values:</b> '.$chparms;   $scrout.='<p><b>New parameters or stored values:</b> '.$chparms.'</p>';
     }      }
   
     $chparms='';      $chparms='';
Line 984  sub publish { Line 984  sub publish {
     }      }
     if ($chparms) {      if ($chparms) {
  $scrout.='<p><b>Obsolete parameters or stored values:</b> '.   $scrout.='<p><b>Obsolete parameters or stored values:</b> '.
     $chparms;      $chparms.'</p>';
     }      }
   
 # ------------------------------------------------------- Now have all metadata  # ------------------------------------------------------- Now have all metadata
Line 1043  function uncheckAll(field) { Line 1043  function uncheckAll(field) {
 }  }
 </script>  </script>
 <p><b>Keywords: $keywords_help</b>   <p><b>Keywords: $keywords_help</b> 
 <input type="button" value="check all" onclick="javascript:checkAll(document.pubform.keywords)">   <input type="button" value="check all" onclick="javascript:checkAll(document.pubform.keywords)" /> 
 <input type="button" value="uncheck all" onclick="javascript:uncheckAll(document.pubform.keywords)">   <input type="button" value="uncheck all" onclick="javascript:uncheckAll(document.pubform.keywords)" /> 
   </p>
 <br />  <br />
 END  END
  $keywordout.='<table border=2><tr>';   $keywordout.='<table border="2"><tr>';
  my $colcount=0;   my $colcount=0;
   
  foreach (sort keys %keywords) {   foreach (sort keys %keywords) {
     $keywordout.='<td><input type=checkbox name="keywords" value="'.$_.'"';      $keywordout.='<td><input type="checkbox" name="keywords" value="'.$_.'"';
     if ($metadatafields{'keywords'}) {      if ($metadatafields{'keywords'}) {
  if ($metadatafields{'keywords'}=~/$_/) {   if ($metadatafields{'keywords'}=~/$_/) {
     $keywordout.=' checked';      $keywordout.=' checked="on"';
  }   }
     } elsif (&Apache::loncommon::keyword($_)) {      } elsif (&Apache::loncommon::keyword($_)) {
  $keywordout.=' checked';   $keywordout.=' checked="on"';
     }      }
     $keywordout.='>'.$_.'</td>';      $keywordout.=' />'.$_.'</td>';
     if ($colcount>10) {      if ($colcount>10) {
  $keywordout.="</tr><tr>\n";   $keywordout.="</tr><tr>\n";
  $colcount=0;   $colcount=0;
Line 1076  END Line 1077  END
  $scrout.=&textfield('Notes','notes',$metadatafields{'notes'});   $scrout.=&textfield('Notes','notes',$metadatafields{'notes'});
   
  $scrout.=   $scrout.=
     '<p><b>Abstract:</b><br><textarea cols=80 rows=5 name=abstract>'.      '<p><b>Abstract:</b><br /><textarea cols="80" rows="5" name="abstract">'.
     $metadatafields{'abstract'}.'</textarea>';      $metadatafields{'abstract'}.'</textarea></p>';
   
  $source=~/\.(\w+)$/;   $source=~/\.(\w+)$/;
   
Line 1274  sub phasetwo { Line 1275  sub phasetwo {
                         .'</'.$tag.'>';                          .'</'.$tag.'>';
             }              }
         }          }
         $r->print('<p>Wrote Metadata');          $r->print('<p>Wrote Metadata</p>');
         print $logfile "\nWrote metadata";          print $logfile "\nWrote metadata";
     }      }
           
Line 1285  sub phasetwo { Line 1286  sub phasetwo {
     unless ($metadatafields{'copyright'} eq 'priv') {      unless ($metadatafields{'copyright'} eq 'priv') {
         my ($error,$success) = &store_metadata(\%metadatafields);          my ($error,$success) = &store_metadata(\%metadatafields);
         if ($success) {          if ($success) {
             $r->print('<p>Synchronized SQL metadata database');              $r->print('<p>Synchronized SQL metadata database</p>');
             print $logfile "\nSynchronized SQL metadata database";              print $logfile "\nSynchronized SQL metadata database";
         } else {          } else {
             $r->print($error);              $r->print($error);
             print $logfile "\n".$error;              print $logfile "\n".$error;
         }          }
     } else {      } else {
         $r->print('<p>Private Publication - did not synchronize database');          $r->print('<p>Private Publication - did not synchronize database</p>');
         print $logfile "\nPrivate: Did not synchronize data into ".          print $logfile "\nPrivate: Did not synchronize data into ".
             "SQL metadata database";              "SQL metadata database";
     }      }
Line 1322  sub phasetwo { Line 1323  sub phasetwo {
         }          }
         closedir(DIR);          closedir(DIR);
         $maxversion++;          $maxversion++;
         $r->print('<p>Creating old version '.$maxversion);          $r->print('<p>Creating old version '.$maxversion.'</p>');
         print $logfile "\nCreating old version ".$maxversion;          print $logfile "\nCreating old version ".$maxversion;
                   
         my $copyfile=$srcd.'/'.$srcf.'.'.$maxversion.'.'.$srct;          my $copyfile=$srcd.'/'.$srcf.'.'.$maxversion.'.'.$srct;
                   
         if (copy($target,$copyfile)) {          if (copy($target,$copyfile)) {
     print $logfile "Copied old target to ".$copyfile."\n";      print $logfile "Copied old target to ".$copyfile."\n";
             $r->print('<p>Copied old target file');              $r->print('<p>Copied old target file</p>');
         } else {          } else {
     print $logfile "Unable to write ".$copyfile.':'.$!."\n";      print $logfile "Unable to write ".$copyfile.':'.$!."\n";
             return "<font color=\"red\">Failed to copy old target, $!, FAIL</font>";              return "<font color=\"red\">Failed to copy old target, $!, FAIL</font>";
Line 1341  sub phasetwo { Line 1342  sub phasetwo {
                   
         if (copy($target.'.meta',$copyfile)) {          if (copy($target.'.meta',$copyfile)) {
     print $logfile "Copied old target metadata to ".$copyfile."\n";      print $logfile "Copied old target metadata to ".$copyfile."\n";
             $r->print('<p>Copied old metadata')              $r->print('<p>Copied old metadata</p>')
         } else {          } else {
     print $logfile "Unable to write metadata ".$copyfile.':'.$!."\n";      print $logfile "Unable to write metadata ".$copyfile.':'.$!."\n";
             if (-e $target.'.meta') {              if (-e $target.'.meta') {
Line 1352  sub phasetwo { Line 1353  sub phasetwo {
                   
                   
     } else {      } else {
         $r->print('<p>Initial version');          $r->print('<p>Initial version</p>');
         print $logfile "\nInitial version";          print $logfile "\nInitial version";
     }      }
   
Line 1367  sub phasetwo { Line 1368  sub phasetwo {
         $path.="/$parts[$count]";          $path.="/$parts[$count]";
         if ((-e $path)!=1) {          if ((-e $path)!=1) {
             print $logfile "\nCreating directory ".$path;              print $logfile "\nCreating directory ".$path;
             $r->print('<p>Created directory '.$parts[$count]);              $r->print('<p>Created directory '.$parts[$count].'</p>');
             mkdir($path,0777);              mkdir($path,0777);
         }          }
     }      }
           
     if (copy($source,$copyfile)) {      if (copy($source,$copyfile)) {
         print $logfile "\nCopied original source to ".$copyfile."\n";          print $logfile "\nCopied original source to ".$copyfile."\n";
         $r->print('<p>Copied source file');          $r->print('<p>Copied source file</p>');
     } else {      } else {
         print $logfile "\nUnable to write ".$copyfile.':'.$!."\n";          print $logfile "\nUnable to write ".$copyfile.':'.$!."\n";
         return "<font color=\"red\">Failed to copy source, $!, FAIL</font>";          return "<font color=\"red\">Failed to copy source, $!, FAIL</font>";
Line 1386  sub phasetwo { Line 1387  sub phasetwo {
           
     if (copy($source.'.meta',$copyfile)) {      if (copy($source.'.meta',$copyfile)) {
         print $logfile "\nCopied original metadata to ".$copyfile."\n";          print $logfile "\nCopied original metadata to ".$copyfile."\n";
         $r->print('<p>Copied metadata');          $r->print('<p>Copied metadata</p>');
     } else {      } else {
         print $logfile "\nUnable to write metadata ".$copyfile.':'.$!."\n";          print $logfile "\nUnable to write metadata ".$copyfile.':'.$!."\n";
         return           return 
Line 1400  sub phasetwo { Line 1401  sub phasetwo {
  $r->print('<p>Notifying host '.$subhost.':');$r->rflush;   $r->print('<p>Notifying host '.$subhost.':');$r->rflush;
  print $logfile "\nNotifying host ".$subhost.':';   print $logfile "\nNotifying host ".$subhost.':';
  my $reply=&Apache::lonnet::critical('update:'.$target,$subhost);   my $reply=&Apache::lonnet::critical('update:'.$target,$subhost);
  $r->print($reply.'<br />');$r->rflush;   $r->print($reply.'</p><br />');$r->rflush;
  print $logfile $reply;   print $logfile $reply;
     }      }
           
Line 1412  sub phasetwo { Line 1413  sub phasetwo {
  print $logfile "\nNotifying host for metadata only ".$subhost.':';   print $logfile "\nNotifying host for metadata only ".$subhost.':';
  my $reply=&Apache::lonnet::critical('update:'.$target.'.meta',   my $reply=&Apache::lonnet::critical('update:'.$target.'.meta',
     $subhost);      $subhost);
  $r->print($reply.'<br />');$r->rflush;   $r->print($reply.'</p><br />');$r->rflush;
  print $logfile $reply;   print $logfile $reply;
     }      }
           
Line 1425  sub phasetwo { Line 1426  sub phasetwo {
         my ($cdom,$cname)=split(/\_/,$_);          my ($cdom,$cname)=split(/\_/,$_);
  my $reply=&Apache::lonnet::cput   my $reply=&Apache::lonnet::cput
                   ('versionupdate',{$target => $now},$cdom,$cname);                    ('versionupdate',{$target => $now},$cdom,$cname);
  $r->print($reply.'<br />');$r->rflush;   $r->print($reply.'</p><br />');$r->rflush;
  print $logfile $reply;   print $logfile $reply;
     }      }
 # ------------------------------------------------ Provide link to new resource  # ------------------------------------------------ Provide link to new resource
Line 1441  sub phasetwo { Line 1442  sub phasetwo {
                   
                   
         $r->print(          $r->print(
            '<hr><a href="'.$thisdistarget.'"><font size="+2">'.             '<hr /><a href="'.$thisdistarget.'"><font size="+2">'.
            'View Published Version</font></a>'.             'View Published Version</font></a>'.
            '<p><a href="'.$thissrc.'"><font size=+2>Back to Source</font></a>'.             '<p><a href="'.$thissrc.'"><font size=+2>Back to Source</font></a></p>'.
            '<p><a href="'.$thissrcdir.             '<p><a href="'.$thissrcdir.
                    '"><font size="+2">Back to Source Directory</font></a>');                     '"><font size="+2">Back to Source Directory</font></a></p>');
     }      }
 }  }
   
Line 1716  unless ($ENV{'form.phase'} eq 'two') { Line 1717  unless ($ENV{'form.phase'} eq 'two') {
       $r->print('<h2>Publishing '.        $r->print('<h2>Publishing '.
         &Apache::loncommon::filedescription($thistype).' <tt>'.          &Apache::loncommon::filedescription($thistype).' <tt>'.
         '<a href="/~'.$cuname.'/'.$thisdisfn.'" target="cat">'.$thisdisfn.          '<a href="/~'.$cuname.'/'.$thisdisfn.'" target="cat">'.$thisdisfn.
         '</a></tt></h2><b>Target:</b> <tt>'.$thisdistarget.'</tt><p>');          '</a></tt></h2><b>Target:</b> <tt>'.$thisdistarget.'</tt><br />');
         
       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">Co-Author: '.$cuname.' at '.$cudom.            $r->print('<h3><font color="red">Co-Author: '.$cuname.' at '.$cudom.
Line 1726  unless ($ENV{'form.phase'} eq 'two') { Line 1727  unless ($ENV{'form.phase'} eq 'two') {
       if (&Apache::loncommon::fileembstyle($thistype) eq 'ssi') {        if (&Apache::loncommon::fileembstyle($thistype) eq 'ssi') {
           $r->print('<br /><a href="/adm/diff?filename=/~'.$cuname.'/'.            $r->print('<br /><a href="/adm/diff?filename=/~'.$cuname.'/'.
                     $thisdisfn.                      $thisdisfn.
    '&versiontwo=priv" target="cat">Diffs with Current Version</a><p>');     '&versiontwo=priv" target="cat">Diffs with Current Version</a><br />');
       }        }
       
 # ------------------ Publishing from $thisfn to $thistarget with $thisembstyle.  # ------------------ Publishing from $thisfn to $thistarget with $thisembstyle.

Removed from v.1.119  
changed lines
  Added in v.1.120


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