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

raeburn raeburn@source.lon-capa.org
Sun, 24 Jan 2010 19:58:25 -0000


raeburn		Sun Jan 24 19:58:25 2010 EDT

  Modified files:              
    /loncom/interface	lonfeedback.pm 
  Log:
  - Simplify regexp in &contains_block_html().
  - Coding style - indentation in &contains_block_html().
  - Use &contains_block_html() to eliminate unwanted <br /> in display
    of discussion posts composed in Rich Text Editor.
  - On post composition page decode() encoded HTML when displaying post 
    to which user is replying. 
  
  
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.285 loncom/interface/lonfeedback.pm:1.286
--- loncom/interface/lonfeedback.pm:1.285	Sun Jan 24 15:30:04 2010
+++ loncom/interface/lonfeedback.pm	Sun Jan 24 19:58:24 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.285 2010/01/24 15:30:04 raeburn Exp $
+# $Id: lonfeedback.pm,v 1.286 2010/01/24 19:58:24 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1396,7 +1396,9 @@
         my ($timesent,$attachmsg);
         my %currattach = ();
         $timesent = &Apache::lonlocal::locallocaltime($postversions[$i]);
-	&newline_to_br(\$messages->{$i});
+        unless (&contains_block_html($messages->{$i})) {
+            &newline_to_br(\$messages->{$i});
+        }
         $$messages{$i}=&Apache::lontexconvert::msgtexconverted($$messages{$i});
         $$subjects{$i}=~s/\n/\<br \/\>/g;
         $$subjects{$i}=&Apache::lontexconvert::msgtexconverted($$subjects{$i});
@@ -1675,7 +1677,10 @@
                                       'bread_crumbs' => $brcrum,});
 
   if ($quote ne '') {
-      &newline_to_br(\$quote);
+      $quote = &HTML::Entities::decode($quote);
+      unless (&contains_block_html($quote)) {
+          &newline_to_br(\$quote);
+      }
       $quote='<blockquote>'.&Apache::lontexconvert::msgtexconverted($quote).'</blockquote>';
   }
 
@@ -2950,16 +2955,17 @@
 }
 
 sub contains_block_html {
-	my ($message)=@_;
-	return ($message =~ m/
-		<(br|h1|h2|h3|h4|h5|h6|p|ol|ul|table|pre|address|blockquote|center|div) 
-		  [\s]*
-		 ([\w]+\=['"][\w]+['"])*
-		  [\s]*
-		(
-		  [\s]*[\/]>|
-		  >.*<\/\1[\s]*>
-		)/xs );
+    my ($message)=@_;
+    return ($message =~ m{
+        <(br|h1|h2|h3|h4|h5|h6|p|ol|ul|table|pre|address|blockquote|center|div) 
+	  \s*
+	 (\w+\=['"]\w+['"])*
+	  \s*
+	(
+	  \s*/>|
+	  >.*</\1\s*>
+	)}xs 
+    );
 }
 
 sub tidy_html {