File:  [LON-CAPA] / loncom / interface / lonhelper.pm
Revision 1.2: download - view: text, annotated - select for diffs
Fri Mar 21 21:34:56 2003 UTC (21 years, 2 months ago) by bowersj2
Branches: MAIN
CVS tags: HEAD
Depends on some other files that aren't in the CVS repository, so this
won't work for anyone else, but I am rocking now. A file is being read
off the disk and being processed through lonxml... in other words, all
the hard parts I wasn't sure about. It's mostly typing from here.

    1: # The LearningOnline Network with CAPA
    2: # .helper XML handler to implement the LON-CAPA helper
    3: #
    4: # $Id: lonhelper.pm,v 1.2 2003/03/21 21:34:56 bowersj2 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: # (Page Handler
   29: #
   30: # (.helper handler
   31: #
   32: 
   33: package Apache::lonhelper;
   34: use Apache::Constants qw(:common);
   35: use Apache::File;
   36: 
   37: BEGIN {
   38:     &Apache::lonxml::register('Apache::lonhelper', 
   39:                               ('helper'));
   40: }
   41: 
   42: my $r;
   43: 
   44: sub handler {
   45:     $r = shift;
   46:     $ENV{'request.uri'} = $r->uri();
   47:     my $filename = '/home/httpd/html' . $r->uri();
   48:     my $fh = Apache::File->new($filename);
   49:     my $file;
   50:     read $fh, $file, 1000000000;
   51: 
   52:     $result = &Apache::lonxml::xmlparse($r, 'helper', $file);
   53:                                         
   54: 
   55:     $r->print("\n\n$result");
   56:     return OK;
   57: }
   58: 
   59: sub start_helper {
   60:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   61: 
   62:     if ($target ne 'helper') {
   63:         return '';
   64:     }
   65:     
   66:     return 'Helper started.';
   67: }
   68: 
   69: sub end_helper {
   70:     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
   71:     
   72:     return 'Helper ended.';
   73: }
   74: 
   75: 1;
   76: 
   77: __END__

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