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

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 15 Mar 2006 19:37:55 -0000


albertel		Wed Mar 15 14:37:55 2006 EDT

  Modified files:              
    /loncom/interface	loncommon.pm 
  Log:
  - adding a variety of helper functions for page starting/ending
     &head 
     &headtag
     &endheadtag
     &start_page
     &end_page
   
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.305 loncom/interface/loncommon.pm:1.306
--- loncom/interface/loncommon.pm:1.305	Sat Mar  4 16:32:30 2006
+++ loncom/interface/loncommon.pm	Wed Mar 15 14:37:55 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.305 2006/03/04 21:32:30 www Exp $
+# $Id: loncommon.pm,v 1.306 2006/03/15 19:37:55 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2931,7 +2931,7 @@
 
 =back
 
-=head1 HTTP Helpers
+=head1 HTML Helpers
 
 =over 4
 
@@ -2939,14 +2939,10 @@
 
 Returns a uniform footer for LON-CAPA web pages.
 
-Inputs: 
-
-=over 4
+Inputs: none
 
 =back
 
-Returns: A uniform footer for LON-CAPA web pages.  
-
 =cut
 
 sub endbodytag {
@@ -2955,10 +2951,117 @@
     return $endbodytag;
 }
 
+=pod
+
+=over 4
+
+=item * &headtag()
+
+Returns a uniform footer for LON-CAPA web pages.
+
+Inputs: $title - optinal title for the head
+
+=back
+
+=cut
+
+sub headtag {
+    my ($title) = @_;
+    
+    my $result = '<head>';
+    
+    if (!defined($title)) {
+	$title = 'The LearningOnline Network with CAPA';
+    }
+    
+    $result .= '<title>'.&mt($title).'</title>';
+    
+    return $result;
+}
+
+=pod
+
+=over 4
+
+=item * &endheadtag()
+
+Returns a uniform </head> for LON-CAPA web pages.
+
+Inputs: none
+
+=back
+
+=cut
+
+sub endheadtag {
+    return '</head>';
+}
+
+=pod
+
+=over 4
+
+=item * &head()
+
+Returns a uniform complete <head>..</head> section for LON-CAPA web pages.
+
+Inputs: $title - optional title for the page
+
+=back
+
+=cut
+
+sub head {
+    my ($title) = @_;
+    return &headtag($title).&endheadtag();
+}
+
+=pod
+
+=over 4
+
+=item * &start_page()
+
+Returns a complete <html> .. <body> section for LON-CAPA web pages.
+
+Inputs: $title - optional title for the page
+        $head_extra - optional extra HTML to incude inside the <head>
+
+=back
+
+=cut
+
+sub start_page {
+    my ($title,$head_extra) = @_;
+    return 
+	&Apache::lonxml::xmlbegin().
+	&headtag($title).$head_extra.&endheadtag().
+	&bodytag($title);
+}
+
+=pod
+
+=over 4
+
+=item * &head()
+
+Returns a complete </body></html> section for LON-CAPA web pages.
+
+Inputs: None
+
+=back
+
+=cut
+
+sub end_page {
+    return &endbodytag."\n</html>";
+}
 ###############################################
 
 =pod
 
+=over 4
+
 =item get_users_function
 
 Used by &bodytag to determine the current users primary role.