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

bowersj2 lon-capa-cvs@mail.lon-capa.org
Fri, 14 Feb 2003 02:21:36 -0000


bowersj2		Thu Feb 13 21:21:36 2003 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  Starting the work with the wizard in lonprintout.pm.
  
  Realize I need another feature for the wizard XML later -
  permission checking.
  
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.114 loncom/interface/lonprintout.pm:1.115
--- loncom/interface/lonprintout.pm:1.114	Thu Feb 13 19:23:37 2003
+++ loncom/interface/lonprintout.pm	Thu Feb 13 21:21:35 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.114 2003/02/14 00:23:37 bowersj2 Exp $
+# $Id: lonprintout.pm,v 1.115 2003/02/14 02:21:35 bowersj2 Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1354,6 +1354,69 @@
     return OK;
    
 } 
+
+use Apache::lonwizard;
+
+sub printWizard {
+    my $r = shift;
+
+    if ($ENV{'request.course.id'}) {
+	my $fn=$ENV{'request.course.fn'};
+	tie(%hash,'GDBM_File',"$fn.db",&GDBM_READER(),0640);
+    }
+
+    if ($r->header_only) {
+        if ($ENV{'browser.mathml'}) {
+            $r->content_type('text/xml');
+        } else {
+            $r->content_type('text/html');
+        }
+        $r->send_http_header;
+        return OK;
+    }
+
+    # Send header, nocache
+    if ($ENV{'browser.mathml'}) {
+        $r->content_type('text/xml');
+    } else {
+        $r->content_type('text/html');
+    }
+    &Apache::loncommon::no_cache($r);
+    $r->send_http_header;
+    $r->rflush();
+
+    my ($resourceTitle,$sequenceTitle,$mapTitle) = &details_for_menu;
+
+    my $wizard = Apache::lonwizard->new("Printing Wizard");
+    # PRINT_TYPE: What the user wants to print (current docs,
+    #  whole sequence, etc.
+    $wizard->declareVars(['PRINT_TYPE']);
+
+    my $subdir = $ENV{'form.postdata'};
+    $subdir =~ s|http://[^/]+||;
+    $subdir =~ m/\/([^\/]+)$/;
+    $subdir =~ s/\Q$1\E//;
+
+    # This code also shows up above... which is prefered? Is one
+    # right for this context?
+    #my $subdir = &Apache::lonnet::filelocation("",$ENV{'form.url'});
+    #$subdir =~ s/\/[^\/]+$//;
+    
+    Apache::lonwizard::switch_state->new($wizard, "START", "Selecting Resources to Print", "PRINT_TYPE", [
+           ['current_document', "<b>$resourceTitle</b> (exactly what was on the screen)", 'CHOOSE_FORMAT'],
+           ['map_problems', "Problems from <b>$sequenceTitle</b>", 'CHOOSE_FORMAT'],
+           ['map_problems_pages', "All of <b>$sequenceTitle</b>", 'CHOOSE_FORMAT'],
+           ['problems_for_students', "Problems from <b>$sequenceTitle</b> for selected students", 'CHOOSE_FORMAT'],
+           ['problems_from_directory', "Problems from <b>$subdir</b>", 'CHOOSE_FORMAT'] ],
+           "What do you want to print?");
+    
+    $r->print($wizard->display());
+
+    untie %hash;
+
+    return OK;
+
+}
 
 
 1;