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

albertel lon-capa-cvs@mail.lon-capa.org
Sun, 19 Mar 2006 21:43:21 -0000


This is a MIME encoded message

--albertel1142804601
Content-Type: text/plain

albertel		Sun Mar 19 16:43:21 2006 EDT

  Modified files:              
    /loncom/interface	loncommon.pm lonfeedback.pm 
  Log:
  - add redirect abitilies to the head tag and start_page
  - get lonfeedback to use them
  - add function override to start_page
  
  
--albertel1142804601
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20060319164321.txt"

Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.312 loncom/interface/loncommon.pm:1.313
--- loncom/interface/loncommon.pm:1.312	Thu Mar 16 17:12:17 2006
+++ loncom/interface/loncommon.pm	Sun Mar 19 16:43:20 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.312 2006/03/16 22:12:17 albertel Exp $
+# $Id: loncommon.pm,v 1.313 2006/03/19 21:43:20 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2972,13 +2972,20 @@
 =cut
 
 sub headtag {
-    my ($title,$head_extra) = @_;
+    my ($title,$head_extra,$args) = @_;
     
     my $result =
 	'<head>'.
 	&Apache::lonxml::fontsettings().
 	&Apache::lonhtmlcommon::htmlareaheaders();
     
+    if (ref($args->{'redir'})) {
+	my ($time,$url) = @{$args->{'redir'}};
+	$result.=<<ADDMETA
+<meta http-equiv="pragma" content="no-cache" />
+<meta HTTP-EQUIV="Refresh" CONTENT="2; url=$url" />
+ADDMETA
+    }
     if (!defined($title)) {
 	$title = 'The LearningOnline Network with CAPA';
     }
@@ -3041,6 +3048,8 @@
                   add_entries -> additional attributes to add to the  <body>
                   domain      -> force to color decorate a page for a 
                                  specific domain
+                  function    -> force usage of a specific rolish color scheme
+                  redirect    -> ...
 
 =back
 
@@ -3048,10 +3057,16 @@
 
 sub start_page {
     my ($title,$head_extra,$args) = @_;
+    my %head_args;
+    if (defined($args->{'redirect'})) {
+	$head_args{'redirect'} = $args->{'redirect'};
+    }
+
     return 
 	&Apache::lonxml::xmlbegin().
-	&headtag($title,$head_extra).&endheadtag().
-	&bodytag($title,undef,$args->{'add_entries'},$args->{'only_body'},
+	&headtag($title,$head_extra,\%head_args).&endheadtag().
+	&bodytag($title, $args->{'function'}, $args->{'add_entries'},
+		 $args->{'only_body'},
 		 undef,undef,undef,$args->{'no_nav_bar'});
 }
 
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.185 loncom/interface/lonfeedback.pm:1.186
--- loncom/interface/lonfeedback.pm:1.185	Wed Mar 15 17:06:08 2006
+++ loncom/interface/lonfeedback.pm	Sun Mar 19 16:43:21 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.185 2006/03/15 22:06:08 www Exp $
+# $Id: lonfeedback.pm,v 1.186 2006/03/19 21:43:21 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1303,8 +1303,7 @@
   if (exists($env{'form.origpage'})) {
       &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['subject','comment','currnewattach','addnewattach','deloldattach','delnewattach','timestamp','idx','anondiscuss','discuss','blog']);
   }
-  my $bodytag=&Apache::loncommon::bodytag('Resource Feedback and Discussion',
-                                          '','onLoad="window.focus();setposttype();"');
+
   my $title=&Apache::lonnet::gettitle($feedurl);
   if (!$title) { $title = $feedurl; }
   my $quote='';
@@ -1442,15 +1441,8 @@
       &process_attachments(\@currnewattach,\@currdelold,\@keepold);
   }
   my $latexHelp=&Apache::loncommon::helpLatexCheatsheet();
-  my $htmlheader=&Apache::lonhtmlcommon::htmlareaheaders();
   my $send=&mt('Send');
-  my $html=&Apache::lonxml::xmlbegin();
-  $r->print(<<END);
-$html
-<head>
-<title>The LearningOnline Network with CAPA</title>
-<meta http-equiv="pragma" content="no-cache"></meta>
-$htmlheader
+  my $js= <<END;
 <script type="text/javascript">
 //<!--
     function gosubmit() {
@@ -1504,8 +1496,15 @@
     $anonscript
 //-->
 </script>
-</head>
-$bodytag
+END
+
+  my $onload = 'onLoad="window.focus();setposttype();"';
+  my $start_page=
+      &Apache::loncommon::start_page('Resource Feedback and Discussion',$js,
+				     {'add_entries' => $onload});
+
+  $r->print(<<END);
+$start_page
 <h2><tt>$title</tt></h2>
 <form action="/adm/feedback" method="post" name="mailform"
 enctype="multipart/form-data">
@@ -1602,7 +1601,8 @@
     }
     $r->print(&generate_preview_button().
               &Apache::lonhtmlcommon::htmlareaselectactive('comment').
-              '</body></html>');
+	      &Apache::loncommon::end_page());
+
 }
 
 sub print_display_options {
@@ -1978,11 +1978,7 @@
                           $env{'course.'.$env{'request.course.id'}.'.num'});
     my %namesort = ();
     my %postcounts = ();
