View Issue Details

IDProjectCategoryView StatusLast Update
0011037mantisbtcustomizationpublic2009-10-24 01:15
Reportercmfitch1 Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
Status newResolutionopen 
Summary0011037: Add a config option to force textarea fields to display as preformatted text on bug view page
Description

Our Mantis users often copy and paste text into reports that needs the spacing preserved. Instead of requiring them to use pre tags, we would like to be able to configure Mantis to always display textarea fields with pre tags on the bug view page.

Tagspatch
Attached Files
issue_11037_b.patch (2,750 bytes)   
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

issue_11037_b.patch (2,750 bytes)   

Activities

cmfitch1

cmfitch1

2009-10-14 10:14

reporter   ~0023189

I uploaded a new patch that covers the view revisions page that I forgot. Please remove the original patch. Thanks!

cmfitch1

cmfitch1

2009-10-16 12:49

reporter   ~0023216

I needed to call string_nl2br to deal with the extra newlines between pre tags and didn't. issue_11037_b.patch includes this fix. Please delete the previous two patches.