From 09953197410072908a7e6b246e18369206b17d90 Mon Sep 17 00:00:00 2001
From: Chris Fitch <cfitch@redcom.com>
Date: Tue, 13 Oct 2009 16:50:29 -0400
Subject: [PATCH] Add config option for preformatted long text


diff --git a/bug_revision_view_page.php b/bug_revision_view_page.php
index fe56781..a707825 100644
--- a/bug_revision_view_page.php
+++ b/bug_revision_view_page.php
@@ -114,7 +114,13 @@ $t_by_string = sprintf( lang_get( 'revision_by' ), string_display_line( date( co
 
 <tr <?php echo helper_alternate_class() ?>>
 <td class="category"><?php echo $t_label ?></td>
-<td colspan="3"><?php echo string_display_links( $t_revision['value'] ) ?></td>
+<td colspan="3"><?php
+if ( ON == config_get( 'preformatted_long_text' ) ) {
+	echo string_nl2br("<pre>" . string_display_links( $t_revision['value'] ) . "</pre>");;
+} else {
+	echo string_display_links( $t_revision['value'] );; 
+}
+?></td>
 </tr>
 
 	<?php
diff --git a/bug_view_inc.php b/bug_view_inc.php
index 639c40c..55a2264 100644
--- a/bug_view_inc.php
+++ b/bug_view_inc.php
@@ -193,6 +193,12 @@
 	$tpl_steps_to_reproduce = $tpl_show_steps_to_reproduce ? string_display_links( $tpl_bug->steps_to_reproduce ) : '';
 	$tpl_additional_information = $tpl_show_additional_information ? string_display_links( $tpl_bug->additional_information ) : '';
 
+	if ( ON == config_get( 'preformatted_long_text' ) ) {
+		$tpl_description = string_nl2br("<pre>" . $tpl_description . "</pre>");
+		$tpl_steps_to_reproduce = string_nl2br("<pre>" . $tpl_steps_to_reproduce . "</pre>");
+		$tpl_additional_information = string_nl2br("<pre>" . $tpl_additional_information . "</pre>");
+	}
+
 	$tpl_links = event_signal( 'EVENT_MENU_ISSUE', $f_bug_id );
 
 	#
diff --git a/bugnote_view_inc.php b/bugnote_view_inc.php
index 6d4775b..6ded840 100644
--- a/bugnote_view_inc.php
+++ b/bugnote_view_inc.php
@@ -197,7 +197,11 @@ $num_notes = count( $t_bugnotes );
 					break;
 			}
 
-			echo string_display_links( $t_bugnote->note );;
+			if ( ON == $g_preformatted_long_text ) {
+				echo string_nl2br("<pre>" . string_display_links( $t_bugnote->note ) . "</pre>");;
+			} else {
+				echo string_display_links( $t_bugnote->note );;
+			}
 		?>
 	</td>
 </tr>
diff --git a/config_defaults_inc.php b/config_defaults_inc.php
index a97c221..4a94956 100644
--- a/config_defaults_inc.php
+++ b/config_defaults_inc.php
@@ -1713,6 +1713,14 @@
 	 */
 	$g_wrap_in_preformatted_text = ON;
 
+	/**
+	 * This flag controls whether long text fields (description, bugnotes,
+	 * etc.) are displayed on the view page as preformatted text.
+	 * @global int $g_preformatted_long_text
+	 */
+	$g_preformatted_long_text = OFF;
+
+
 	/************************
 	 * MantisBT HR Settings *
 	 ************************/
-- 
1.6.0.4