-    my %lt=&Apache::lonlocal::texthash(
-                     'diso' => 'Discussion filtering options',
-    );
-    my $bodytag=&Apache::loncommon::bodytag('Discussion options',
-                                          '','');
+
     if ($contrib{'version'}) {
         for (my $idx=1;$idx<=$contrib{'version'};$idx++) {
             my $hidden=($contrib{'hidden'}=~/\.$idx\./);
@@ -2014,14 +2010,11 @@
             }
         }
     }
-    my $html=&Apache::lonxml::xmlbegin();
+
+    my $start_page = &Apache::loncommon::start_page('Discussion options');
+
     $r->print(<<END);
-$html
-<head>
-<title>$lt{'diso'}</title>
-<meta http-equiv="pragma" content="no-cache" />
-</head>
-$bodytag
+$start_page
  <form name="pickpostersform" method="post">
   <table border="0">
    <tr>
@@ -2048,6 +2041,8 @@
             }
         }
     }
+
+    my $end_page   = &Apache::loncommon::end_page();
     $r->print(<<END);
      </table>
     </td>
@@ -2058,8 +2053,7 @@
 <input type="hidden" name="userpick" value="$symb" />
 <input type="button" name="store" value="Display posts" onClick="javascript:document.pickpostersform.submit()" />
 </form>
-</body>
-</html>
+$end_page
 END
 }
 
@@ -2067,7 +2061,8 @@
     my ($versions,$incoming,$htmldecode,$numver) = @_;
     if ($incoming =~ /^<version num="0">/) {
         my $p = HTML::LCParser->new(\$incoming);
-        my $done = 0;                                                                       
+        my $done = 0; 
+
         while ( (my $token = $p->get_tag("version")) && (!$done)) {
             my $num = $token->[1]{num};
             my $text = $p->get_text("/version");
@@ -2128,21 +2123,15 @@
   my ($r,$feedurl) = @_;
   if ($feedurl=~/^\/adm\//) { $feedurl.='?register=1' };
   my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');
-  my $html=&Apache::lonxml::xmlbegin();
-  $r->print (<<ENDFAILREDIR);
-$html
-<head>
-<title>Feedback not sent</title>
-<meta http-equiv="pragma" content="no-cache" />
-<meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl" />
-</head>
-<body bgcolor="#FFFFFF">
+  $r->print(&Apache::loncommon::start_page('Feedback not sent',undef,
+					   {'redirect'  => [2,$feedurl],
+					    'only_body' => 1,}));
+  $r->print(<<ENDFAILREDIR);
 <img align="right" src="$logo" />
 <b>Sorry, no recipients  ...</b>
 <br /><a href="$feedurl">Continue</a>
-</body>
-</html>
 ENDFAILREDIR
+  $r->print(&Apache::loncommon::end_page());
 }
 
 sub redirect_back {
@@ -2216,15 +2205,16 @@
   }
   $feedurl=&Apache::lonenc::check_encrypt($feedurl);
   my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');
-  my $html=&Apache::lonxml::xmlbegin();
-  $r->print (<<ENDREDIR);
-$html
-<head>
-<title>Feedback sent</title>
-<meta http-equiv="pragma" content="no-cache" />
-<meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl" />
-</head>
-<body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { this.document.reldt.submit(); self.window.close(); }'>
+  my $onload = 'onLoad=\'if (window.name!="loncapaclient") { this.document.reldt.submit(); self.window.close(); }\'';
+  my $start_page=
+      &Apache::loncommon::start_page('New posts marked as read',undef,
+				     {'redirect'    => [2,$feedurl],
+				      'only_body'   => 1,
+				      'add_entries' => $onload});
+  my $end_page = &Apache::loncommon::end_page();
+
+  $r->print(<<ENDREDIR);
+$start_page
 <img align="right" src="$logo" />
 $typestyle
 <b>Sent $sendsomething message(s), and $sendposts post(s).</b>
@@ -2239,8 +2229,7 @@
 $userpicktag
 </form>
 <br /><a href="$feedurl">Continue</a>
-</body>
-</html>
+$end_page
 ENDREDIR
 }
 
@@ -3125,22 +3114,21 @@
       &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;
       my $logo=&Apache::loncommon::lonhttpdurl('/adm/lonIcons/lonlogos.gif');
-      my $html=&Apache::lonxml::xmlbegin();
+      my $onload = 'onLoad=\'if (window.name!="loncapaclient") { this.document.reldt.submit(); self.window.close(); }\'';
+      my $start_page=
+	  &Apache::loncommon::start_page('New posts marked as read',undef,
+					 {'redirect'    => [2,$feedurl],
+					  'only_body'   => 1,
+					  'add_entries' => $onload});
+      my $end_page = &Apache::loncommon::end_page();
       $r->print (<<ENDREDIR);
-$html
-<head>
-<title>New posts marked as read</title>
-<meta http-equiv="pragma" content="no-cache" />
-<meta HTTP-EQUIV="Refresh" CONTENT="2; url=$feedurl" />
-</head>
-<body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { this.document.reldt.submit(); self.window.close(); }'>
+$start_page
 <img align="right" src="$logo" />
 $textline
 <form name="reldt" action="$feedurl" target="loncapaclient">
 </form>
 <br /><a href="$feedurl">Continue</a>
-</body>
-</html>
+$end_page
 ENDREDIR
       return OK;
   } elsif ($env{'form.modifydisp'}) {

--albertel1142804601--