1: # The LearningOnline Network with CAPA
2: # Metadata display handler
3: #
4: # $Id: lonmeta.pm,v 1.48 2003/12/29 21:17:00 www Exp $
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.
14: #
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/
27:
28:
29: package Apache::lonmeta;
30:
31: use strict;
32: use Apache::Constants qw(:common);
33: use Apache::lonnet();
34: use Apache::loncommon();
35: use Apache::lonhtmlcommon();
36: use Apache::lonmsg;
37: use Apache::lonpublisher;
38: use Apache::lonlocal;
39: use Apache::lonmysql;
40:
41: # MySQL table columns
42:
43: my @columns;
44:
45: # ----------------------------------------- Fetch and evaluate dynamic metadata
46:
47: sub dynamicmeta {
48: my $url=&Apache::lonnet::declutter(shift);
49: $url=~s/\.meta$//;
50: my ($adomain,$aauthor)=($url=~/^(\w+)\/(\w+)\//);
51: my $regexp=$url;
52: $regexp=~s/(\W)/\\$1/g;
53: $regexp='___'.$regexp.'___';
54: my %evaldata=&Apache::lonnet::dump('nohist_resevaldata',$adomain,
55: $aauthor,$regexp);
56: my %sum=();
57: my %cnt=();
58: my %concat=();
59: my %listitems=(
60: 'course' => 'add',
61: 'goto' => 'add',
62: 'comefrom' => 'add',
63: 'avetries' => 'avg',
64: 'stdno' => 'add',
65: 'difficulty' => 'avg',
66: 'clear' => 'avg',
67: 'technical' => 'avg',
68: 'helpful' => 'avg',
69: 'correct' => 'avg',
70: 'depth' => 'avg',
71: 'comments' => 'app',
72: 'usage' => 'cnt'
73: );
74: while ($_=each(%evaldata)) {
75: my ($item,$purl,$cat)=split(/___/,$_);
76: ### Apache->request->print("\n".$_.' - '.$item.'<br />');
77: if (defined($cnt{$cat})) { $cnt{$cat}++; } else { $cnt{$cat}=1; }
78: unless ($listitems{$cat} eq 'app') {
79: if (defined($sum{$cat})) {
80: $sum{$cat}+=$evaldata{$_};
81: $concat{$cat}.=','.$item;
82: } else {
83: $sum{$cat}=$evaldata{$_};
84: $concat{$cat}=$item;
85: }
86: } else {
87: if (defined($sum{$cat})) {
88: if ($evaldata{$_}) {
89: $sum{$cat}.='<hr />'.$evaldata{$_};
90: }
91: } else {
92: $sum{$cat}=''.$evaldata{$_};
93: }
94: }
95: }
96: my %returnhash=();
97: while ($_=each(%cnt)) {
98: if ($listitems{$_} eq 'avg') {
99: $returnhash{$_}=int(($sum{$_}/$cnt{$_})*100.0+0.5)/100.0;
100: } elsif ($listitems{$_} eq 'cnt') {
101: $returnhash{$_}=$cnt{$_};
102: } else {
103: $returnhash{$_}=$sum{$_};
104: }
105: $returnhash{$_.'_list'}=$concat{$_};
106: ### Apache->request->print("\n<hr />".$_.': '.$returnhash{$_}.'<br />'.$returnhash{$_.'_list'});
107: }
108: #
109: # Deal with 'count' separately
110: $returnhash{'count'} = &access_count($url,$aauthor,$adomain);
111: # since "usage" is reserved word in MySQL ...
112: $returnhash{'sequsage'}=$returnhash{'usage'};
113: $returnhash{'sequsage_list'}=$returnhash{'usage_list'};
114:
115: return %returnhash;
116: }
117:
118: sub access_count {
119: my ($src,$author,$adomain) = @_;
120: my %countdata=&Apache::lonnet::dump('nohist_accesscount',$adomain,
121: $author,$src);
122: if (! exists($countdata{$src})) {
123: return &mt('Not Available');
124: } else {
125: return $countdata{$src};
126: }
127: }
128:
129: # ------------------------------------- Try to make an alt tag if there is none
130:
131: sub alttag {
132: my ($base,$src)=@_;
133: my $fullpath=&Apache::lonnet::hreflocation($base,$src);
134: my $alttag=&Apache::lonnet::metadata($fullpath,'title').' '.
135: &Apache::lonnet::metadata($fullpath,'subject').' '.
136: &Apache::lonnet::metadata($fullpath,'abstract');
137: $alttag=~s/\s+/ /gs;
138: $alttag=~s/\"//gs;
139: $alttag=~s/\'//gs;
140: $alttag=~s/\s+$//gs;
141: $alttag=~s/^\s+//gs;
142: if ($alttag) { return $alttag; } else
143: { return &mt('No information available'); }
144: }
145:
146: # -------------------------------------------------------------- Author display
147:
148: sub authordisplay {
149: my ($aname,$adom)=@_;
150: return &Apache::loncommon::aboutmewrapper(
151: &Apache::loncommon::plainname($aname,$adom),
152: $aname,$adom,'preview').' <tt>['.$aname.'@'.$adom.']</tt>';
153: }
154:
155: # -------------------------------------------------------------- Pretty display
156:
157: sub evalgraph {
158: my $value=shift;
159: unless ($value) { return ''; }
160: my $val=int($value*10.+0.5)-10;
161: my $output='<table border=0 cellpadding=0 cellspacing=0><tr>';
162: if ($val>=20) {
163: $output.='<td width=20 bgcolor="#555555">  </td>';
164: } else {
165: $output.='<td width='.($val).' bgcolor="#555555"> </td>'.
166: '<td width='.(20-$val).' bgcolor="#FF3333"> </td>';
167: }
168: $output.='<td bgcolor="#FFFF33"> </td>';
169: if ($val>20) {
170: $output.='<td width='.($val-20).' bgcolor="#33FF33"> </td>'.
171: '<td width='.(40-$val).' bgcolor="#555555"> </td>';
172: } else {
173: $output.='<td width=20 bgcolor="#555555">  </td>';
174: }
175: $output.='<td> ('.$value.') </td></tr></table>';
176: return $output;
177: }
178:
179: sub diffgraph {
180: my $value=shift;
181: unless ($value) { return ''; }
182: my $val=int(40.0*$value+0.5);
183: my @colors=('#FF9933','#EEAA33','#DDBB33','#CCCC33',
184: '#BBDD33','#CCCC33','#DDBB33','#EEAA33');
185: my $output='<table border=0 cellpadding=0 cellspacing=0><tr>';
186: for (my $i=0;$i<8;$i++) {
187: if ($val>$i*5) {
188: $output.='<td width=5 bgcolor="'.$colors[$i].'"> </td>';
189: } else {
190: $output.='<td width=5 bgcolor="#555555"> </td>';
191: }
192: }
193: $output.='<td> ('.$value.') </td></tr></table>';
194: return $output;
195: }
196:
197: # ==================================================== Turn MySQL row into hash
198:
199: sub metadata_col_to_hash {
200: my @cols=@_;
201: my %hash=();
202: for (my $i=0; $i<=$#columns; $i++) {
203: $hash{$columns[$i]}=$cols[$i];
204: }
205: return %hash;
206: }
207:
208: # ============================================================= The field names
209:
210: sub fieldnames {
211: return &Apache::lonlocal::texthash(
212: 'title' => 'Title',
213: 'author' =>'Author(s)',
214: 'subject' => 'Subject',
215: 'keywords' => 'Keyword(s)',
216: 'notes' => 'Notes',
217: 'abstract' => 'Abstract',
218: 'lowestgradelevel' => 'Lowest Grade Level',
219: 'highestgradelevel' => 'Highest Grade Level',
220: 'standards' => 'Standards',
221: 'mime' => 'MIME Type',
222: 'language' => 'Language',
223: 'creationdate' => 'Creation Date',
224: 'lastrevisiondate' => 'Last Revision Date',
225: 'owner' => 'Publisher/Owner',
226: 'copyright' => 'Copyright/Distribution',
227: 'customdistributionfile' => 'Custom Distribution File',
228: 'obsolete' => 'Obsolete',
229: 'obsoletereplacement' => 'Suggested Replacement for Obsolete File',
230: 'count' => 'Network-wide number of accesses (hits)',
231: 'course' => 'Network-wide number of courses using resource',
232: 'course_list' => 'Network-wide courses using resource',
233: 'sequsage' => 'Number of resources using or importing resource',
234: 'sequsage_list' => 'Resources using or importing resource',
235: 'goto' => 'Number of resources that follow this resource in maps',
236: 'goto_list' => 'Resources that follow this resource in maps',
237: 'comefrom' => 'Number of resources that lead up to this resource in maps',
238: 'comefrom_list' => 'Resources that lead up to this resource in maps',
239: 'clear' => 'Material presented in clear way',
240: 'depth' => 'Material covered with sufficient depth',
241: 'helpful' => 'Material is helpful',
242: 'correct' => 'Material appears to be correct',
243: 'technical' => 'Resource is technically correct',
244: 'avetries' => 'Average number of tries till solved',
245: 'stdno' => 'Total number of students who have worked on this problem',
246: 'difficulty' => 'Degree of difficulty'
247: );
248: }
249:
250: # =========================================== Pretty printing of metadata field
251:
252: sub prettyprint {
253: my ($type,$value)=@_;
254: unless (defined($value)) { return ' '; }
255: # Title
256: if ($type eq 'title') {
257: return '<font size="+1" face="arial">'.$value.'</font>';
258: }
259: # Dates
260: if (($type eq 'creationdate') ||
261: ($type eq 'lastrevisiondate')) {
262: return &Apache::lonlocal::locallocaltime(
263: &Apache::lonmysql::unsqltime($value));
264: }
265: # Language
266: if ($type eq 'language') {
267: return &Apache::loncommon::languagedescription($value);
268: }
269: # Copyright
270: if ($type eq 'copyright') {
271: return &Apache::loncommon::copyrightdescription($value);
272: }
273: # MIME
274: if ($type eq 'mime') {
275: return '<img src="'.&Apache::loncommon::icon($value).'" /> '.
276: &Apache::loncommon::filedescription($value);
277: }
278: # Person
279: if (($type eq 'author') ||
280: ($type eq 'owner') ||
281: ($type eq 'modifyinguser') ||
282: ($type eq 'authorspace')) {
283: $value=~s/(\w+)(\:|\@)(\w+)/&authordisplay($1,$3)/gse;
284: return $value;
285: }
286: # Gradelevel
287: if (($type eq 'lowestgradelevel') ||
288: ($type eq 'highestgradelevel')) {
289: return &Apache::loncommon::gradeleveldescription($value);
290: }
291: # Only for advance users below
292: unless ($ENV{'user.adv'}) { return '<i>- '.&mt('not displayed').' -</i>' };
293: # File
294: if (($type eq 'customdistributionfile') ||
295: ($type eq 'obsoletereplacement') ||
296: ($type eq 'goto_list') ||
297: ($type eq 'comefrom_list') ||
298: ($type eq 'sequsage_list')) {
299: return join('<br />',map {
300: &Apache::lonnet::gettitle($_).' ['.
301: &Apache::lonhtmlcommon::crumbs(&Apache::lonnet::clutter($_),'preview').']';
302: } split(/\s*\,\s*/,$value));
303: }
304: # Evaluations
305: if (($type eq 'clear') ||
306: ($type eq 'depth') ||
307: ($type eq 'helpful') ||
308: ($type eq 'correct') ||
309: ($type eq 'technical')) {
310: return &evalgraph($value);
311: }
312: # Difficulty
313: if ($type eq 'difficulty') {
314: return &diffgraph($value);
315: }
316: # List of courses
317: if ($type=~/\_list/) {
318: return join('<br />',map {
319: my %courseinfo=&Apache::lonnet::coursedescription($_);
320: '<a href="/public/'.
321: $courseinfo{'domain'}.'/'.$courseinfo{'num'}.'/syllabus" target="preview">'.
322: $courseinfo{'description'}.'</a>';
323: } split(/\s*\,\s*/,$value));
324: }
325: # No pretty print found
326: return $value;
327: }
328: # ============================================== Pretty input of metadata field
329:
330: sub selectbox {
331: my ($name,$value,$functionref,@idlist)=@_;
332: my $selout='<select name="'.$name.'">';
333: foreach (@idlist) {
334: $selout.='<option value=\''.$_.'\'';
335: if ($_ eq $value) {
336: $selout.=' selected>'.&{$functionref}($_).'</option>';
337: }
338: else {$selout.='>'.&{$functionref}($_).'</option>';}
339: }
340: return $selout.'</select>';
341: }
342:
343:
344: sub prettyinput {
345: my ($type,$value,$fieldname,$formname)=@_;
346: # Language
347: if ($type eq 'language') {
348: return &selectbox($fieldname,
349: $value,
350: \&Apache::loncommon::languagedescription,
351: (&Apache::loncommon::languageids));
352: }
353: # Copyright
354: if ($type eq 'copyright') {
355: return &selectbox($fieldname,
356: $value,
357: \&Apache::loncommon::copyrightdescription,
358: (&Apache::loncommon::copyrightids));
359: }
360: # Gradelevels
361: if (($type eq 'lowestgradelevel') ||
362: ($type eq 'highestgradelevel')) {
363: return &Apache::loncommon::select_level_form($value,$fieldname);
364: }
365: # Obsolete
366: if ($type eq 'obsolete') {
367: return '<input type="checkbox" name="'.$fieldname.'"'.
368: ($value?' checked="1"':'').' />';
369: }
370: # Obsolete replacement file
371: if ($type eq 'obsoletereplacement') {
372: return '<input type="text" name="'.$fieldname.
373: '" size="60" value="'.$value.'" /><a href="javascript:openbrowser'.
374: "('".$formname."','".$fieldname."'".
375: ",'')\">".&mt('Select').'</a>';
376: }
377: # Customdistribution file
378: if ($type eq 'customdistributionfile') {
379: return '<input type="text" name="'.$fieldname.
380: '" size="60" value="'.$value.'" /><a href="javascript:openbrowser'.
381: "('".$formname."','".$fieldname."'".
382: ",'rights')\">".&mt('Select').'</a>';
383: }
384: # Dates
385: if (($type eq 'creationdate') ||
386: ($type eq 'lastrevisiondate')) {
387: return &Apache::lonhtmlcommon::date_setter($formname,
388: $fieldname,$value);
389: }
390: # No pretty input found
391: $value=~s/^\s+//gs;
392: $value=~s/\s+$//gs;
393: $value=~s/\s+/ /gs;
394: $value=~s/\"/\&quod\;/gs;
395: return '<input type="text" name="'.$fieldname.'" size="80" value="'.$value.'" />';
396: }
397:
398: # ================================================================ Main Handler
399:
400: sub handler {
401: my $r=shift;
402:
403: my $loaderror=&Apache::lonnet::overloaderror($r);
404: if ($loaderror) { return $loaderror; }
405:
406:
407: my $uri=$r->uri;
408:
409: unless ($uri=~/^\/\~/) {
410: # =========================================== This is not in construction space
411: my ($resdomain,$resuser)=
412: (&Apache::lonnet::declutter($uri)=~/^(\w+)\/(\w+)\//);
413:
414: $loaderror=
415: &Apache::lonnet::overloaderror($r,
416: &Apache::lonnet::homeserver($resuser,$resdomain));
417: if ($loaderror) { return $loaderror; }
418:
419: my %content=();
420:
421: # ----------------------------------------------------------- Set document type
422:
423: &Apache::loncommon::content_type($r,'text/html');
424: $r->send_http_header;
425:
426: return OK if $r->header_only;
427:
428: # ------------------------------------------------------------------- Read file
429: foreach (split(/\,/,&Apache::lonnet::metadata($uri,'keys'))) {
430: $content{$_}=&Apache::lonnet::metadata($uri,$_);
431: }
432: # --------------------------------------------------------------- Render Output
433: # displayed url
434: my ($thisversion)=($uri=~/\.(\d+)\.(\w+)\.meta$/);
435: my $disuri=&Apache::lonnet::clutter($uri);
436: $disuri=~s/\.meta$//;
437: $disuri=&Apache::lonhtmlcommon::crumbs($disuri);
438: # version
439: my $currentversion=&Apache::lonnet::getversion($disuri);
440: my $versiondisplay='';
441: if ($thisversion) {
442: $versiondisplay=&mt('Version').': '.$thisversion.
443: ' ('.&mt('most recent version').': '.
444: ($currentversion>0?$currentversion:&mt('information not available')).')';
445: } else {
446: $versiondisplay='Version: '.$currentversion;
447: }
448: # obsolete
449: my $obsolete=$content{'obsolete'};
450: my $obsoletewarning='';
451: if (($obsolete) && ($ENV{'user.adv'})) {
452: $obsoletewarning='<p><font color="red">'.
453: &mt('This resource has been marked obsolete by the author(s)').'</font></p>';
454: }
455:
456: my %lt=&fieldnames();
457: my $table='';
458: my $bodytag=&Apache::loncommon::bodytag
459: ('Catalog Information','','','',$resdomain);
460: foreach ('title',
461: 'author',
462: 'subject',
463: 'keywords',
464: 'notes',
465: 'abstract',
466: 'mime',
467: 'language',
468: 'creationdate',
469: 'lastrevisiondate',
470: 'owner',
471: 'copyright',
472: 'customdistributionfile',
473: 'obsolete',
474: 'obsoletereplacement') {
475: $table.='<tr><td bgcolor="#AAAAAA">'.$lt{$_}.
476: '</td><td bgcolor="#CCCCCC">'.
477: &prettyprint($_,$content{$_}).'</td></tr>';
478: delete $content{$_};
479: }
480:
481: $r->print(<<ENDHEAD);
482: <html><head><title>Catalog Information</title></head>
483: $bodytag
484: <h2>$content{'title'}</h2>
485: <h3><tt>$disuri</tt></h3>
486: $obsoletewarning
487: $versiondisplay<br />
488: <table cellspacing=2 border=0>
489: $table
490: </table>
491: ENDHEAD
492: if ($ENV{'user.adv'}) {
493: # ------------------------------------------------------------ Dynamic Metadata
494: $r->print(
495: '<h3>'.&mt('Dynamic Metadata').' ('.
496: &mt('updated periodically').')</h3>'.&mt('Processing').
497: ' ...<br />');
498: $r->rflush();
499: my %items=&fieldnames();
500: my %dynmeta=&dynamicmeta($uri);
501: # General Access and Usage Statistics
502: $r->print('<h4>'.&mt('Access and Usage Statistics').'</h4><table cellspacing=2 border=0>');
503: foreach ('count',
504: 'sequsage','sequsage_list',
505: 'comefrom','comefrom_list',
506: 'goto','goto_list',
507: 'course','course_list') {
508: $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td><td bgcolor="#CCCCCC">'.
509: &prettyprint($dynmeta{$_})."</td></tr>\n");
510: }
511: $r->print('</table>');
512: if ($uri=~/\.(problem|exam|quiz|assess|survey|form)\.meta$/) {
513: # This is an assessment, print assessment data
514: $r->print(
515: '<h4>'.&mt('Assessment Statistical Data').'</h4><table cellspacing=2 border=0>');
516: foreach ('stdno','avetries','difficulty') {
517: $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td><td bgcolor="#CCCCCC">'.
518: &prettyprint($dynmeta{$_})."</td></tr>\n");
519: }
520: $r->print('</table>');
521: }
522: $r->print('<h4>'.&mt('Evaluation Data').'</h4><table cellspacing=2 border=0>');
523: foreach ('clear','depth','helpful','correct','technical') {
524: $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td><td bgcolor="#CCCCCC">'.
525: &prettyprint($dynmeta{$_})."</td></tr>\n");
526: }
527: $r->print('</table>');
528: $disuri=~/^(\w+)\/(\w+)\//;
529: if ((($ENV{'user.domain'} eq $1) && ($ENV{'user.name'} eq $2))
530: || ($ENV{'user.role.ca./'.$1.'/'.$2})) {
531: $r->print(
532: '<h4>'.&mt('Evaluation Comments').' ('.&mt('visible to author and co-authors only').')</h4>'.
533: '<blockquote>'.$dynmeta{'comments'}.'</blockquote>');
534: $r->print('<h4>'.&mt('Error Messages').' ('.
535: &mt('visible to author and co-authors only').')</h4>');
536: my %errormsgs=&Apache::lonnet::dump('nohist_res_msgs',$1,$2);
537: foreach (keys %errormsgs) {
538: if ($_=~/^\Q$disuri\E\_\d+$/) {
539: my %content=&Apache::lonmsg::unpackagemsg($errormsgs{$_});
540: $r->print('<b>'.$content{'time'}.'</b>: '.$content{'message'}.
541: '<br />');
542: }
543: }
544: }
545: # ------------------------------------------------------------- All other stuff
546: $r->print(
547: '<h3>'.&mt('Additional Metadata (non-standard, parameters, exports)').'</h3>');
548: foreach (sort keys %content) {
549: my $name=$_;
550: unless ($name=~/\.display$/) {
551: my $display=&Apache::lonnet::metadata($uri,$name.'.display');
552: unless ($display) { $display=$name; };
553: my $otherinfo='';
554: foreach ('name','part','type','default') {
555: if (defined(&Apache::lonnet::metadata($uri,$name.'.'.$_))) {
556: $otherinfo.=' '.$_.'='.
557: &Apache::lonnet::metadata($uri,$name.'.'.$_).'; ';
558: }
559: }
560: $r->print('<b>'.$display.':</b> '.$content{$name});
561: if ($otherinfo) {
562: $r->print(' ('.$otherinfo.')');
563: }
564: $r->print("<br />\n");
565: }
566: }
567: }
568: # ===================================================== End Resource Space Call
569: } else {
570: # ===================================================== Construction Space Call
571:
572: # ----------------------------------------------------------- Set document type
573:
574: &Apache::loncommon::content_type($r,'text/html');
575: $r->send_http_header;
576:
577: return OK if $r->header_only;
578: # ---------------------------------------------------------------------- Header
579: my $bodytag=&Apache::loncommon::bodytag('Edit Catalog Information');
580: my $disuri=$uri;
581: my $fn=&Apache::lonnet::filelocation('',$uri);
582: $disuri=~s/^\/\~\w+//;
583: $disuri=~s/\.meta$//;
584: my $displayfile='Catalog Information for '.$disuri;
585: if ($disuri=~/\/default$/) {
586: my $dir=$disuri;
587: $dir=~s/default$//;
588: $displayfile=&mt('Default Cataloging Information for Directory').' '.
589: $dir;
590: }
591: %Apache::lonpublisher::metadatafields=();
592: %Apache::lonpublisher::metadatakeys=();
593: &Apache::lonpublisher::metaeval(&Apache::lonnet::getfile($fn));
594: $r->print(<<ENDEDIT);
595: <html><head><title>Edit Catalog Information</title></head>
596: $bodytag
597: <h1>$displayfile</h1>
598: <form method="post" name="defaultmeta">
599: ENDEDIT
600: $r->print('<script language="JavaScript">'.
601: &Apache::loncommon::browser_and_searcher_javascript.
602: '</script>');
603: my %lt=&fieldnames();
604: foreach ('author','title','subject','keywords','abstract','notes',
605: 'copyright','customdistributionfile','language','standards',
606: 'lowestgradelevel','highestgradelevel',
607: 'obsolete','obsoletereplacement') {
608: $Apache::lonpublisher::metadatafields{$_}=$ENV{'form.new_'.$_};
609: unless ($Apache::lonpublisher::metadatafields{'copyright'}) {
610: $Apache::lonpublisher::metadatafields{'copyright'}='default';
611: }
612: $r->print('<p>'.$lt{$_}.': '.&prettyinput($_,
613: $Apache::lonpublisher::metadatafields{$_},
614: 'new_'.$_,'defaultmeta').'</p>');
615: }
616: if ($ENV{'form.store'}) {
617: my $mfh;
618: unless ($mfh=Apache::File->new('>'.$fn)) {
619: $r->print(
620: '<p><font color=red>'.&mt('Could not write metadata').', '.
621: &mt('FAIL').'</font>');
622: } else {
623: foreach (sort keys %Apache::lonpublisher::metadatafields) {
624: unless ($_=~/\./) {
625: my $unikey=$_;
626: $unikey=~/^([A-Za-z]+)/;
627: my $tag=$1;
628: $tag=~tr/A-Z/a-z/;
629: print $mfh "\n\<$tag";
630: foreach
631: (split(/\,/,$Apache::lonpublisher::metadatakeys{$unikey})) {
632: my $value=
633: $Apache::lonpublisher::metadatafields{$unikey.'.'.$_};
634: $value=~s/\"/\'\'/g;
635: print $mfh ' '.$_.'="'.$value.'"';
636: }
637: print $mfh '>'.
638: &HTML::Entities::encode($Apache::lonpublisher::metadatafields{$unikey})
639: .'</'.$tag.'>';
640: }
641: }
642: $r->print('<p>'.&mt('Wrote Metadata'));
643: }
644: }
645: $r->print(
646: '<br /><input type="submit" name="store" value="'.
647: &mt('Store Catalog Information').'"></form></body></html>');
648: return OK;
649: }
650: }
651:
652: # ================================================================= BEGIN Block
653: BEGIN {
654: # Get columns of MySQL metadata table
655: @columns=&Apache::lonmysql::col_order('metadata');
656: }
657: 1;
658: __END__
659:
660:
661:
662:
663:
664:
665:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>