Diff for /loncom/publisher/lonpublisher.pm between versions 1.239 and 1.245

version 1.239, 2008/06/30 18:10:24 version 1.245, 2008/08/14 13:39:02
Line 118  use Apache::File; Line 118  use Apache::File;
 use File::Copy;  use File::Copy;
 use Apache::Constants qw(:common :http :methods);  use Apache::Constants qw(:common :http :methods);
 use HTML::LCParser;  use HTML::LCParser;
   use HTML::Entities;
   use Encode::Encoder;
 use Apache::lonxml;  use Apache::lonxml;
 use Apache::loncacc;  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 325  string which presents the form field (fo Line 328  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 336  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 355  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 886  sub checkonthis { Line 889  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 1167  sub publish { Line 1174  sub publish {
  $textonly=~s/\<script[^\<]+\<\/script\>//g;   $textonly=~s/\<script[^\<]+\<\/script\>//g;
  $textonly=~s/\<m\>[^\<]+\<\/m\>//g;   $textonly=~s/\<m\>[^\<]+\<\/m\>//g;
  $textonly=~s/\<[^\>]*\>//g;   $textonly=~s/\<[^\>]*\>//g;
  $textonly=~tr/A-Z/a-z/;  
  $textonly=~s/[\$\&][a-z]\w*//g;  
  $textonly=~s/[^a-z\s]//g;  
   
  foreach ($textonly=~m/(\w+)/g) {  
     unless ($nokey{$_}) {  
  $keywords{$_}=1;  
     }   
  }  
     }  
   
           #this is a work simplification for german authors for present
           $textonly=HTML::Entities::decode($textonly);           #decode HTML-character
           $textonly=Encode::Encoder::encode('utf8', $textonly);  #encode to perl internal unicode
           $textonly=~tr/A-ZÜÄÖ/a-züäö/;      #add lowercase rule for german "Umlaute"
           $textonly=~s/[\$\&][a-z]\w*//g;
           $textonly=~s/[^a-z^ü^ä^ö^ß\s]//g;  #dont delete german "Umlaute"
   
           foreach ($textonly=~m/[^\s]+/g) {  #match all but whitespaces
               unless ($nokey{$_}) {
                   $keywords{$_}=1;
               }
           }
   
   
       }
                           
     foreach my $addkey (split(/[\"\'\,\;]/,$metadatafields{'keywords'})) {      foreach my $addkey (split(/[\"\'\,\;]/,$metadatafields{'keywords'})) {
  $addkey=~s/\s+/ /g;   $addkey=~s/\s+/ /g;
Line 1237  END Line 1249  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) {
    $colcount++;
  $keywordout.='<td><label><input type="checkbox" name="keywords" value="'.$_.'"';   $keywordout.='<td><label><input type="checkbox" name="keywords" value="'.$_.'"';
  if ($metadatafields{'keywords'}) {   if ($metadatafields{'keywords'}) {
     if ($metadatafields{'keywords'}=~/\Q$_\E/) {      if ($metadatafields{'keywords'}=~/\Q$_\E/) {
Line 1252  END Line 1267  END
     $env{'form.keywords'}.=$_.',';      $env{'form.keywords'}.=$_.',';
  }   }
  $keywordout.=' />'.$_.'</label></td>';   $keywordout.=' />'.$_.'</label></td>';
  if ($colcount>10) {   if ($colcount>=10) {
     $keywordout.="</tr><tr>\n";      $keywordout.=&Apache::loncommon::end_data_table_row()
                           .&Apache::loncommon::start_data_table_row();
     $colcount=0;      $colcount=0;
  }   }
  $colcount++;  
     }      }
       # Proper end of started table row:
       if ($colcount != 0) { # has still to be improved: if amount of keywords mod 10 == 0, then do not start another table row
           while ($colcount<10) {
               $keywordout.='<td>&nbsp;</td>';
               $colcount++;
           }
       }
   
     $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 1309  END Line 1333  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 1362  END Line 1389  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 1388  END Line 1415  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
Line 2148  ENDCAPTION Line 2175  ENDCAPTION
   
         $r->print(&Apache::lonhtmlcommon::row_title(&mt('Target'))          $r->print(&Apache::lonhtmlcommon::row_title(&mt('Target'))
                  .'<tt>'.$thisdistarget.'</tt>'                   .'<tt>'.$thisdistarget.'</tt>'
                  .&Apache::lonhtmlcommon::row_closure()  
                  );                   );
   
 # SB - ToDo:     # 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(&Apache::lonhtmlcommon::row_title('<span class="LC_warning">'.&mt('Co-Author').'</span>')  #           $r->print(&Apache::lonhtmlcommon::row_title('<span class="LC_warning">'.&mt('Co-Author').'</span>')
             $r->print(&Apache::lonhtmlcommon::row_title(&mt('Co-Author'))              $r->print(&Apache::lonhtmlcommon::row_closure()
                        .&Apache::lonhtmlcommon::row_title(&mt('Co-Author'))
                      .'<span class="LC_warning">'                       .'<span class="LC_warning">'
      .&mt('[_1] at [_2]',$cuname,$cudom)       .&mt('[_1] at [_2]',$cuname,$cudom)
                      .'</span>'                       .'</span>'
                      .&Apache::lonhtmlcommon::row_closure()  
                      );                       );
  }   }
   
  if (&Apache::loncommon::fileembstyle($thistype) eq 'ssi') {   if (&Apache::loncommon::fileembstyle($thistype) eq 'ssi') {
             $r->print(&Apache::lonhtmlcommon::row_title(&mt('Diffs')));              $r->print(&Apache::lonhtmlcommon::row_closure()
                        .&Apache::lonhtmlcommon::row_title(&mt('Diffs')));
     $r->print(<<ENDDIFF);      $r->print(<<ENDDIFF);
 <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>'              $r->print(&mt('Diffs with Current Version').'</a>');
                      .&Apache::lonhtmlcommon::row_closure()  
                      );  
   
  }   }
           
         $r->print(&Apache::lonhtmlcommon::end_pick_box());          $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.
   

Removed from v.1.239  
changed lines
  Added in v.1.245


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