Diff for /loncom/publisher/lonpublisher.pm between versions 1.142 and 1.158

version 1.142, 2003/11/01 17:38:58 version 1.158, 2003/12/29 21:17:00
Line 25 Line 25
 #  #
 # http://www.lon-capa.org/  # http://www.lon-capa.org/
 #  #
 #   
 # (TeX Content Handler  
 #  
 # 05/29/00,05/30,10/11 Gerd Kortemeyer)  
 #  
 # 11/28,11/29,11/30,12/01,12/02,12/04,12/23 Gerd Kortemeyer  
 # 03/23 Guy Albertelli  
 # 03/24,03/29,04/03 Gerd Kortemeyer  
 # 05/03,05/05,05/07 Gerd Kortemeyer  
 # 06/23,08/07,08/11,8/13,8/17,8/18,8/24,9/26,10/16 Gerd Kortemeyer  
 # 12/04,12/05 Guy Albertelli  
 # 12/05 Gerd Kortemeyer  
 # 12/05 Guy Albertelli  
 # 12/06,12/07 Gerd Kortemeyer  
 # 12/25 Gerd Kortemeyer  
 # YEAR=2002  
 # 1/17 Gerd Kortemeyer  
 #  
 ###  ###
   
 ###############################################################################  ###############################################################################
Line 143  use Apache::lonnet(); Line 125  use Apache::lonnet();
 use Apache::loncommon();  use Apache::loncommon();
 use Apache::lonmysql;  use Apache::lonmysql;
 use Apache::lonlocal;  use Apache::lonlocal;
   use Apache::loncfile;
   use Apache::lonmeta;
 use vars qw(%metadatafields %metadatakeys);  use vars qw(%metadatafields %metadatakeys);
   
 my %addid;  my %addid;
Line 180  nothing Line 164  nothing
   
 #########################################  #########################################
 #########################################  #########################################
   #
   # Modifies global %metadatafields %metadatakeys 
   #
   
 sub metaeval {  sub metaeval {
     my ($metastring,$prefix)=@_;      my ($metastring,$prefix)=@_;
         
Line 214  sub metaeval { Line 202  sub metaeval {
  $newentry=~s/^\s*//;   $newentry=~s/^\s*//;
  if ($newentry !~m|^/res|) { $newentry=$prefix.$newentry; }   if ($newentry !~m|^/res|) { $newentry=$prefix.$newentry; }
     }      }
     unless ($metadatafields{$unikey}=~/\w/) {  # actually store
  $metadatafields{$unikey}=$newentry;      $metadatafields{$unikey}=$newentry;
     }  
  }   }
     }      }
 }  }
Line 262  sub metaread { Line 249  sub metaread {
     my ($logfile,$fn,$prefix)=@_;      my ($logfile,$fn,$prefix)=@_;
     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>'.&mt('No file').':</b> <tt>'.
       &Apache::loncfile::display($fn).'</tt>';
     }      }
     print($logfile 'Processing '.$fn."\n");      print($logfile 'Processing '.$fn."\n");
     my $metastring;      my $metastring;
Line 271  sub metaread { Line 259  sub metaread {
  $metastring=join('',<$metafh>);   $metastring=join('',<$metafh>);
     }      }
     &metaeval($metastring,$prefix);      &metaeval($metastring,$prefix);
     return '<br /><b>Processed file:</b> <tt>'.$fn.'</tt>';      return '<br /><b>'.&mt('Processed file').':</b> <tt>'.
    &Apache::loncfile::display($fn).'</tt>';
 }  }
   
 #########################################  #########################################
Line 328  sub textfield { Line 317  sub textfield {
     $value=~s/\s+$//gs;      $value=~s/\s+$//gs;
     $value=~s/\s+/ /gs;      $value=~s/\s+/ /gs;
     $title=&mt($title);      $title=&mt($title);
     my $uctitle=uc($title);      return "\n<p><font color=\"#800000\" face=\"helvetica\"><b>$title:".
     return "\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:".  
            "</b></font></p><br />".             "</b></font></p><br />".
            '<input type="text" name="'.$name.'" size=80 value="'.$value.'" />';             '<input type="text" name="'.$name.'" size=80 value="'.$value.'" />';
 }  }
