File:  [LON-CAPA] / loncom / interface / lonmeta.pm
Revision 1.8: download - view: text, annotated - select for diffs
Wed Dec 19 17:17:46 2001 UTC (22 years, 5 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- Finished GPLing the code

    1: # The LearningOnline Network with CAPA
    2: # Metadata display handler
    3: #
    4: # $Id: lonmeta.pm,v 1.8 2001/12/19 17:17:46 albertel 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: # (TeX Content Handler
   29: #
   30: # 05/29/00,05/30,10/11 Gerd Kortemeyer)
   31: #
   32: # 10/19,10/21,10/23,11/27,08/09/01 Gerd Kortemeyer
   33: 
   34: package Apache::lonmeta;
   35: 
   36: use strict;
   37: use Apache::Constants qw(:common);
   38: use Apache::lonnet();
   39: 
   40: 
   41: # ================================================================ Main Handler
   42: 
   43: sub handler {
   44:   my $r=shift;
   45:   my %content=();
   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: 
   56:   my $uri=$r->uri;
   57:   map {
   58:       $content{$_}=&Apache::lonnet::metadata($uri,$_);
   59:   } split(/\,/,&Apache::lonnet::metadata($uri,'keys'));
   60: 
   61: # ------------------------------------------------------------------ Hide stuff
   62: 
   63:   unless ($ENV{'user.adv'}) {
   64:       map {
   65:           $content{$_}='<i>- not displayed -</i>';
   66:       } ('keywords','notes','abstract','subject');
   67:   }
   68: 
   69: # --------------------------------------------------------------- Render Output
   70: 
   71: my $creationdate=localtime($content{'creationdate'});
   72: my $lastrevisiondate=localtime($content{'lastrevisiondate'});
   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>
   88: <b>Creation Date:</b> $creationdate<br>
   89: <b>Last Revision Date:</b> $lastrevisiondate<br>
   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'});
  106:   if ($ENV{'user.adv'}) {
  107:    map {
  108:       my $name=$_;
  109:       my $display=&Apache::lonnet::metadata($uri,$name.'.display');
  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");
  123:    } sort keys %content;
  124:   }
  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>