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