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

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 21 Mar 2006 21:01:23 -0000


albertel		Tue Mar 21 16:01:23 2006 EDT

  Modified files:              
    /loncom/interface	loncommon.pm lonbulletin.pm 
  Log:
  - adding a simple error page handler
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.317 loncom/interface/loncommon.pm:1.318
--- loncom/interface/loncommon.pm:1.317	Tue Mar 21 15:36:15 2006
+++ loncom/interface/loncommon.pm	Tue Mar 21 16:01:22 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.317 2006/03/21 20:36:15 albertel Exp $
+# $Id: loncommon.pm,v 1.318 2006/03/21 21:01:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3080,6 +3080,7 @@
 
 sub start_page {
     my ($title,$head_extra,$args) = @_;
+    #&Apache::lonnet::logthis("start_page ".join(':',caller(0)));
     my %head_args;
     if (defined($args->{'redirect'})) {
 	$head_args{'redirect'} = $args->{'redirect'};
@@ -3116,6 +3117,7 @@
 
 sub end_page {
     my ($args) = @_;
+    #&Apache::lonnet::logthis("end_page ".join(':',caller(0)));
     $env{'internal.end_page'}++;
     my $result = &endbodytag()."\n</html>";
     if ($args->{'js_ready'}) {
@@ -3138,11 +3140,13 @@
     if (  exists($env{'internal.start_page'})
 	  &&     $env{'internal.start_page'} > 1) {
 	&Apache::lonnet::logthis('start_page called multiple times '.
+				 $env{'internal.start_page'}.' '.
 				 $ENV{'request.filename'});
     }
     if (  exists($env{'internal.end_page'})
 	  &&     $env{'internal.end_page'} > 1) {
 	&Apache::lonnet::logthis('end_page called multiple times '.
+				 $env{'internal.end_page'}.' '.
 				 $env{'request.filename'});
     }
     if (     exists($env{'internal.start_page'})
@@ -3157,6 +3161,18 @@
     }
 }
 
+sub simple_error_page {
+    my ($r,$title,$msg) = @_;
+    my $page =
+	&Apache::loncommon::start_page($title).
+	&mt($msg).
+	&Apache::loncommon::end_page();
+    if (ref($r)) {
+	$r->print($page);
+	return;
+    }
+    return $page;
+}
 ###############################################
 
 =pod
Index: loncom/interface/lonbulletin.pm
diff -u loncom/interface/lonbulletin.pm:1.33 loncom/interface/lonbulletin.pm:1.34
--- loncom/interface/lonbulletin.pm:1.33	Tue Mar 21 15:41:40 2006
+++ loncom/interface/lonbulletin.pm	Tue Mar 21 16:01:22 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Bulletin Board Handler
 #
-# $Id: lonbulletin.pm,v 1.33 2006/03/21 20:41:40 albertel Exp $
+# $Id: lonbulletin.pm,v 1.34 2006/03/21 21:01:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -50,18 +50,16 @@
     my (undef,undef,undef,undef,$marker)=split(/\//,$r->uri);
 # Is this even in a course?
     if (!$env{'request.course.id'}) {
-	$r->print(&Apache::loncommon::start_page('Not in a course').
-		  &mt('Not in a course').
-		  &Apache::loncommon::end_page());
+	&Apache::loncommon::simple_error_page($r,'Not in a course',
+					      'Not in a course');
         return OK;
     }
 
     $marker=~s/\D//g;
 
     if (!$marker) {
-	$r->print(&Apache::loncommon::start_page('Invalid Call').
-		  &mt('Invalid Call').
-		  &Apache::loncommon::end_page());
+	&Apache::loncommon::simple_error_page($r,'Invalid Call',
+					      'Invalid Call');
         return OK;
     }