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

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

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