Diff for /loncom/interface/lonmeta.pm between versions 1.64 and 1.66

version 1.64, 2004/04/13 14:42:24 version 1.66, 2004/04/13 16:03:46
Line 104  sub authordisplay { Line 104  sub authordisplay {
 # Pretty display  # Pretty display
 sub evalgraph {  sub evalgraph {
     my $value=shift;      my $value=shift;
     unless ($value) { return ''; }      if (! $value) { 
           return '';
       }
     my $val=int($value*10.+0.5)-10;      my $val=int($value*10.+0.5)-10;
     my $output='<table border=0 cellpadding=0 cellspacing=0><tr>';      my $output='<table border=0 cellpadding=0 cellspacing=0><tr>';
     if ($val>=20) {      if ($val>=20) {
Line 126  sub evalgraph { Line 128  sub evalgraph {
   
 sub diffgraph {  sub diffgraph {
     my $value=shift;      my $value=shift;
     unless ($value) { return ''; }      if (! $value) { 
           return '';
       }
     my $val=int(40.0*$value+0.5);      my $val=int(40.0*$value+0.5);
     my @colors=('#FF9933','#EEAA33','#DDBB33','#CCCC33',      my @colors=('#FF9933','#EEAA33','#DDBB33','#CCCC33',
                 '#BBDD33','#CCCC33','#DDBB33','#EEAA33');                  '#BBDD33','#CCCC33','#DDBB33','#EEAA33');
Line 142  sub diffgraph { Line 146  sub diffgraph {
     return $output;      return $output;
 }  }
   
   #
 # Turn MySQL row into hash  # Turn MySQL row into hash
   #     This routine is here for historic reasons.  Probably should be moved to 
   #     a more generic place since it has nothing to do with metadata
 sub metadata_col_to_hash {  sub metadata_col_to_hash {
     my @cols=@_;      my @cols=@_;
     my %hash=();      my %hash=();
Line 200  sub fieldnames { Line 207  sub fieldnames {
   
 sub prettyprint {  sub prettyprint {
     my ($type,$value)=@_;      my ($type,$value)=@_;
     unless (defined($value)) { return '&nbsp;'; }      if (! defined($value)) { 
           return '&nbsp;'; 
       }
     # Title      # Title
     if ($type eq 'title') {      if ($type eq 'title') {
  return '<font size="+1" face="arial">'.$value.'</font>';   return '<font size="+1" face="arial">'.$value.'</font>';
Line 239  sub prettyprint { Line 248  sub prettyprint {
  return &Apache::loncommon::gradeleveldescription($value);   return &Apache::loncommon::gradeleveldescription($value);
     }      }
     # Only for advance users below      # Only for advance users below
     unless ($ENV{'user.adv'}) { return '<i>- '.&mt('not displayed').' -</i>' };      if (! $ENV{'user.adv'}) { 
           return '<i>- '.&mt('not displayed').' -</i>';
       }
     # File      # File
     if (($type eq 'customdistributionfile') ||      if (($type eq 'customdistributionfile') ||
  ($type eq 'obsoletereplacement') ||   ($type eq 'obsoletereplacement') ||
Line 284  sub direct { Line 295  sub direct {
   
 sub selectbox {  sub selectbox {
     my ($name,$value,$functionref,@idlist)=@_;      my ($name,$value,$functionref,@idlist)=@_;
     unless (defined($functionref)) { $functionref=\&direct; }      if (! defined($functionref)) {
           $functionref=\&direct;
       }
     my $selout='<select name="'.$name.'">';      my $selout='<select name="'.$name.'">';
     foreach (@idlist) {      foreach (@idlist) {
         $selout.='<option value=\''.$_.'\'';          $selout.='<option value=\''.$_.'\'';
Line 298  sub selectbox { Line 311  sub selectbox {
   
 sub relatedfield {  sub relatedfield {
     my ($show,$relatedsearchflag,$relatedsep,$fieldname,$relatedvalue)=@_;      my ($show,$relatedsearchflag,$relatedsep,$fieldname,$relatedvalue)=@_;
     unless ($relatedsearchflag) { return ''; }      if (! $relatedsearchflag) { 
     unless (defined($relatedsep)) { $relatedsep=' '; }          return '';
     unless ($show) { return $relatedsep.'&nbsp;'; }      }
       if (! defined($relatedsep)) {
           $relatedsep=' ';
       }
       if (! $show) {
           return $relatedsep.'&nbsp;';
       }
     return $relatedsep.'<input type="checkbox" name="'.$fieldname.'_related"'.      return $relatedsep.'<input type="checkbox" name="'.$fieldname.'_related"'.
  ($relatedvalue?' checked="1"':'').' />';   ($relatedvalue?' checked="1"':'').' />';
 }  }
Line 380  sub handler { Line 399  sub handler {
     #      #
     my $uri=$r->uri;      my $uri=$r->uri;
     #      #
     # Looking for all bombs?      if ($uri=~m:/adm/bombs/(.*)$:) {
     if ($uri=~/\/adm\/bombs\/(.*)$/) {          # Looking for all bombs?
         # Set document type          &report_bombs($r,$uri);
         $uri=&Apache::lonnet::declutter($1);      } elsif ($uri=~/^\/\~/) { 
         &Apache::loncommon::content_type($r,'text/html');          # Construction space
         $r->send_http_header;          &present_editable_metadata($r,$uri);
         #      } else {
         return OK if $r->header_only;          &present_uneditable_metadata($r,$uri);
         $r->print(&Apache::loncommon::bodytag('Error Messages'));      }
         $r->print('<h1>'.&Apache::lonnet::clutter($uri).'</h1>');      return OK;
         my ($domain,$author)=($uri=~/^(\w+)\/(\w+)\//);  }
         if (&Apache::loncacc::constructaccess('/~'.$author.'/',$domain)) {  
             my %brokenurls=&Apache::lonmsg::all_url_author_res_msg($author,  sub report_bombs {
                                                                    $domain);      my ($r,$uri) = @_;
             foreach (sort keys %brokenurls) {      # Set document type
                 if ($_=~/^\Q$uri\E/) {      $uri=~ s:/adm/bombs/::;
                     $r->print(&Apache::lonhtmlcommon::crumbs      $uri=&Apache::lonnet::declutter($uri);
                               (&Apache::lonnet::clutter($_)).      &Apache::loncommon::content_type($r,'text/html');
                               &Apache::lonmsg::retrieve_author_res_msg($_).      $r->send_http_header;
                               '<hr />');      #
                 }      return OK if $r->header_only;
       $r->print(&Apache::loncommon::bodytag('Error Messages'));
       $r->print('<h1>'.&Apache::lonnet::clutter($uri).'</h1>');
       my ($domain,$author)=($uri=~/^(\w+)\/(\w+)\//);
       if (&Apache::loncacc::constructaccess('/~'.$author.'/',$domain)) {
           my %brokenurls=&Apache::lonmsg::all_url_author_res_msg($author,
                                                                  $domain);
           foreach (sort keys %brokenurls) {
               if ($_=~/^\Q$uri\E/) {
                   $r->print(&Apache::lonhtmlcommon::crumbs
                             (&Apache::lonnet::clutter($_)).
                             &Apache::lonmsg::retrieve_author_res_msg($_).
                             '<hr />');
             }              }
         } else {  
             $r->print(&mt('Not authorized'));  
         }  
         $r->print('</body></html>');  
     } elsif ($uri!~/^\/\~/) {   
         # This is not in construction space  
         my ($resdomain,$resuser)=  
             (&Apache::lonnet::declutter($uri)=~/^(\w+)\/(\w+)\//);  
         $loaderror=&Apache::lonnet::overloaderror  
             ($r,  
              &Apache::lonnet::homeserver($resuser,$resdomain));  
         if ($loaderror) { return $loaderror; }  
         #  
         my %content=();  
         # Set document type  
         &Apache::loncommon::content_type($r,'text/html');  
         $r->send_http_header;  
         return OK if $r->header_only;  
         # Read file  
         foreach (split(/\,/,&Apache::lonnet::metadata($uri,'keys'))) {  
             $content{$_}=&Apache::lonnet::metadata($uri,$_);  
         }          }
         # Render Output      } else {
         # displayed url          $r->print(&mt('Not authorized'));
         my ($thisversion)=($uri=~/\.(\d+)\.(\w+)\.meta$/);      }
         $uri=~s/\.meta$//;      $r->print('</body></html>');
         my $disuri=&Apache::lonnet::clutter($uri);      return;
         # version  }
         my $currentversion=&Apache::lonnet::getversion($disuri);  
         my $versiondisplay='';  sub present_uneditable_metadata {
         if ($thisversion) {      my ($r,$uri) = @_;
             $versiondisplay=&mt('Version').': '.$thisversion.      my ($resdomain,$resuser)=
                 ' ('.&mt('most recent version').': '.          (&Apache::lonnet::declutter($uri)=~/^(\w+)\/(\w+)\//);
                 ($currentversion>0 ?       my $loaderror=&Apache::lonnet::overloaderror
                  $currentversion   :          ($r,
                  &mt('information not available')).')';           &Apache::lonnet::homeserver($resuser,$resdomain));
         } else {      if ($loaderror) { 
             $versiondisplay='Version: '.$currentversion;          return $loaderror;
         }      }
         # crumbify displayed URL      #
         $disuri=&Apache::lonhtmlcommon::crumbs($disuri);      my %content=();
         # obsolete      # Set document type
         my $obsolete=$content{'obsolete'};      &Apache::loncommon::content_type($r,'text/html');
         my $obsoletewarning='';      $r->send_http_header;
         if (($obsolete) && ($ENV{'user.adv'})) {      return OK if $r->header_only;
             $obsoletewarning='<p><font color="red">'.      # Read file
                 &mt('This resource has been marked obsolete by the author(s)').      foreach (split(/\,/,&Apache::lonnet::metadata($uri,'keys'))) {
                 '</font></p>';          $content{$_}=&Apache::lonnet::metadata($uri,$_);
         }      }
         #      # Render Output
         my %lt=&fieldnames();      # displayed url
         my $table='';      my ($thisversion)=($uri=~/\.(\d+)\.(\w+)\.meta$/);
         my $bodytag=&Apache::loncommon::bodytag      $uri=~s/\.meta$//;
             ('Catalog Information','','','',$resdomain);      my $disuri=&Apache::lonnet::clutter($uri);
         foreach ('title',       # version
                  'author',       my $currentversion=&Apache::lonnet::getversion($disuri);
                  'subject',       my $versiondisplay='';
                  'keywords',       if ($thisversion) {
                  'notes',           $versiondisplay=&mt('Version').': '.$thisversion.
                  'abstract',              ' ('.&mt('most recent version').': '.
                  'lowestgradelevel',              ($currentversion>0 ? 
                  'highestgradelevel',               $currentversion   :
                  'standards',                &mt('information not available')).')';
                  'mime',       } else {
                  'language',           $versiondisplay='Version: '.$currentversion;
                  'creationdate',       }
                  'lastrevisiondate',       # crumbify displayed URL
                  'owner',       $disuri=&Apache::lonhtmlcommon::crumbs($disuri);
                  'copyright',       # obsolete
                  'customdistributionfile',       my $obsolete=$content{'obsolete'};
                  'obsolete',       my $obsoletewarning='';
                  'obsoletereplacement') {      if (($obsolete) && ($ENV{'user.adv'})) {
             $table.='<tr><td bgcolor="#AAAAAA">'.$lt{$_}.          $obsoletewarning='<p><font color="red">'.
         '</td><td bgcolor="#CCCCCC">'.              &mt('This resource has been marked obsolete by the author(s)').
                 &prettyprint($_,$content{$_}).'</td></tr>';              '</font></p>';
             delete $content{$_};      }
         }      #
         #      my %lt=&fieldnames();
         $r->print(<<ENDHEAD);      my $table='';
       my $bodytag=&Apache::loncommon::bodytag
           ('Catalog Information','','','',$resdomain);
       foreach ('title', 
                'author', 
                'subject', 
                'keywords', 
                'notes', 
                'abstract',
                'lowestgradelevel',
                'highestgradelevel',
                'standards', 
                'mime', 
                'language', 
                'creationdate', 
                'lastrevisiondate', 
                'owner', 
                'copyright', 
                'customdistributionfile', 
                'obsolete', 
                'obsoletereplacement') {
           $table.='<tr><td bgcolor="#AAAAAA">'.$lt{$_}.
               '</td><td bgcolor="#CCCCCC">'.
               &prettyprint($_,$content{$_}).'</td></tr>';
           delete $content{$_};
       }
       #
       $r->print(<<ENDHEAD);
 <html><head><title>Catalog Information</title></head>  <html><head><title>Catalog Information</title></head>
 $bodytag  $bodytag
 <h2>$content{'title'}</h2>  <h2>$content{'title'}</h2>
Line 491  $versiondisplay<br /> Line 528  $versiondisplay<br />
 $table  $table
 </table>  </table>
 ENDHEAD  ENDHEAD
         if ($ENV{'user.adv'}) {      if ($ENV{'user.adv'}) {
             # Dynamic Metadata          # Dynamic Metadata
           $r->print(
                     '<h3>'.&mt('Dynamic Metadata').' ('.
                     &mt('updated periodically').')</h3>'.&mt('Processing').
                     ' ...<br />');
           $r->rflush();
           my %items=&fieldnames();
           my %dynmeta=&dynamicmeta($uri);
           # General Access and Usage Statistics
           $r->print('<h4>'.&mt('Access and Usage Statistics').'</h4>'.
                     '<table cellspacing=2 border=0>');
           foreach ('count',
                    'sequsage','sequsage_list',
                    'comefrom','comefrom_list',
                    'goto','goto_list',
                    'course','course_list') {
               $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td>'.
                         '<td bgcolor="#CCCCCC">'.
                         &prettyprint($_,$dynmeta{$_})."</td></tr>\n");
           }
           $r->print('</table>');
           if ($uri=~/\.(problem|exam|quiz|assess|survey|form)\.meta$/) {
               # This is an assessment, print assessment data
             $r->print(              $r->print(
                       '<h3>'.&mt('Dynamic Metadata').' ('.                        '<h4>'.&mt('Assessment Statistical Data').'</h4>'.
                       &mt('updated periodically').')</h3>'.&mt('Processing').  
                       ' ...<br />');  
             $r->rflush();  
             my %items=&fieldnames();  
             my %dynmeta=&dynamicmeta($uri);  
             # General Access and Usage Statistics  
             $r->print('<h4>'.&mt('Access and Usage Statistics').'</h4>'.  
                       '<table cellspacing=2 border=0>');  
             foreach ('count',  
                      'sequsage','sequsage_list',  
                      'comefrom','comefrom_list',  
                      'goto','goto_list',  
                      'course','course_list') {  
                 $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td>'.  
                           '<td bgcolor="#CCCCCC">'.  
                           &prettyprint($_,$dynmeta{$_})."</td></tr>\n");  
             }  
             $r->print('</table>');  
             if ($uri=~/\.(problem|exam|quiz|assess|survey|form)\.meta$/) {  
                 # This is an assessment, print assessment data  
                 $r->print(  
                           '<h4>'.&mt('Assessment Statistical Data').'</h4>'.  
                           '<table cellspacing=2 border=0>');  
                 foreach ('stdno','avetries','difficulty') {  
                     $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td>'.  
                               '<td bgcolor="#CCCCCC">'.  
                               &prettyprint($_,$dynmeta{$_})."</td></tr>\n");  
                 }  
                 $r->print('</table>');      
             }  
             $r->print('<h4>'.&mt('Evaluation Data').'</h4>'.  
                       '<table cellspacing=2 border=0>');                        '<table cellspacing=2 border=0>');
             foreach ('clear','depth','helpful','correct','technical') {              foreach ('stdno','avetries','difficulty') {
                 $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td>'.                  $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td>'.
                           '<td bgcolor="#CCCCCC">'.                            '<td bgcolor="#CCCCCC">'.
                           &prettyprint($_,$dynmeta{$_})."</td></tr>\n");                            &prettyprint($_,$dynmeta{$_})."</td></tr>\n");
             }              }
             $r->print('</table>');              $r->print('</table>');    
             $uri=~/^\/res\/(\w+)\/(\w+)\//;           }
             if ((($ENV{'user.domain'} eq $1) && ($ENV{'user.name'} eq $2))          $r->print('<h4>'.&mt('Evaluation Data').'</h4>'.
                 || ($ENV{'user.role.ca./'.$1.'/'.$2})) {                    '<table cellspacing=2 border=0>');
                 $r->print('<h4>'.&mt('Evaluation Comments').' ('.          foreach ('clear','depth','helpful','correct','technical') {
                           &mt('visible to author and co-authors only').              $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td>'.
                           ')</h4>'.                        '<td bgcolor="#CCCCCC">'.
                           '<blockquote>'.$dynmeta{'comments'}.'</blockquote>');                        &prettyprint($_,$dynmeta{$_})."</td></tr>\n");
                 $r->print('<a name="bombs" /><h4>'.&mt('Error Messages').' ('.          }
                           &mt('visible to author and co-authors only').')'.          $r->print('</table>');
                           '</h4>'.          $uri=~/^\/res\/(\w+)\/(\w+)\//; 
                           &Apache::lonmsg::retrieve_author_res_msg($uri));          if ((($ENV{'user.domain'} eq $1) && ($ENV{'user.name'} eq $2))
             }              || ($ENV{'user.role.ca./'.$1.'/'.$2})) {
             # All other stuff              $r->print('<h4>'.&mt('Evaluation Comments').' ('.
             $r->print('<h3>'.                        &mt('visible to author and co-authors only').
                 &mt('Additional Metadata (non-standard, parameters, exports)').                        ')</h4>'.
                       '</h3>');                        '<blockquote>'.$dynmeta{'comments'}.'</blockquote>');
             foreach (sort keys %content) {              $r->print('<a name="bombs" /><h4>'.&mt('Error Messages').' ('.
                 my $name=$_;                        &mt('visible to author and co-authors only').')'.
                 unless ($name=~/\.display$/) {                        '</h4>'.
                     my $display=&Apache::lonnet::metadata($uri,                        &Apache::lonmsg::retrieve_author_res_msg($uri));
                                                           $name.'.display');          }
                     unless ($display) { $display=$name; };          # All other stuff
                     my $otherinfo='';          $r->print('<h3>'.
                     foreach ('name','part','type','default') {                    &mt('Additional Metadata (non-standard, parameters, exports)').
                         if (defined(&Apache::lonnet::metadata($uri,                    '</h3>');
                                                               $name.'.'.$_))) {          foreach (sort keys %content) {
                             $otherinfo.=' '.$_.'='.              my $name=$_;
                                 &Apache::lonnet::metadata($uri,              if ($name!~/\.display$/) {
                                                           $name.'.'.$_).'; ';                  my $display=&Apache::lonnet::metadata($uri,
                         }                                                        $name.'.display');
                     }                  if (! $display) { 
                     $r->print('<b>'.$display.':</b> '.$content{$name});                      $display=$name;
                     if ($otherinfo) {                  };
                         $r->print(' ('.$otherinfo.')');                  my $otherinfo='';
                   foreach ('name','part','type','default') {
                       if (defined(&Apache::lonnet::metadata($uri,
                                                             $name.'.'.$_))) {
                           $otherinfo.=' '.$_.'='.
                               &Apache::lonnet::metadata($uri,
                                                         $name.'.'.$_).'; ';
                     }                      }
                     $r->print("<br />\n");  
                 }                  }
                   $r->print('<b>'.$display.':</b> '.$content{$name});
                   if ($otherinfo) {
                       $r->print(' ('.$otherinfo.')');
                   }
                   $r->print("<br />\n");
             }              }
         }          }
         # End Resource Space Call      }
     } else {  }
         # Construction Space Call  
         # Set document type  sub present_editable_metadata {
         &Apache::loncommon::content_type($r,'text/html');      my ($r,$uri) = @_;
         $r->send_http_header;      # Construction Space Call
         #      # Set document type
         return OK if $r->header_only;      &Apache::loncommon::content_type($r,'text/html');
         # Header      $r->send_http_header;
         my $disuri=$uri;      #
         my $fn=&Apache::lonnet::filelocation('',$uri);      return OK if $r->header_only;
         $disuri=~s/^\/\~/\/priv\//;      # Header
         $disuri=~s/\.meta$//;      my $disuri=$uri;
         my $target=$uri;      my $fn=&Apache::lonnet::filelocation('',$uri);
         $target=~s/^\/\~/\/res\/$ENV{'request.role.domain'}\//;      $disuri=~s/^\/\~/\/priv\//;
         $target=~s/\.meta$//;      $disuri=~s/\.meta$//;
         my $bombs=&Apache::lonmsg::retrieve_author_res_msg($target);      my $target=$uri;
         if ($bombs) {      $target=~s/^\/\~/\/res\/$ENV{'request.role.domain'}\//;
             if ($ENV{'form.delmsg'}) {      $target=~s/\.meta$//;
                 if (&Apache::lonmsg::del_url_author_res_msg($target) eq 'ok') {      my $bombs=&Apache::lonmsg::retrieve_author_res_msg($target);
                     $bombs=&mt('Messages deleted.');      if ($bombs) {
                 } else {          if ($ENV{'form.delmsg'}) {
                     $bombs=&mt('Error deleting messages');              if (&Apache::lonmsg::del_url_author_res_msg($target) eq 'ok') {
                 }                  $bombs=&mt('Messages deleted.');
               } else {
                   $bombs=&mt('Error deleting messages');
             }              }
             my $bodytag=&Apache::loncommon::bodytag('Error Messages');          }
             my $del=&mt('Delete Messages');          my $bodytag=&Apache::loncommon::bodytag('Error Messages');
             $r->print(<<ENDBOMBS);          my $del=&mt('Delete Messages');
           $r->print(<<ENDBOMBS);
 <html><head><title>Edit Catalog Information</title></head>  <html><head><title>Edit Catalog Information</title></head>
 $bodytag  $bodytag
 <h1>$disuri</h1>  <h1>$disuri</h1>
Line 610  $bodytag Line 651  $bodytag
 </body>  </body>
 </html>  </html>
 ENDBOMBS  ENDBOMBS
         } else {      } else {
             my $displayfile='Catalog Information for '.$disuri;          my $displayfile='Catalog Information for '.$disuri;
             if ($disuri=~/\/default$/) {          if ($disuri=~/\/default$/) {
                 my $dir=$disuri;              my $dir=$disuri;
                 $dir=~s/default$//;              $dir=~s/default$//;
                 $displayfile=              $displayfile=
                     &mt('Default Cataloging Information for Directory').' '.                  &mt('Default Cataloging Information for Directory').' '.
                     $dir;                  $dir;
             }          }
             my $bodytag=          my $bodytag=
                 &Apache::loncommon::bodytag('Edit Catalog Information');              &Apache::loncommon::bodytag('Edit Catalog Information');
             %Apache::lonpublisher::metadatafields=();          %Apache::lonpublisher::metadatafields=();
             %Apache::lonpublisher::metadatakeys=();          %Apache::lonpublisher::metadatakeys=();
             &Apache::lonpublisher::metaeval(&Apache::lonnet::getfile($fn));          &Apache::lonpublisher::metaeval(&Apache::lonnet::getfile($fn));
             $r->print(<<ENDEDIT);          $r->print(<<ENDEDIT);
 <html><head><title>Edit Catalog Information</title></head>  <html><head><title>Edit Catalog Information</title></head>
 $bodytag  $bodytag
 <h1>$displayfile</h1>  <h1>$displayfile</h1>
 <form method="post" name="defaultmeta">  <form method="post" name="defaultmeta">
 ENDEDIT  ENDEDIT
             $r->print('<script language="JavaScript">'.          $r->print('<script language="JavaScript">'.
                       &Apache::loncommon::browser_and_searcher_javascript.                    &Apache::loncommon::browser_and_searcher_javascript.
                       '</script>');                    '</script>');
             my %lt=&fieldnames();          my %lt=&fieldnames();
             foreach ('author','title','subject','keywords','abstract','notes',          foreach ('author','title','subject','keywords','abstract','notes',
                      'copyright','customdistributionfile','language',                   'copyright','customdistributionfile','language',
                      'standards',                   'standards',
                      'lowestgradelevel','highestgradelevel',                   'lowestgradelevel','highestgradelevel',
                      'obsolete','obsoletereplacement') {                   'obsolete','obsoletereplacement') {
                 if (defined($ENV{'form.new_'.$_})) {              if (defined($ENV{'form.new_'.$_})) {
                     $Apache::lonpublisher::metadatafields{$_}=                  $Apache::lonpublisher::metadatafields{$_}=
                         $ENV{'form.new_'.$_};                      $ENV{'form.new_'.$_};
                 }              }
                 unless ($Apache::lonpublisher::metadatafields{'copyright'}) {              if (! $Apache::lonpublisher::metadatafields{'copyright'}) {
                     $Apache::lonpublisher::metadatafields{'copyright'}=                  $Apache::lonpublisher::metadatafields{'copyright'}=
                         'default';                      'default';
                 }  
                 $r->print('<p>'.$lt{$_}.': '.  
                           &prettyinput  
                           ($_,$Apache::lonpublisher::metadatafields{$_},  
                            'new_'.$_,'defaultmeta').'</p>');  
             }              }
             if ($ENV{'form.store'}) {              $r->print('<p>'.$lt{$_}.': '.
                 my $mfh;                        &prettyinput
                 unless ($mfh=Apache::File->new('>'.$fn)) {                        ($_,$Apache::lonpublisher::metadatafields{$_},
                     $r->print('<p><font color=red>'.                         'new_'.$_,'defaultmeta').'</p>');
                               &mt('Could not write metadata').', '.          }
                               &mt('FAIL').'</font>');          if ($ENV{'form.store'}) {
                 } else {              my $mfh;
                     foreach (sort keys %Apache::lonpublisher::metadatafields) {              if (!  ($mfh=Apache::File->new('>'.$fn))) {
                         unless ($_=~/\./) {                  $r->print('<p><font color=red>'.
                             my $unikey=$_;                            &mt('Could not write metadata').', '.
                             $unikey=~/^([A-Za-z]+)/;                            &mt('FAIL').'</font>');
                             my $tag=$1;              } else {
                             $tag=~tr/A-Z/a-z/;                  foreach (sort keys %Apache::lonpublisher::metadatafields) {
                             print $mfh "\n\<$tag";                      if ($_!~/\./) {
                             foreach (split(/\,/,                          my $unikey=$_;
                           $unikey=~/^([A-Za-z]+)/;
                           my $tag=$1;
                           $tag=~tr/A-Z/a-z/;
                           print $mfh "\n\<$tag";
                           foreach (split(/\,/,
                                  $Apache::lonpublisher::metadatakeys{$unikey})                                   $Apache::lonpublisher::metadatakeys{$unikey})
                                      ) {                                   ) {
                                 my $value=                              my $value=
                         $Apache::lonpublisher::metadatafields{$unikey.'.'.$_};                          $Apache::lonpublisher::metadatafields{$unikey.'.'.$_};
                                 $value=~s/\"/\'\'/g;                              $value=~s/\"/\'\'/g;
                                 print $mfh ' '.$_.'="'.$value.'"';                              print $mfh ' '.$_.'="'.$value.'"';
                             }  
                             print $mfh '>'.  
                                 &HTML::Entities::encode($Apache::lonpublisher::metadatafields{$unikey},'<>&"').  
                                 '</'.$tag.'>';  
                         }                          }
                           print $mfh '>'.
                               &HTML::Entities::encode
                               ($Apache::lonpublisher::metadatafields{$unikey},
                                '<>&"').
                                '</'.$tag.'>';
                     }                      }
                     $r->print('<p>'.&mt('Wrote Metadata'));  
                 }                  }
                   $r->print('<p>'.&mt('Wrote Metadata'));
             }              }
             $r->print('<br /><input type="submit" name="store" value="'.  
                       &mt('Store Catalog Information').'"></form>'.  
                       '</body></html>');  
         }          }
           $r->print('<br /><input type="submit" name="store" value="'.
                     &mt('Store Catalog Information').'"></form>'.
                     '</body></html>');
     }      }
     return OK;      return;
 }  }
   
 # BEGIN Block  # BEGIN Block

Removed from v.1.64  
changed lines
  Added in v.1.66


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