[LON-CAPA-cvs] cvs: loncom /interface lonhelper.pm

bowersj2 lon-capa-cvs@mail.lon-capa.org
Fri, 21 Mar 2003 21:34:56 -0000


bowersj2		Fri Mar 21 16:34:56 2003 EDT

  Modified files:              
    /loncom/interface	lonhelper.pm 
  Log:
  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.
  
  
  
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.1 loncom/interface/lonhelper.pm:1.2
--- loncom/interface/lonhelper.pm:1.1	Fri Mar 21 13:11:11 2003
+++ loncom/interface/lonhelper.pm	Fri Mar 21 16:34:56 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # .helper XML handler to implement the LON-CAPA helper
 #
-# $Id: lonhelper.pm,v 1.1 2003/03/21 18:11:11 bowersj2 Exp $
+# $Id: lonhelper.pm,v 1.2 2003/03/21 21:34:56 bowersj2 Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -31,6 +31,46 @@
 #
 
 package Apache::lonhelper;
+use Apache::Constants qw(:common);
+use Apache::File;
+
+BEGIN {
+    &Apache::lonxml::register('Apache::lonhelper', 
+                              ('helper'));
+}
+
+my $r;
+
+sub handler {
+    $r = shift;
+    $ENV{'request.uri'} = $r->uri();
+    my $filename = '/home/httpd/html' . $r->uri();
+    my $fh = Apache::File->new($filename);
+    my $file;
+    read $fh, $file, 1000000000;
+
+    $result = &Apache::lonxml::xmlparse($r, 'helper', $file);
+                                        
+
+    $r->print("\n\n$result");
+    return OK;
+}
+
+sub start_helper {
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+
+    if ($target ne 'helper') {
+        return '';
+    }
+    
+    return 'Helper started.';
+}
+
+sub end_helper {
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+    
+    return 'Helper ended.';
+}
 
 1;