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

sakharuk lon-capa-cvs@mail.lon-capa.org
Fri, 24 Oct 2003 13:31:37 -0000


sakharuk		Fri Oct 24 09:31:37 2003 EDT

  Modified files:              
    /loncom/interface	lonsimplepage.pm 
  Log:
  First attempt to print simple page as a single document only. Needs more work particularly with photos and links.
  
  
Index: loncom/interface/lonsimplepage.pm
diff -u loncom/interface/lonsimplepage.pm:1.13 loncom/interface/lonsimplepage.pm:1.14
--- loncom/interface/lonsimplepage.pm:1.13	Wed Sep 17 15:45:39 2003
+++ loncom/interface/lonsimplepage.pm	Fri Oct 24 09:31:37 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Simple Page Editor
 #
-# $Id: lonsimplepage.pm,v 1.13 2003/09/17 19:45:39 www Exp $
+# $Id: lonsimplepage.pm,v 1.14 2003/10/24 13:31:37 sakharuk Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -35,6 +35,8 @@
 use Apache::lontexconvert;
 use Apache::lonfeedback;
 use Apache::lonlocal;
+use Apache::lonprintout;
+use Apache::lonxml;
 
 sub handler {
     my $r = shift;
@@ -43,16 +45,24 @@
     return OK if $r->header_only;
 
 # ------------------------------------------------------------ Print the screen
-    $r->print(<<ENDDOCUMENT);
+    if ($ENV{'form.grade_target'} ne 'tex') {
+	$r->print(<<ENDDOCUMENT);
 <html>
 <head>
 <title>The LearningOnline Network with CAPA</title>
 ENDDOCUMENT
+    } else {
+	$r->print(&Apache::lonprintout::print_latex_header($ENV{'form.latex_type'}));
+    } 
     my (undef,undef,undef,undef,$marker)=split(/\//,$r->uri);
 # Is this even in a course?
     unless ($ENV{'request.course.id'}) {
-	$r->print('</head><body>Not in a course</body></html>');
-        return OK;
+	if ($ENV{'form.grade_target'} ne 'tex') {
+	    $r->print('</head><body>Not in a course</body></html>');
+	    return OK;
+	} else {
+	    $r->print('\textbf{Not in a course}\end{document}');
+	}
     }
 
     $marker=~s/\D//g;
@@ -91,18 +101,22 @@
        
 # --------------------------------------- There is such a user, get environment
 
-    $r->print('</head>'.&Apache::loncommon::bodytag
-      ("Course Page",$forcestudent,$addentries,'',$dom,$ENV{'form.register'}));
+    if ($ENV{'form.grade_target'} ne 'tex') {
+	$r->print('</head>'.&Apache::loncommon::bodytag
+		  ("Course Page",$forcestudent,$addentries,'',$dom,$ENV{'form.register'}));
+    }
 
     my $allowed=&Apache::lonnet::allowed('mdc',$ENV{'request.course.id'});
 
        if ($forcestudent) { $allowed=0; }
  
        if ($allowed) {
-          $r->print('<p>'.
-&Apache::loncommon::help_open_topic('Uploaded_Templates_TextBoxes','Help with filling in text boxes').'<br /><a href="'.$r->uri.'?forcestudent=1"><font size="+1">Show Student View</font></a>'.
- &Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView').'</p>');
-      }
+	   if ($ENV{'form.grade_target'} ne 'tex') {
+	       $r->print('<p>'.
+                   &Apache::loncommon::help_open_topic('Uploaded_Templates_TextBoxes','Help with filling in text boxes').'<br /><a href="'.$r->uri.'?forcestudent=1"><font size="+1">Show Student View</font></a>'.
+                   &Apache::loncommon::help_open_topic('Uploaded_Templates_PublicView').'</p>');
+	   } 
+       }
       if (($ENV{'form.uploaddoc.filename'}) &&
           ($ENV{'form.storeupl'}) && ($allowed)) {
  	  if ($ENV{'form.uploaddoc.filename'}=~/\.(gif|jpg|png|jpeg)$/i) {
@@ -126,11 +140,13 @@
 # ---------------------------------------------------------------- Get syllabus
     if (($syllabus{'uploaded.lastmodified'}) || ($allowed)) {
        if ($syllabus{'uploaded.photourl'}) {
-	   $r->print('<img src="'.
-             &Apache::lonnet::tokenwrapper($syllabus{'uploaded.photourl'}).
-             '" align="right" />');
+	   if ($ENV{'form.grade_target'} ne 'tex') {
+	       $r->print('<img src="'.
+			 &Apache::lonnet::tokenwrapper($syllabus{'uploaded.photourl'}).
+			 '" align="right" />');
+	   }
        }
-       if ($allowed) {
+       if ($allowed && ($ENV{'form.grade_target'} ne 'tex')) {
            $r->print(
 	 '<form method="post" enctype="multipart/form-data">'.
          '<h3>Upload a Photo</h3>'.
@@ -147,34 +163,63 @@
 	      $message=&Apache::lontexconvert::msgtexconverted($message);
             unless ($_ eq 'aaa_title') {
 		if (($_ ne 'bbb_content') || ($allowed)) {
-                    $r->print('<h3>'.$syllabusfields{$_}.'</h3>');
+		    if ($ENV{'form.grade_target'} ne 'tex') {
+			$r->print('<h3>'.$syllabusfields{$_}.'</h3>');
+		    } else {
+			my $safeinit;
+			$r->print(&Apache::lonxml::xmlparse($r,'tex','<h3>'.$syllabusfields{$_}.'</h3>'));
+		    }
+		}
+		if ($ENV{'form.grade_target'} ne 'tex') {
+		    $r->print('<blockquote>'.
+			      $message.'</blockquote>');
+		} else {
+			my $safeinit;
+			$r->print(&Apache::lonxml::xmlparse($r,'tex',$message));
 		}
-                 $r->print('<blockquote>'.
-                        $message.'</blockquote>');
                  if ($allowed) {
-                $r->print('<br /><textarea cols="80" rows="20" name="'.$_.'">'.
+		     if ($ENV{'form.grade_target'} ne 'tex') {
+			 $r->print('<br /><textarea cols="80" rows="20" name="'.$_.'">'.
 			   $syllabus{$_}.
-           '</textarea><input type="submit" name="storesyl" value="Store" />');
+                           '</textarea><input type="submit" name="storesyl" value="Store" />');
+		     } else {
+			my $safeinit;
+			$r->print(&Apache::lonxml::xmlparse($r,'tex',$syllabus{$_},$safeinit));
+		     }
 	        }
 	    } else {
-		$r->print('<h1>'.$message.'</h1>');
+		if ($ENV{'form.grade_target'} ne 'tex') {
+		    $r->print('<h1>'.$message.'</h1>');
+		} else {
+		    my $safeinit;
+		    $r->print(&Apache::lonxml::xmlparse($r,'tex','<h1>'.$message.'</h1>'));
+		}
                 if ($allowed) {
-                 $r->print(
-                '<br />Title<br /><textarea cols="80" rows="2" name="'.$_.'">'.
-			   $syllabus{$_}.
-           '</textarea><input type="submit" name="storesyl" value="Store" />');
+		    if ($ENV{'form.grade_target'} ne 'tex') {
+			$r->print(
+			    '<br />Title<br /><textarea cols="80" rows="2" name="'.$_.'">'.
+			    $syllabus{$_}.
+                            '</textarea><input type="submit" name="storesyl" value="Store" />');
+		    } else {
+			my $safeinit;
+			$r->print(&Apache::lonxml::xmlparse($r,'tex',$syllabus{$_},$safeinit));
+		    }
                 }
             }
 	  }
        }
-       if ($allowed) {
+       if ($allowed && ($ENV{'form.grade_target'} ne 'tex')) {
 	   $r->print('</form>');
        }
-       $r->print('</p>');
+       if ($ENV{'form.grade_target'} ne 'tex') {$r->print('</p>');}
     } else {
        $r->print('<p>No page information provided.</p>');
     }
-    $r->print('</body></html>');
+    if ($ENV{'form.grade_target'} ne 'tex') {
+	$r->print('</body></html>');
+    } else {
+	$r->print('\end{document}');
+    }
     return OK;
 }