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

1.1       www         1: # The LearningOnline Network with CAPA
1.8     ! albertel    2: # Metadata display handler
        !             3: #
        !             4: # $Id: gplheader.pl,v 1.1 2001/11/29 18:19:27 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.
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.7       www        32: # 10/19,10/21,10/23,11/27,08/09/01 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.1       www        39: 
                     40: 
                     41: # ================================================================ Main Handler
                     42: 
                     43: sub handler {
                     44:   my $r=shift;
1.3       www        45:   my %content=();
1.1       www        46: 
                     47: # ----------------------------------------------------------- Set document type
                     48: 
                     49:   $r->content_type('text/html');
                     50:   $r->send_http_header;
                     51: 
                     52:   return OK if $r->header_only;
                     53: 
                     54: # ------------------------------------------------------------------- Read file
                     55: 
1.3       www        56:   my $uri=$r->uri;
                     57:   map {
                     58:       $content{$_}=&Apache::lonnet::metadata($uri,$_);
                     59:   } split(/\,/,&Apache::lonnet::metadata($uri,'keys'));
1.1       www        60: 
1.6       albertel   61: # ------------------------------------------------------------------ Hide stuff
1.7       www        62: 
                     63:   unless ($ENV{'user.adv'}) {
                     64:       map {
                     65:           $content{$_}='<i>- not displayed -</i>';
                     66:       } ('keywords','notes','abstract','subject');
1.6       albertel   67:   }
                     68: 
1.1       www        69: # --------------------------------------------------------------- Render Output
1.2       www        70: 
                     71: my $creationdate=localtime($content{'creationdate'});
                     72: my $lastrevisiondate=localtime($content{'lastrevisiondate'});
1.1       www        73:   
                     74:   $r->print(<<ENDHEAD);
                     75: <html><head><title>Catalog Information</title></head>
                     76: <body bgcolor="#FFFFFF">
                     77: <h1>Catalog Information</h1>
                     78: <h2>$content{'title'}</h2>
                     79: <h3>Author(s): $content{'author'}</h3>
                     80: <b>Subject:</b> $content{'subject'}<br>
                     81: <b>Keyword(s):</b> $content{'keywords'}<br>
                     82: <b>Notes:</b> $content{'notes'}<br>
                     83: <b>Abstract:</b>
                     84: <blockquote>$content{'abstract'}</blockquote>
                     85: <hr>
                     86: <b>MIME Type:</b> $content{'mime'}<br>
                     87: <b>Language:</b> $content{'language'}<br>
1.2       www        88: <b>Creation Date:</b> $creationdate<br>
                     89: <b>Last Revision Date:</b> $lastrevisiondate<br>
1.1       www        90: <b>Publisher/Owner:</b> $content{'owner'}<br>
                     91: <b>Copyright/Distribution:</b> $content{'copyright'}
                     92: <hr>
                     93: ENDHEAD
                     94:   delete($content{'title'});
                     95:   delete($content{'author'});
                     96:   delete($content{'subject'});
                     97:   delete($content{'keywords'});
                     98:   delete($content{'notes'});
                     99:   delete($content{'abstract'});
                    100:   delete($content{'mime'});
                    101:   delete($content{'language'});
                    102:   delete($content{'creationdate'});
                    103:   delete($content{'lastrevisiondate'});
                    104:   delete($content{'owner'});
                    105:   delete($content{'copyright'});
1.7       www       106:   if ($ENV{'user.adv'}) {
                    107:    map {
1.3       www       108:       my $name=$_;
                    109:       my $display=&Apache::lonnet::metadata($uri,$name.'.display');
1.5       www       110:       unless ($display) { $display=$name; };
                    111:       my $otherinfo='';
                    112:       map {
                    113:           if (defined(&Apache::lonnet::metadata($uri,$name.'.'.$_))) {
                    114:              $otherinfo.=' '.$_.'='.
                    115: 		 &Apache::lonnet::metadata($uri,$name.'.'.$_).'; ';
                    116:           }
                    117:       } ('name','part','type','default'); 
                    118:       $r->print('<b>'.$display.':</b> '.$content{$name});
                    119:       if ($otherinfo) {
                    120:          $r->print(' ('.$otherinfo.')');
                    121:       }
                    122:       $r->print("<br>\n");
1.7       www       123:    } sort keys %content;
                    124:   }
1.1       www       125:   $r->print('</body></html>');
                    126:   return OK;
                    127: }
                    128: 
                    129: 1;
                    130: __END__
                    131: 
                    132: 
                    133: 
                    134: 
                    135: 
                    136: 
                    137: 

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