Line 342  sub hiddenfield { Line 330  sub hiddenfield {
 sub selectbox {  sub selectbox {
     my ($title,$name,$value,$functionref,@idlist)=@_;      my ($title,$name,$value,$functionref,@idlist)=@_;
     $title=&mt($title);      $title=&mt($title);
     my $uctitle=uc($title);  
     $value=(split(/\s*,\s*/,$value))[-1];      $value=(split(/\s*,\s*/,$value))[-1];
     my $selout="\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:".      my $selout="\n<p><font color=\"#800000\" face=\"helvetica\"><b>$title:".
  '</b></font></p><br /><select name="'.$name.'">';   '</b></font></p><br /><select name="'.$name.'">';
     foreach (@idlist) {      foreach (@idlist) {
         $selout.='<option value=\''.$_.'\'';          $selout.='<option value=\''.$_.'\'';
Line 621  sub fix_ids_and_indices { Line 608  sub fix_ids_and_indices {
    join(', ',@duplicatedids));     join(', ',@duplicatedids));
     if ($duplicateids) {      if ($duplicateids) {
  print $logfile "Duplicate ID(s) exist, ".join(', ',@duplicatedids)."\n";   print $logfile "Duplicate ID(s) exist, ".join(', ',@duplicatedids)."\n";
  my $outstring='<font color="red">Unable to publish file, it contains duplicated ID(s), ID(s) need to be unique. The duplicated ID(s) are: '.join(', ',@duplicatedids).'</font>';   my $outstring='<font color="red">'.&mt('Unable to publish file, it contains duplicated ID(s), ID(s) need to be unique. The duplicated ID(s) are').': '.join(', ',@duplicatedids).'</font>';
  return ($outstring,1);   return ($outstring,1);
     }      }
     if ($needsfixup) {      if ($needsfixup) {
Line 686  sub fix_ids_and_indices { Line 673  sub fix_ids_and_indices {
  }   }
  if ($lctag eq 'applet') {   if ($lctag eq 'applet') {
     my $codebase='';      my $codebase='';
     if (defined($parms{'codebase'})) {      my $havecodebase=0;
  my $oldcodebase=$parms{'codebase'};      foreach my $key (keys(%parms)) {
    if (lc($key) eq 'codebase') { 
       $codebase=$parms{$key};
       $havecodebase=1; 
    }
       }
       if ($havecodebase) {
    my $oldcodebase=$codebase;
  unless ($oldcodebase=~/\/$/) {   unless ($oldcodebase=~/\/$/) {
     $oldcodebase.='/';      $oldcodebase.='/';
  }   }
Line 701  sub fix_ids_and_indices { Line 695  sub fix_ids_and_indices {
  }   }
  $allow{&absoluteurl($codebase,$target).'/*'}=1;   $allow{&absoluteurl($codebase,$target).'/*'}=1;
     } else {      } else {
  foreach ('archive','code','object') {   foreach my $key (keys(%parms)) {
     if (defined($parms{$_})) {      if ($key =~ /(archive|code|object)/i) {
  my $oldurl=$parms{$_};   my $oldurl=$parms{$key};
  my $newurl=&urlfixup($oldurl,$target);   my $newurl=&urlfixup($oldurl,$target);
  $newurl=~s/\/[^\/]+$/\/\*/;   $newurl=~s/\/[^\/]+$/\/\*/;
  print $logfile 'Allow: applet '.$_.':'.   print $logfile 'Allow: applet '.lc($key).':'.
     $oldurl.' allows '.      $oldurl.' allows '.$newurl."\n";
  $newurl."\n";  
  $allow{&absoluteurl($newurl,$target)}=1;   $allow{&absoluteurl($newurl,$target)}=1;
     }      }
  }   }
Line 773  Returns: (error,status).  error is undef Line 766  Returns: (error,status).  error is undef
 #########################################  #########################################
 #########################################  #########################################
 sub store_metadata {  sub store_metadata {
     my %metadata = %{shift()};      my %metadata = @_;
     my $error;      my $error;
     # Determine if the table exists      # Determine if the table exists
     my $status = &Apache::lonmysql::check_table('metadata');      my $status = &Apache::lonmysql::check_table('metadata');
Line 790  sub store_metadata { Line 783  sub store_metadata {
         &Apache::lonnet::logthis($error);          &Apache::lonnet::logthis($error);
         return ($error,undef);          return ($error,undef);
     }      }
     # Remove old value from table      if (($metadata{'obsolete'}) || ($metadata{'copyright'} eq 'priv') ||
     $status = &Apache::lonmysql::remove_from_table   ($metadata{'copyright'} eq 'custom')) {
         ('metadata','url',$metadata{'url'});  # remove this entry
     if (! defined($status)) {   $status=&Apache::lonmysql::remove_from_table
         $error = '<font color="red">Error when removing old values from '.      ('metadata','url',$metadata{'url'});
             'metadata table in LON-CAPA database.</font>';      } else {
         &Apache::lonnet::logthis($error);  # store new data
         return ($error,undef);  # adjust some values to metadatadatabase (e.g., "usage" is a reserved word)
    $metadata{'creationdate'}=
       &Apache::lonmysql::sqltime($metadata{'creationdate'}); 
    $metadata{'lastrevisiondate'}=
       &Apache::lonmysql::sqltime($metadata{'lastrevisiondate'});
    $metadata{'sequsage'}=$metadata{'usage'};
    $metadata{'sequsage_list'}=$metadata{'usage_list'};
    my %newmetadata=();
   # see if we have old entries
    my @oldmeta=&Apache::lonmysql::get_rows('metadata',
    "url LIKE BINARY '".
    $metadata{'url'}."'");
    if ($#oldmeta==0) {
   # yes, there is one old entry, transfer to newmetadata
       %newmetadata=&Apache::lonmeta::metadata_col_to_hash(@{$oldmeta[0]});
   # remove old entry
       $status=&Apache::lonmysql::remove_from_table
    ('metadata','url',$metadata{'url'});
    } elsif ($#oldmeta>0) {
   # more than one entry fit - how did that happen?
       $error='<font color="red">Error occured retrieving old values in '.
         'metadata table in LON-CAPA database: '.$#oldmeta.
         ' matches</font>';
       &Apache::lonnet::logthis($error);
       return ($error,undef);
    }
   # store new data on top of it
    foreach (keys %metadata) {
       $newmetadata{$_}=$metadata{$_};
    }
    $status = &Apache::lonmysql::store_row('metadata',\%newmetadata);
     }      }
     # Store data in table.  
     $status = &Apache::lonmysql::store_row('metadata',\%metadata);  
     if (! defined($status)) {      if (! defined($status)) {
         $error='<font color="red">Error occured storing new values in '.          $error='<font color="red">Error occured storing new values in '.
             'metadata table in LON-CAPA database</font>';              'metadata table in LON-CAPA database</font>';
Line 812  sub store_metadata { Line 833  sub store_metadata {
   
   
 # ============================================== Parse file itself for metadata  # ============================================== Parse file itself for metadata
   #
   # parses a file with target meta, sets global %metadatafields %metadatakeys 
   
 sub parseformeta {  sub parseformeta {
     my ($source,$style)=@_;      my ($source,$style)=@_;
       my $allmeta='';
     if (($style eq 'ssi') || ($style eq 'prv')) {      if (($style eq 'ssi') || ($style eq 'prv')) {
  my $dir=$source;   my $dir=$source;
  $dir=~s-/[^/]*$--;   $dir=~s-/[^/]*$--;
  my $file=$source;   my $file=$source;
  $file=(split('/',$file))[-1];   $file=(split('/',$file))[-1];
         $source=&Apache::lonnet::hreflocation($dir,$file);          $source=&Apache::lonnet::hreflocation($dir,$file);
  my $allmeta=&Apache::lonnet::ssi_body($source,('grade_target' => 'meta'));   $allmeta=&Apache::lonnet::ssi_body($source,('grade_target' => 'meta'));
         &metaeval($allmeta);          &metaeval($allmeta);
     }      }
       return $allmeta;
 }  }
   
 #########################################  #########################################
Line 858  sub publish { Line 882  sub publish {
     my %allow=();      my %allow=();
   
     unless ($logfile=Apache::File->new('>>'.$source.'.log')) {      unless ($logfile=Apache::File->new('>>'.$source.'.log')) {
  return ('<font color="red">No write permission to user directory, FAIL</font>',1);   return ('<font color="red">'.&mt('No write permission to user directory, FAIL').'</font>',1);
     }      }
     print $logfile       print $logfile 
 "\n\n================= Publish ".localtime()." Phase One  ================\n".$ENV{'user.name'}.'@'.$ENV{'user.domain'}."\n";  "\n\n================= Publish ".localtime()." Phase One  ================\n".$ENV{'user.name'}.'@'.$ENV{'user.domain'}."\n";
Line 882  sub publish { Line 906  sub publish {
  if ($error) { return ($outstring,$error); }   if ($error) { return ($outstring,$error); }
 # ------------------------------------------------------------ Construct Allows  # ------------------------------------------------------------ Construct Allows
           
  $scrout.='<h3>Dependencies</h3>';   $scrout.='<h3>'.&mt('Dependencies').'</h3>';
         my $allowstr='';          my $allowstr='';
         foreach (sort(keys(%allow))) {          foreach (sort(keys(%allow))) {
    my $thisdep=$_;     my $thisdep=$_;
Line 900  sub publish { Line 924  sub publish {
                if (                 if (
        &Apache::lonnet::getfile($Apache::lonnet::perlvar{'lonDocRoot'}.'/'.         &Apache::lonnet::getfile($Apache::lonnet::perlvar{'lonDocRoot'}.'/'.
                                             $thisdep.'.meta') eq '-1') {                                              $thisdep.'.meta') eq '-1') {
    $scrout.= ' - <font color="red">Currently not available'.     $scrout.= ' - <font color="red">'.&mt('Currently not available').
        '</font>';         '</font>';
                } else {                 } else {
                    my %temphash=(&Apache::lonnet::declutter($target).'___'.                     my %temphash=(&Apache::lonnet::declutter($target).'___'.
Line 939  sub publish { Line 963  sub publish {
 # -------------------------------------------- Initial step done, now metadata.  # -------------------------------------------- Initial step done, now metadata.
   
 # --------------------------------------- Storage for metadata keys and fields.  # --------------------------------------- Storage for metadata keys and fields.
   # these are globals
   #
      %metadatafields=();       %metadatafields=();
      %metadatakeys=();       %metadatakeys=();
             
Line 960  sub publish { Line 985  sub publish {
         $metadatafields{'author'}=~s/\s+/ /g;          $metadatafields{'author'}=~s/\s+/ /g;
         $metadatafields{'author'}=~s/\s+$//;          $metadatafields{'author'}=~s/\s+$//;
         $metadatafields{'owner'}=$cuname.'@'.$cudom;          $metadatafields{'owner'}=$cuname.'@'.$cudom;
  $metadatafields{'modifyinguser'}=$ENV{'user.name'}.'@'.  
                                  $ENV{'user.domain'};  
  $metadatafields{'authorspace'}=$cuname.'@'.$cudom;  
   
 # ----------------------------------------------------------- Parse file itself  
   
  &parseformeta($source,$style);  
 # ------------------------------------------------ Check out directory hierachy  # ------------------------------------------------ Check out directory hierachy
   
         my $thisdisfn=$source;          my $thisdisfn=$source;
Line 983  sub publish { Line 1002  sub publish {
             $scrout.=&metaread($logfile,$currentpath.'default.meta',$prefix);              $scrout.=&metaread($logfile,$currentpath.'default.meta',$prefix);
     $prefix=~s|^\.\./||;      $prefix=~s|^\.\./||;
         }          }
   # ----------------------------------------------------------- Parse file itself
   # read %metadatafields from file itself
    
    $allmeta=&parseformeta($source,$style);
   
 # ------------------- Clear out parameters and stores (there should not be any)  # ------------------- Clear out parameters and stores (there should not be any)
   
Line 1003  sub publish { Line 1026  sub publish {
  delete $metadatafields{$_};   delete $metadatafields{$_};
             }              }
         }          }
           
     }  
 # ------------------------------------------ See if anything new in file itself  # ------------------------------------------ See if anything new in file itself
     
     &parseformeta($source,$style);   $allmeta=&parseformeta($source,$style);
      }
   
          
 # ---------------- Find and document discrepancies in the parameters and stores  # ---------------- Find and document discrepancies in the parameters and stores
   
     my $chparms='';      my $chparms='';
Line 1039  sub publish { Line 1062  sub publish {
     }      }
     if ($chparms) {      if ($chparms) {
  $scrout.='<p><b>'.&mt('Obsolete parameters or stored values').':</b> '.   $scrout.='<p><b>'.&mt('Obsolete parameters or stored values').':</b> '.
     $chparms.'</p>';      $chparms.'</p><h1><font color="red">'.&mt('Warning!').
       '</font></h1><p><font color="red" size="+1">'.
       &mt('If this resource is in active use, student performance data from the previous version may become inaccessible.').'</font></p><hr />';
     }      }
   
 # ------------------------------------------------------- Now have all metadata  # ------------------------------------------------------- Now have all metadata
Line 1073  sub publish { Line 1098  sub publish {
     unless ($batch) {      unless ($batch) {
         $scrout.=          $scrout.=
     '<form name="pubform" action="/adm/publish" method="post">'.      '<form name="pubform" action="/adm/publish" method="post">'.
             '<p><input type="submit" value="Finalize Publication" /></p>'.              '<p><input type="submit" value="'.&mt('Finalize Publication').'" /></p>'.
             &hiddenfield('phase','two').              &hiddenfield('phase','two').
             &hiddenfield('filename',$ENV{'form.filename'}).              &hiddenfield('filename',$ENV{'form.filename'}).
     &hiddenfield('allmeta',&Apache::lonnet::escape($allmeta)).      &hiddenfield('allmeta',&Apache::lonnet::escape($allmeta)).
Line 1085  sub publish { Line 1110  sub publish {
 # --------------------------------------------------- Scan content for keywords  # --------------------------------------------------- Scan content for keywords
   
         my $keywords_help = Apache::loncommon::help_open_topic("Publishing_Keywords");          my $keywords_help = Apache::loncommon::help_open_topic("Publishing_Keywords");
           my $KEYWORDS=&mt('Keywords');
    my $CheckAll=&mt('check all');
    my $UncheckAll=&mt('uncheck all');
  my $keywordout=<<"END";   my $keywordout=<<"END";
 <script>  <script>
 function checkAll(field) {  function checkAll(field) {
Line 1097  function uncheckAll(field) { Line 1125  function uncheckAll(field) {
         field[i].checked = false ;          field[i].checked = false ;
 }  }
 </script>  </script>
 <p><font color="#800000" face="helvetica"><b>KEYWORDS:</b></font>  <p><font color="#800000" face="helvetica"><b>$KEYWORDS:</b></font>
  $keywords_help</b>   $keywords_help</b>
 <input type="button" value="check all" onclick="javascript:checkAll(document.pubform.keywords)" />   <input type="button" value="$CheckAll" onclick="javascript:checkAll(document.pubform.keywords)" /> 
 <input type="button" value="uncheck all" onclick="javascript:uncheckAll(document.pubform.keywords)" />   <input type="button" value="$UncheckAll" onclick="javascript:uncheckAll(document.pubform.keywords)" /> 
 </p>  </p>
 <br />  <br />
 END  END
Line 1133  END Line 1161  END
  $scrout.=&textfield('Notes','notes',$metadatafields{'notes'});   $scrout.=&textfield('Notes','notes',$metadatafields{'notes'});
   
  $scrout.=   $scrout.=
     "\n<p><font color=\"#800000\" face=\"helvetica\"><b>ABSTRACT:".      "\n<p><font color=\"#800000\" face=\"helvetica\"><b>".&mt('Abstract').":".
     "</b></font></p><br />".      "</b></font></p><br />".
     '<textarea cols="80" rows="5" name="abstract">'.      '<textarea cols="80" rows="5" name="abstract">'.
     $metadatafields{'abstract'}.'</textarea></p>';      $metadatafields{'abstract'}.'</textarea></p>';
   
  $source=~/\.(\w+)$/;   $source=~/\.(\w+)$/;
   
   
    $scrout.=
       "\n<p><font color=\"#800000\" face=\"helvetica\"><b>".
       &mt('Lowest Grade Level').':'.
              "</b></font></p><br />".
      &Apache::loncommon::select_level_form($metadatafields{'lowestgradelevel'},'lowestgradelevel').
       "\n<p><font color=\"#800000\" face=\"helvetica\"><b>".
       &mt('Highest Grade Level').':'.
              "</b></font></p><br />".
      &Apache::loncommon::select_level_form($metadatafields{'highestgradelevel'},'highestgradelevel').
              &textfield('Standards','standards',$metadatafields{'standards'});
   
   
   
   
  $scrout.=&hiddenfield('mime',$1);   $scrout.=&hiddenfield('mime',$1);
   
  my $defaultlanguage=$metadatafields{'language'};   my $defaultlanguage=$metadatafields{'language'};
Line 1157  END Line 1200  END
     $metadatafields{'creationdate'}=time;      $metadatafields{'creationdate'}=time;
  }   }
  $scrout.=&hiddenfield('creationdate',   $scrout.=&hiddenfield('creationdate',
       &Apache::loncommon::unsqltime($metadatafields{'creationdate'}));        &Apache::lonmysql::unsqltime($metadatafields{'creationdate'}));
   
  $scrout.=&hiddenfield('lastrevisiondate',time);   $scrout.=&hiddenfield('lastrevisiondate',time);
   
Line 1191  END Line 1234  END
     $scrout.=&textfield('Custom Distribution File','customdistributionfile',      $scrout.=&textfield('Custom Distribution File','customdistributionfile',
  $metadatafields{'customdistributionfile'}).   $metadatafields{'customdistributionfile'}).
     $copyright_help;      $copyright_help;
     my $uctitle=uc(&mt('Obsolete'));      my $uctitle=&mt('Obsolete');
             $scrout.=              $scrout.=
  "\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:".   "\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:".
  '</b></font> <input type="checkbox" name="obsolete" ';   '</b></font> <input type="checkbox" name="obsolete" ';
Line 1315  sub phasetwo { Line 1358  sub phasetwo {
     $metadatafields{'lastrevisiondate'}=$ENV{'form.lastrevisiondate'};      $metadatafields{'lastrevisiondate'}=$ENV{'form.lastrevisiondate'};
     $metadatafields{'owner'}=$ENV{'form.owner'};      $metadatafields{'owner'}=$ENV{'form.owner'};
     $metadatafields{'copyright'}=$ENV{'form.copyright'};      $metadatafields{'copyright'}=$ENV{'form.copyright'};
       $metadatafields{'standards'}=$ENV{'form.standards'};
       $metadatafields{'lowestgradelevel'}=$ENV{'form.lowestgradelevel'};
       $metadatafields{'highestgradelevel'}=$ENV{'form.highestgradelevel'};
     $metadatafields{'customdistributionfile'}=      $metadatafields{'customdistributionfile'}=
                                  $ENV{'form.customdistributionfile'};                                   $ENV{'form.customdistributionfile'};
     $metadatafields{'obsolete'}=$ENV{'form.obsolete'};      $metadatafields{'obsolete'}=$ENV{'form.obsolete'};
     $metadatafields{'obsoletereplacement'}=      $metadatafields{'obsoletereplacement'}=
                         $ENV{'form.obsoletereplacement'};                          $ENV{'form.obsoletereplacement'};
     $metadatafields{'dependencies'}=$ENV{'form.dependencies'};      $metadatafields{'dependencies'}=$ENV{'form.dependencies'};
       $metadatafields{'modifyinguser'}=$ENV{'user.name'}.'@'.
                                    $ENV{'user.domain'};
       $metadatafields{'authorspace'}=$cuname.'@'.$cudom;
           
     my $allkeywords=$ENV{'form.addkey'};      my $allkeywords=$ENV{'form.addkey'};
     if (exists($ENV{'form.keywords'})) {      if (exists($ENV{'form.keywords'})) {
Line 1334  sub phasetwo { Line 1383  sub phasetwo {
     $allkeywords=~s/^\,//;      $allkeywords=~s/^\,//;
     $metadatafields{'keywords'}=$allkeywords;      $metadatafields{'keywords'}=$allkeywords;
           
   # check if custom distribution file is specified
       if ($metadatafields{'copyright'} eq 'custom') {
    my $file=$metadatafields{'customdistributionfile'};
    unless ($file=~/\.rights$/) {
               return 
                   '<font color="red">'.&mt('No valid custom distribution rights file specified, FAIL').
    '</font>';
           }
       }
     {      {
         print $logfile "\nWrite metadata file for ".$source;          print $logfile "\nWrite metadata file for ".$source;
         my $mfh;          my $mfh;
Line 1367  sub phasetwo { Line 1425  sub phasetwo {
   
     $metadatafields{'url'} = $distarget;      $metadatafields{'url'} = $distarget;
     $metadatafields{'version'} = 'current';      $metadatafields{'version'} = 'current';
     unless ($metadatafields{'copyright'} eq 'priv') {  
         my ($error,$success) = &store_metadata(\%metadatafields);      my ($error,$success) = &store_metadata(%metadatafields);
         if ($success) {      if ($success) {
             $r->print('<p>'.&mt('Synchronized SQL metadata database').'</p>');   $r->print('<p>'.&mt('Synchronized SQL metadata database').'</p>');
             print $logfile "\nSynchronized SQL metadata database";   print $logfile "\nSynchronized SQL metadata database";
         } else {  
             $r->print($error);  
             print $logfile "\n".$error;  
         }  
     } else {      } else {
         $r->print('<p>'.   $r->print($error);
      &mt('Private Publication - did not synchronize database').'</p>');   print $logfile "\n".$error;
         print $logfile "\nPrivate: Did not synchronize data into ".  
             "SQL metadata database";  
     }      }
   
 # ----------------------------------------------------------- Copy old versions  # ----------------------------------------------------------- Copy old versions
         
     if (-e $target) {      if (-e $target) {
Line 1539  sub phasetwo { Line 1592  sub phasetwo {
                    '"><font size="+2">'.                     '"><font size="+2">'.
   &mt('Back to Source Directory').'</font></a></p>');    &mt('Back to Source Directory').'</font></a></p>');
     }      }
       return '<p><font color="green">'.&mt('Done').'</font></p>';
 }  }
   
 #########################################  #########################################
Line 1593  sub publishdirectory { Line 1647  sub publishdirectory {
     my $resdir=      my $resdir=
  $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/'.$cudom.'/'.$cuname.'/'.   $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/'.$cudom.'/'.$cuname.'/'.
  $thisdisfn;   $thisdisfn;
     $r->print('<h1>Directory <tt>'.$thisdisfn.'</tt></h1>'.      $r->print('<h1>'.&mt('Directory').' <tt>'.$thisdisfn.'</tt></h1>'.
       'Target: <tt>'.$resdir.'</tt><br />');        &mt('Target').': <tt>'.$resdir.'</tt><br />');
   
     my $dirptr=16384; # Mask indicating a directory in stat.cmode.      my $dirptr=16384; # Mask indicating a directory in stat.cmode.
   
Line 1632  sub publishdirectory { Line 1686  sub publishdirectory {
     if ($publishthis) {      if ($publishthis) {
                 &batchpublish($r,$fn.'/'.$filename,$resdir.'/'.$filename);                  &batchpublish($r,$fn.'/'.$filename,$resdir.'/'.$filename);
     } else {      } else {
  $r->print('<br />Skipping '.$filename.'<br />');   $r->print('<br />'.&mt('Skipping').' '.$filename.'<br />');
     }      }
     $r->rflush();      $r->rflush();
  }   }
Line 1838  ENDDIFF Line 1892  ENDDIFF
     my ($outstring,$error)=&publish($thisfn,$thistarget,$thisembstyle);      my ($outstring,$error)=&publish($thisfn,$thistarget,$thisembstyle);
     $r->print('<hr />'.$outstring);      $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.142  
changed lines
  Added in v.1.158


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