Annotation of loncom/interface/lonmeta.pm, revision 1.33

1.1       www         1: # The LearningOnline Network with CAPA
1.8       albertel    2: # Metadata display handler
                      3: #
1.33    ! www         4: # $Id: lonmeta.pm,v 1.32 2003/06/30 17:17:30 albertel Exp $
1.8       albertel    5: #
                      6: # Copyright Michigan State University Board of Trustees
                      7: #
                      8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      9: #
                     10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
1.1       www        14: #
1.8       albertel   15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
1.1       www        27: #
                     28: # (TeX Content Handler
                     29: #
                     30: # 05/29/00,05/30,10/11 Gerd Kortemeyer)
                     31: #
1.13      www        32: # 10/19,10/21,10/23,11/27,08/09/01,12/22,12/24,12/25 Gerd Kortemeyer
1.1       www        33: 
                     34: package Apache::lonmeta;
                     35: 
                     36: use strict;
                     37: use Apache::Constants qw(:common);
1.3       www        38: use Apache::lonnet();
1.10      www        39: use Apache::loncommon();
1.23      www        40: use Apache::lonmsg;
                     41: use Apache::lonpublisher;
1.1       www        42: 
1.9       www        43: # ----------------------------------------- Fetch and evaluate dynamic metadata
                     44: 
                     45: sub dynamicmeta {
                     46:     my $url=&Apache::lonnet::declutter(shift);
                     47:     $url=~s/\.meta$//;
                     48:     my ($adomain,$aauthor)=($url=~/^(\w+)\/(\w+)\//);
1.19      www        49:     my $regexp=$url;
1.9       www        50:     $regexp=~s/(\W)/\\$1/g;
1.10      www        51:     $regexp='___'.$regexp.'___';
1.16      albertel   52:     my %evaldata=&Apache::lonnet::dump('nohist_resevaldata',$adomain,
                     53: 				       $aauthor,$regexp);
1.30      www        54:     my %sum=();
                     55:     my %cnt=();
                     56:     my %concat=();
1.10      www        57:     my %listitems=('count'        => 'add',
                     58:                    'course'       => 'add',
1.29      www        59:                    'goto'         => 'add',
                     60:                    'comefrom'     => 'add',
1.10      www        61:                    'avetries'     => 'avg',
                     62:                    'stdno'        => 'add',
                     63:                    'difficulty'   => 'avg',
                     64:                    'clear'        => 'avg',
                     65:                    'technical'    => 'avg',
                     66:                    'helpful'      => 'avg',
                     67:                    'correct'      => 'avg',
                     68:                    'depth'        => 'avg',
                     69:                    'comments'     => 'app',
                     70:                    'usage'        => 'cnt'
                     71:                    );
                     72:     foreach (keys %evaldata) {
1.30      www        73: 	my ($item,$purl,$cat)=split(/\_\_\_/,$_);
                     74: ###	print "\n".$_.' - '.$item.'<br />';
                     75:         if (defined($cnt{$cat})) { $cnt{$cat}++; } else { $cnt{$cat}=1; }
                     76:         unless ($listitems{$cat} eq 'app') {
                     77:             if (defined($sum{$cat})) {
                     78:                $sum{$cat}+=$evaldata{$_};
                     79:                $concat{$cat}.=','.$item;
1.10      www        80: 	    } else {
1.30      www        81:                $sum{$cat}=$evaldata{$_};
                     82:                $concat{$cat}=$item;
1.10      www        83: 	    }
                     84:         } else {
1.30      www        85:             if (defined($sum{$cat})) {
1.10      www        86:                if ($evaldata{$_}) {
1.30      www        87:                   $sum{$cat}.='<hr>'.$evaldata{$_};
1.10      www        88: 	       }
                     89:  	    } else {
1.30      www        90: 	       $sum{$cat}=''.$evaldata{$_};
1.10      www        91: 	    }
                     92: 	}
                     93:     }
1.9       www        94:     my %returnhash=();
1.10      www        95:     foreach (keys %cnt) {
1.11      www        96:        if ($listitems{$_} eq 'avg') {
                     97: 	   $returnhash{$_}=int(($sum{$_}/$cnt{$_})*100.0+0.5)/100.0;
                     98:        } elsif ($listitems{$_} eq 'cnt') {
                     99:            $returnhash{$_}=$cnt{$_};
                    100:        } else {
                    101:            $returnhash{$_}=$sum{$_};
                    102:        }
1.30      www       103:        $returnhash{$_.'_list'}=$concat{$_};
                    104: ### print "\n<hr />".$_.': '.$returnhash{$_}.'<br />'.$returnhash{$_.'_list'};
1.9       www       105:     }
                    106:     return %returnhash;
1.25      www       107: }
                    108: 
                    109: # ------------------------------------- Try to make an alt tag if there is none
                    110: 
                    111: sub alttag {
1.26      www       112:     my ($base,$src)=@_;
                    113:     my $fullpath=&Apache::lonnet::hreflocation($base,$src);
                    114:     my $alttag=&Apache::lonnet::metadata($fullpath,'title').' '.
                    115:                &Apache::lonnet::metadata($fullpath,'subject').' '.
                    116:                &Apache::lonnet::metadata($fullpath,'abstract');
                    117:     $alttag=~s/\s+/ /gs;
                    118:     $alttag=~s/\"//gs;
                    119:     $alttag=~s/\'//gs;
                    120:     $alttag=~s/\s+$//gs;
                    121:     $alttag=~s/^\s+//gs;
                    122:     if ($alttag) { return $alttag; } else 
                    123:                  { return 'No information available'; }
1.9       www       124: }
1.1       www       125: 
1.29      www       126: # -------------------------------------------------------------- Author display
                    127: 
                    128: sub authordisplay {
                    129:     my ($aname,$adom)=@_;
                    130:     return &Apache::loncommon::aboutmewrapper(
                    131:                 &Apache::loncommon::plainname($aname,$adom),
                    132:                     $aname,$adom).' <tt>['.$aname.'@'.$adom.']</tt>';
                    133: }
                    134: 
1.12      www       135: # -------------------------------------------------------------- Pretty display
                    136: 
                    137: sub evalgraph {
                    138:     my $value=shift;
1.13      www       139:     unless ($value) { return ''; }
1.12      www       140:     my $val=int($value*10.+0.5)-10;
                    141:     my $output='<table border=0 cellpadding=0 cellspacing=0><tr>';
                    142:     if ($val>=20) {
                    143: 	$output.='<td width=20 bgcolor="#555555">&nbsp&nbsp;</td>';
                    144:     } else {
                    145:         $output.='<td width='.($val).' bgcolor="#555555">&nbsp;</td>'.
                    146:                  '<td width='.(20-$val).' bgcolor="#FF3333">&nbsp;</td>';
                    147:     }
                    148:     $output.='<td bgcolor="#FFFF33">&nbsp;</td>';
                    149:     if ($val>20) {
                    150: 	$output.='<td width='.($val-20).' bgcolor="#33FF33">&nbsp;</td>'.
                    151:                  '<td width='.(40-$val).' bgcolor="#555555">&nbsp;</td>';
                    152:     } else {
                    153:        $output.='<td width=20 bgcolor="#555555">&nbsp&nbsp;</td>';
                    154:     }
                    155:     $output.='<td> ('.$value.') </td></tr></table>';
                    156:     return $output;
                    157: }
                    158: 
                    159: sub diffgraph {
                    160:     my $value=shift;
1.13      www       161:     unless ($value) { return ''; }
1.12      www       162:     my $val=int(40.0*$value+0.5);
1.13      www       163:     my @colors=('#FF9933','#EEAA33','#DDBB33','#CCCC33',
                    164:                 '#BBDD33','#CCCC33','#DDBB33','#EEAA33');
1.12      www       165:     my $output='<table border=0 cellpadding=0 cellspacing=0><tr>';
                    166:     for (my $i=0;$i<8;$i++) {
                    167: 	if ($val>$i*5) {
                    168:             $output.='<td width=5 bgcolor="'.$colors[$i].'">&nbsp;</td>';
                    169:         } else {
                    170: 	    $output.='<td width=5 bgcolor="#555555">&nbsp;</td>';
                    171: 	}
                    172:     }
                    173:     $output.='<td> ('.$value.') </td></tr></table>';
                    174:     return $output;
                    175: }
                    176: 
1.1       www       177: # ================================================================ Main Handler
                    178: 
                    179: sub handler {
                    180:   my $r=shift;
1.20      www       181: 
                    182:     my $loaderror=&Apache::lonnet::overloaderror($r);
                    183:     if ($loaderror) { return $loaderror; }
                    184: 
                    185: 
                    186:     my $uri=$r->uri;
                    187: 
1.23      www       188:   unless ($uri=~/^\/\~/) { 
                    189: # =========================================== This is not in construction space
1.20      www       190:     my ($resdomain,$resuser)=
                    191:            (&Apache::lonnet::declutter($uri)=~/^(\w+)\/(\w+)\//);
                    192: 
                    193:     $loaderror=
                    194:        &Apache::lonnet::overloaderror($r,
                    195:          &Apache::lonnet::homeserver($resuser,$resdomain));
                    196:     if ($loaderror) { return $loaderror; }
                    197: 
1.3       www       198:   my %content=();
1.1       www       199: 
                    200: # ----------------------------------------------------------- Set document type
                    201: 
                    202:   $r->content_type('text/html');
                    203:   $r->send_http_header;
                    204: 
                    205:   return OK if $r->header_only;
                    206: 
                    207: # ------------------------------------------------------------------- Read file
1.14      harris41  208:   foreach (split(/\,/,&Apache::lonnet::metadata($uri,'keys'))) {
1.3       www       209:       $content{$_}=&Apache::lonnet::metadata($uri,$_);
1.14      harris41  210:   }
1.6       albertel  211: # ------------------------------------------------------------------ Hide stuff
1.7       www       212: 
                    213:   unless ($ENV{'user.adv'}) {
1.14      harris41  214:       foreach ('keywords','notes','abstract','subject') {
1.7       www       215:           $content{$_}='<i>- not displayed -</i>';
1.14      harris41  216:       }
1.6       albertel  217:   }
                    218: 
1.1       www       219: # --------------------------------------------------------------- Render Output
1.23      www       220:   my ($thisversion)=($uri=~/\.(\d+)\.(\w+)\.meta$/);
1.22      www       221: my $creationdate=localtime(
                    222:  &Apache::loncommon::unsqltime($content{'creationdate'}));
                    223: my $lastrevisiondate=localtime(
                    224:  &Apache::loncommon::unsqltime($content{'lastrevisiondate'}));
1.10      www       225: my $language=&Apache::loncommon::languagedescription($content{'language'});
                    226: my $mime=&Apache::loncommon::filedescription($content{'mime'}); 
1.11      www       227: my $disuri=&Apache::lonnet::declutter($uri);
                    228:   $disuri=~s/\.meta$//;
1.21      www       229: my $currentversion=&Apache::lonnet::getversion($disuri);
1.29      www       230: my $author=$content{'author'};
                    231: $author=~s/(\w+)(\:|\@)(\w+)/&authordisplay($1,$3)/gse;
                    232: my $owner=$content{'owner'};
                    233: $owner=~s/(\w+)(\:|\@)(\w+)/&authordisplay($1,$3)/gse;
1.21      www       234: my $versiondisplay='';
                    235: if ($thisversion) {
                    236:     $versiondisplay='Version: '.$thisversion.
                    237:     ' (most recent version: '.$currentversion.')';
                    238: } else {
                    239:     $versiondisplay='Version: '.$currentversion;
                    240: }
1.29      www       241: my $customdistributionfile='';
                    242: if ($content{'customdistributionfile'}) {
                    243:    $customdistributionfile='<a href="'.$content{'customdistributionfile'}.
                    244:      '"><tt>'.$content{'customdistributionfile'}.'</tt></a>';
                    245: }
1.17      www       246: my $bodytag=&Apache::loncommon::bodytag
                    247:             ('Catalog Information','','','',$resdomain);
1.1       www       248:   $r->print(<<ENDHEAD);
                    249: <html><head><title>Catalog Information</title></head>
1.17      www       250: $bodytag
1.1       www       251: <h2>$content{'title'}</h2>
1.11      www       252: <h3><tt>$disuri</tt></h3>
1.21      www       253: $versiondisplay<br />
1.11      www       254: <table cellspacing=2 border=0>
                    255: <tr><td bgcolor='#AAAAAA'>Author(s)</td>
1.29      www       256: <td bgcolor="#CCCCCC">$author&nbsp;</td></tr>
1.11      www       257: <tr><td bgcolor='#AAAAAA'>Subject</td>
                    258: <td bgcolor="#CCCCCC">$content{'subject'}&nbsp;</td></tr>
                    259: <tr><td bgcolor='#AAAAAA'>Keyword(s)</td>
                    260: <td bgcolor="#CCCCCC">$content{'keywords'}&nbsp;</td></tr>
                    261: <tr><td bgcolor='#AAAAAA'>Notes</td>
                    262: <td bgcolor="#CCCCCC">$content{'notes'}&nbsp;</td></tr>
                    263: <tr><td bgcolor='#AAAAAA'>Abstract</td>
                    264: <td bgcolor="#CCCCCC">$content{'abstract'}&nbsp;</td></tr>
                    265: <tr><td bgcolor='#AAAAAA'>MIME Type</td>
                    266: <td bgcolor="#CCCCCC">$mime ($content{'mime'})&nbsp;</td></tr>
                    267: <tr><td bgcolor='#AAAAAA'>Language</td>
                    268: <td bgcolor="#CCCCCC">$language&nbsp;</td></tr>
                    269: <tr><td bgcolor='#AAAAAA'>Creation Date</td>
                    270: <td bgcolor="#CCCCCC">$creationdate&nbsp;</td></tr>
                    271: <tr><td bgcolor='#AAAAAA'>
                    272: Last Revision Date</td><td bgcolor="#CCCCCC">$lastrevisiondate&nbsp;</td></tr>
                    273: <tr><td bgcolor='#AAAAAA'>Publisher/Owner</td>
1.29      www       274: <td bgcolor="#CCCCCC">$owner&nbsp;</td></tr>
1.11      www       275: <tr><td bgcolor='#AAAAAA'>Copyright/Distribution</td>
1.29      www       276: <td bgcolor="#CCCCCC">$content{'copyright'}&nbsp;</td></tr>
                    277: <tr><td bgcolor='#AAAAAA'>Custom Distribution File</td>
                    278: <td bgcolor="#CCCCCC">$customdistributionfile&nbsp;</td></tr>
1.11      www       279: </table>
1.1       www       280: ENDHEAD
                    281:   delete($content{'title'});
                    282:   delete($content{'author'});
                    283:   delete($content{'subject'});
                    284:   delete($content{'keywords'});
                    285:   delete($content{'notes'});
                    286:   delete($content{'abstract'});
                    287:   delete($content{'mime'});
                    288:   delete($content{'language'});
                    289:   delete($content{'creationdate'});
                    290:   delete($content{'lastrevisiondate'});
                    291:   delete($content{'owner'});
                    292:   delete($content{'copyright'});
1.33    ! www       293:   delete($content{'customdistributionfile'});
1.7       www       294:   if ($ENV{'user.adv'}) {
1.11      www       295: # ------------------------------------------------------------ Dynamic Metadata
1.15      www       296:    $r->print(
                    297:    '<h3>Dynamic Metadata (updated periodically)</h3>Processing ...<br>');
                    298:    $r->rflush();
1.10      www       299:     my %items=(
                    300:  'count'      => 'Network-wide number of accesses (hits)',
                    301:  'course'     => 'Network-wide number of courses using resource',
                    302:  'usage'      => 'Number of resources using or importing resource',
1.30      www       303:  'goto'       => 'Number of resources that follow this resource in maps',
                    304:  'comefrom'   => 'Number of resources that lead up to this resource in maps',
1.11      www       305:  'clear'      => 'Material presented in clear way',
                    306:  'depth'      => 'Material covered with sufficient depth',
                    307:  'helpful'    => 'Material is helpful',
                    308:  'correct'    => 'Material appears to be correct',
                    309:  'technical'  => 'Resource is technically correct', 
1.10      www       310:  'avetries'   => 'Average number of tries till solved',
                    311:  'stdno'      => 'Total number of students who have worked on this problem',
                    312:  'difficulty' => 'Degree of difficulty');
                    313:    my %dynmeta=&dynamicmeta($uri);
1.11      www       314:    $r->print(
                    315: '</table><h4>Access and Usage Statistics</h4><table cellspacing=2 border=0>');
1.30      www       316:    foreach ('count') {
                    317:        $r->print(
                    318: '<tr><td bgcolor="#AAAAAA">'.$items{$_}.'</td><td bgcolor="#CCCCCC">'.
                    319: $dynmeta{$_}."&nbsp;</td></tr>\n");
                    320:    }
                    321:    foreach my $cat ('usage','comefrom','goto') {
                    322:        $r->print(
                    323: '<tr><td bgcolor="#AAAAAA">'.$items{$cat}.'</td><td bgcolor="#CCCCCC">'.
1.31      www       324: $dynmeta{$cat}.'<font size="-1"><ul>'.join("\n",
                    325:       map { my $murl=$_; 
                    326:  '<li><a href="'.&Apache::lonnet::clutter($murl).'" target="preview">'.
                    327:                         &Apache::lonnet::gettitle($murl).' [<tt>'.$murl
                    328:                         .'</tt>]</a></li>' }
                    329:       split(/\,/,$dynmeta{$cat.'_list'}))."</ul></font></td></tr>\n");
1.30      www       330:    }
1.31      www       331:    foreach my $cat ('course') {
1.11      www       332:        $r->print(
1.31      www       333: '<tr><td bgcolor="#AAAAAA">'.$items{$cat}.'</td><td bgcolor="#CCCCCC">'.
                    334: $dynmeta{$cat}.'<font size="-1"><ul>'.join("\n",
                    335:       map { my %courseinfo=&Apache::lonnet::coursedescription($_);  
                    336:  '<li><a href="/public/'.
                    337:   $courseinfo{'domain'}.'/'.$courseinfo{'num'}.'/syllabus" target="preview">'.
                    338:   $courseinfo{'description'}.'</a></li>' }
                    339:       split(/\,/,$dynmeta{$cat.'_list'}))."</ul></font></td></tr>\n");
1.11      www       340:    }
                    341:        $r->print('</table>');
1.10      www       342:    if ($uri=~/\.(problem|exam|quiz|assess|survey|form)\.meta$/) {
1.11      www       343:       $r->print(
                    344: '<h4>Assessment Statistical Data</h4><table cellspacing=2 border=0>');
1.12      www       345:       foreach ('stdno','avetries') {
1.11      www       346:           $r->print(
                    347: '<tr><td bgcolor="#AAAAAA">'.$items{$_}.'</td><td bgcolor="#CCCCCC">'.
                    348: $dynmeta{$_}."&nbsp;</td></tr>\n");
                    349:       }
1.12      www       350:       foreach ('difficulty') {
                    351:          $r->print(
                    352: '<tr><td bgcolor="#AAAAAA">'.$items{$_}.'</td><td bgcolor="#CCCCCC">'.
                    353: &diffgraph($dynmeta{$_})."</td></tr>\n");
                    354:       }
1.11      www       355:       $r->print('</table>');    
1.10      www       356:    }
1.11      www       357:    $r->print('<h4>Evaluation Data</h4><table cellspacing=2 border=0>');
1.10      www       358:    foreach ('clear','depth','helpful','correct','technical') {
1.11      www       359:        $r->print(
                    360: '<tr><td bgcolor="#AAAAAA">'.$items{$_}.'</td><td bgcolor="#CCCCCC">'.
1.12      www       361: &evalgraph($dynmeta{$_})."</td></tr>\n");
1.10      www       362:    }    
1.11      www       363:    $r->print('</table>');
                    364:    $disuri=~/^(\w+)\/(\w+)\//;   
1.10      www       365:    if ((($ENV{'user.domain'} eq $1) && ($ENV{'user.name'} eq $2))
                    366:        || ($ENV{'user.role.ca./'.$1.'/'.$2})) {
                    367:       $r->print(
                    368:   '<h4>Evaluation Comments (visible to author and co-authors only)</h4>'.
1.23      www       369:       '<blockquote>'.$dynmeta{'comments'}.'</blockquote>');
                    370:       $r->print(
                    371:    '<h4>Error Messages (visible to author and co-authors only)</h4>');
                    372:       my %errormsgs=&Apache::lonnet::dump('nohist_res_msgs',$1,$2);
                    373:       foreach (keys %errormsgs) {
1.28      albertel  374: 	if ($_=~/^\Q$disuri\E\_\d+$/) {
1.23      www       375:           my %content=&Apache::lonmsg::unpackagemsg($errormsgs{$_});
                    376: 	  $r->print('<b>'.$content{'time'}.'</b>: '.$content{'message'}.
                    377:                     '<br />');
                    378:         }
                    379:       }      
1.10      www       380:    }
1.11      www       381: # ------------------------------------------------------------- All other stuff
1.10      www       382:    $r->print(
                    383:  '<h3>Additional Metadata (non-standard, parameters, exports)</h3>');
                    384:    foreach (sort keys %content) {
1.3       www       385:       my $name=$_;
1.33    ! www       386:       unless ($name=~/\.display$/) {
        !           387: 	  my $display=&Apache::lonnet::metadata($uri,$name.'.display');
        !           388: 	  unless ($display) { $display=$name; };
        !           389: 	  my $otherinfo='';
        !           390: 	  foreach ('name','part','type','default') {
        !           391: 	      if (defined(&Apache::lonnet::metadata($uri,$name.'.'.$_))) {
        !           392: 		  $otherinfo.=' '.$_.'='.
        !           393: 		      &Apache::lonnet::metadata($uri,$name.'.'.$_).'; ';
        !           394: 	      }
        !           395: 	  }
        !           396: 	  $r->print('<b>'.$display.':</b> '.$content{$name});
        !           397: 	  if ($otherinfo) {
        !           398: 	      $r->print(' ('.$otherinfo.')');
        !           399: 	  }
        !           400: 	  $r->print("<br>\n");
1.14      harris41  401:       }
1.10      www       402:    }
1.7       www       403:   }
1.23      www       404: # ===================================================== End Resource Space Call
                    405:  } else {
                    406: # ===================================================== Construction Space Call
                    407: 
                    408: # ----------------------------------------------------------- Set document type
                    409: 
                    410:   $r->content_type('text/html');
                    411:   $r->send_http_header;
                    412: 
                    413:   return OK if $r->header_only;
                    414: # ---------------------------------------------------------------------- Header
                    415:   my $bodytag=&Apache::loncommon::bodytag('Edit Catalog Information');
                    416:   my $disuri=$uri;
                    417:   my $fn=&Apache::lonnet::filelocation('',$uri);
                    418:   $disuri=~s/^\/\~\w+//;
                    419:   $disuri=~s/\.meta$//;
                    420:   my $displayfile='Catalog Information for '.$disuri;
                    421:   if ($disuri=~/\/default$/) {
                    422:       my $dir=$disuri;
                    423:       $dir=~s/default$//;
                    424:       $displayfile='Default Cataloging Information for Directory '.$dir;
                    425:   }
                    426:   %Apache::lonpublisher::metadatafields=();
                    427:   %Apache::lonpublisher::metadatakeys=();
                    428:   &Apache::lonpublisher::metaeval(&Apache::lonnet::getfile($fn));
                    429:   $r->print(<<ENDEDIT);
                    430: <html><head><title>Edit Catalog Information</title></head>
                    431: $bodytag
                    432: <h1>$displayfile</h1>
1.24      www       433: <form method="post">
1.23      www       434: ENDEDIT
1.24      www       435:    foreach ('author','title','subject','keywords','abstract','notes',
1.27      www       436:             'copyright','customdistributionfile','language') {
1.24      www       437:        if ($ENV{'form.new_'.$_}) {
                    438: 	   $Apache::lonpublisher::metadatafields{$_}=$ENV{'form.new_'.$_};
                    439:        }
1.32      albertel  440:        if (m/copyright/) {
                    441: 	   $r->print(&Apache::lonpublisher::selectbox($_,'new_'.$_,
                    442: 			       $Apache::lonpublisher::metadatafields{$_},
                    443: 			       \&Apache::loncommon::copyrightdescription,
                    444: 			       (&Apache::loncommon::copyrightids)));
                    445:        } elsif (m/language/) {
                    446: 	   $r->print(&Apache::lonpublisher::selectbox($_,'new_'.$_,
                    447: 			      $Apache::lonpublisher::metadatafields{$_},
                    448: 			      \&Apache::loncommon::languagedescription,
                    449: 			      (&Apache::loncommon::languageids)));
                    450:        } else {
                    451: 	   $r->print(&Apache::lonpublisher::textfield($_,'new_'.$_,
                    452: 			     $Apache::lonpublisher::metadatafields{$_}));
                    453:        }
1.23      www       454:    }
1.24      www       455:    if ($ENV{'form.store'}) {
                    456:       my $mfh;
                    457:       unless ($mfh=Apache::File->new('>'.$fn)) {
                    458:             $r->print(
                    459:             '<p><font color=red>Could not write metadata, FAIL</font>');
                    460:       } else {
                    461:           foreach (sort keys %Apache::lonpublisher::metadatafields) {
                    462:             unless ($_=~/\./) {
                    463:                 my $unikey=$_;
                    464:                 $unikey=~/^([A-Za-z]+)/;
                    465:                 my $tag=$1;
                    466:                 $tag=~tr/A-Z/a-z/;
                    467:                 print $mfh "\n\<$tag";
                    468:                 foreach 
                    469:                   (split(/\,/,$Apache::lonpublisher::metadatakeys{$unikey})) {
                    470:                     my $value=
                    471:                        $Apache::lonpublisher::metadatafields{$unikey.'.'.$_};
                    472:                     $value=~s/\"/\'\'/g;
                    473:                     print $mfh ' '.$_.'="'.$value.'"';
                    474:                 }
                    475:                 print $mfh '>'.
                    476:         &HTML::Entities::encode($Apache::lonpublisher::metadatafields{$unikey})
                    477:                         .'</'.$tag.'>';
                    478:             }
                    479: 	  }
                    480:           $r->print('<p>Wrote Metadata');
                    481:       }
                    482:     }
                    483:     $r->print(
                    484:  '<br /><input type="submit" name="store" value="Store Catalog Information"></form></body></html>');
                    485:     return OK;
                    486:   }
1.1       www       487: }
                    488: 
                    489: 1;
                    490: __END__
                    491: 
                    492: 
                    493: 
                    494: 
                    495: 
                    496: 
                    497: 

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