View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0008766 | mantisbt | plug-ins | public | 2008-01-17 19:08 | 2008-04-19 04:10 |
| Reporter | jreese | Assigned To | jreese | ||
| Priority | normal | Severity | feature | Reproducibility | N/A |
| Status | closed | Resolution | fixed | ||
| Target Version | 1.2.0a1 | Fixed in Version | 1.2.0a1 | ||
| Summary | 0008766: Move text processing and formatting to an official plugin | ||||
| Description | In order to better support the future use of plugins to customize the formatted text content in Mantis, the current text formatting system should be updated and moved to an official plugin, so it can be partially or entirely disabled in order to play nicely with other plugins. I already have a working patch for this (attached), that I have tested with and without another plugin that enables Markdown syntax in formatted text inputs. It has three distinct functions: formatting text, formatting URLs, and processing bug/bugnote links. Each piece can be optionally disabled through the plugin config page. The patch adds a schema entry to enable the plugin by default for new installs and upgrades. | ||||
| Tags | patch | ||||
| Attached Files | mantis-format.2008-01-17.patch (13,668 bytes)
diff --git a/admin/schema.php b/admin/schema.php
index fec1314..0001b80 100644
--- a/admin/schema.php
+++ b/admin/schema.php
@@ -389,4 +389,8 @@ $upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_table' ),
$upgrade[] = Array( 'DropTableSQL', Array( db_get_table( 'mantis_project_category_table' ) ) );
$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_project_table' ), "category_id I UNSIGNED NOTNULL DEFAULT '1'" ) );
+$upgrade[] = Array( 'InsertData', Array( db_get_table( 'mantis_plugin_table' ), "
+ ( basename, enabled ) VALUES
+ ( 'format', '1' )" ) );
+
?>
diff --git a/core/string_api.php b/core/string_api.php
index d5f610c..e5a64e6 100644
--- a/core/string_api.php
+++ b/core/string_api.php
@@ -106,49 +106,31 @@
# --------------------
# Prepare a multiple line string for display to HTML
function string_display( $p_string ) {
- $p_string = string_strip_hrefs( $p_string );
- $p_string = string_html_specialchars( $p_string );
- $p_string = string_restore_valid_html_tags( $p_string, /* multiline = */ true );
- $p_string = string_preserve_spaces_at_bol( $p_string );
- $p_string = string_nl2br( $p_string );
-
- return event_signal( 'EVENT_DISPLAY_TEXT', $p_string );
+ $t_data = event_signal( 'EVENT_DISPLAY_TEXT', array( $p_string, true ) );
+ return $t_data[0];
}
# --------------------
# Prepare a single line string for display to HTML
function string_display_line( $p_string ) {
- $p_string = string_strip_hrefs( $p_string );
- $p_string = string_html_specialchars( $p_string );
- $p_string = string_restore_valid_html_tags( $p_string, /* multiline = */ false );
-
- return event_signal( 'EVENT_DISPLAY_TEXT', $p_string );
+ $t_data = event_signal( 'EVENT_DISPLAY_TEXT', array( $p_string, false ) );
+ return $t_data[0];
}
# --------------------
# Prepare a string for display to HTML and add href anchors for URLs, emails,
# bug references, and cvs references
function string_display_links( $p_string ) {
- $p_string = string_display( $p_string );
- $p_string = string_insert_hrefs( $p_string );
- $p_string = string_process_bug_link( $p_string );
- $p_string = string_process_bugnote_link( $p_string );
- $p_string = string_process_cvs_link( $p_string );
-
- return event_signal( 'EVENT_DISPLAY_FORMATTED', $p_string );
+ $t_data = event_signal( 'EVENT_DISPLAY_FORMATTED', array( $p_string, true ) );
+ return $t_data[0];
}
# --------------------
# Prepare a single line string for display to HTML and add href anchors for
# URLs, emails, bug references, and cvs references
function string_display_line_links( $p_string ) {
- $p_string = string_display_line( $p_string );
- $p_string = string_insert_hrefs( $p_string );
- $p_string = string_process_bug_link( $p_string );
- $p_string = string_process_bugnote_link( $p_string );
- $p_string = string_process_cvs_link( $p_string );
-
- return event_signal( 'EVENT_DISPLAY_FORMATTED', $p_string );
+ $t_data = event_signal( 'EVENT_DISPLAY_FORMATTED', array( $p_string, false ) );
+ return $t_data[0];
}
# --------------------
@@ -157,16 +139,6 @@
# rss can not start with which spaces will be replaced into by string_display().
$t_string = trim( $p_string );
- # same steps as string_display_links() without the preservation of spaces since is undefined in XML.
- $t_string = string_strip_hrefs( $t_string );
- $t_string = string_html_specialchars( $t_string );
- $t_string = string_restore_valid_html_tags( $t_string );
- $t_string = string_nl2br( $t_string );
- $t_string = string_insert_hrefs( $t_string );
- $t_string = string_process_bug_link( $t_string, /* anchor */ true, /* detailInfo */ false, /* fqdn */ true );
- $t_string = string_process_bugnote_link( $t_string, /* anchor */ true, /* detailInfo */ false, /* fqdn */ true );
- $t_string = string_process_cvs_link( $t_string );
-
$t_string = event_signal( 'EVENT_DISPLAY_RSS', $t_string );
# another escaping to escape the special characters created by the generated links
@@ -185,12 +157,7 @@
# Prepare a string for plain text display in email and add URLs for bug
# links and cvs links
function string_email_links( $p_string ) {
- $p_string = string_email( $p_string );
- $p_string = string_process_bug_link( $p_string, false );
- $p_string = string_process_bugnote_link( $p_string, false );
- $p_string = string_process_cvs_link( $p_string, false );
-
- return $p_string;
+ return event_signal( 'EVENT_DISPLAY_EMAIL', $p_string );
}
diff --git a/plugins/format/events.php b/plugins/format/events.php
new file mode 100644
index 0000000..13913ca
--- /dev/null
+++ b/plugins/format/events.php
@@ -0,0 +1,104 @@
+<?php
+
+/**
+ * Plain text processing.
+ * @param string Event name
+ * @param string Unformatted text
+ * @param boolean Multiline text
+ * @return multi Array with formatted text and multiline paramater
+ */
+function plugin_event_format_text( $p_event, $p_string, $p_multiline = true ) {
+ if ( ON == plugin_config_get( 'process_text' ) ) {
+ $p_string = string_strip_hrefs( $p_string );
+ $p_string = string_html_specialchars( $p_string );
+ $p_string = string_restore_valid_html_tags( $p_string, /* multiline = */ true );
+
+ if ( $p_multiline ) {
+ $p_string = string_preserve_spaces_at_bol( $p_string );
+ $p_string = string_nl2br( $p_string );
+ }
+ }
+
+ return array( $p_string, $p_multiline );
+}
+
+/**
+ * Formatted text processing.
+ * @param string Event name
+ * @param string Unformatted text
+ * @param boolean Multiline text
+ * @return multi Array with formatted text and multiline paramater
+ */
+function plugin_event_format_formatted( $p_event, $p_string, $p_multiline = true ) {
+ if ( ON == plugin_config_get( 'process_text' ) ) {
+ $p_string = string_strip_hrefs( $p_string );
+ $p_string = string_html_specialchars( $p_string );
+ $p_string = string_restore_valid_html_tags( $p_string, /* multiline = */ true );
+
+ if ( $p_multiline ) {
+ $p_string = string_preserve_spaces_at_bol( $p_string );
+ $p_string = string_nl2br( $p_string );
+ }
+ }
+
+ if ( ON == plugin_config_get( 'process_urls' ) ) {
+ $p_string = string_insert_hrefs( $p_string );
+ }
+
+ if ( ON == plugin_config_get( 'process_buglinks' ) ) {
+ $p_string = string_process_bug_link( $p_string );
+ $p_string = string_process_bugnote_link( $p_string );
+ $p_string = string_process_cvs_link( $p_string );
+ }
+
+ return array( $p_string, $p_multiline );
+}
+
+/**
+ * RSS text processing.
+ * @param string Event name
+ * @param string Unformatted text
+ * @return string Formatted text
+ */
+function plugin_event_format_rss( $p_event, $p_string ) {
+ if ( ON == plugin_config_get( 'process_text' ) ) {
+ $p_string = string_strip_hrefs( $p_string );
+ $p_string = string_html_specialchars( $p_string );
+ $p_string = string_restore_valid_html_tags( $p_string );
+ $p_string = string_nl2br( $p_string );
+ }
+
+ if ( ON == plugin_config_get( 'process_urls' ) ) {
+ $p_string = string_insert_hrefs( $p_string );
+ }
+
+ if ( ON == plugin_config_get( 'process_buglinks' ) ) {
+ $p_string = string_process_bug_link( $p_string, /* anchor */ true, /* detailInfo */ false, /* fqdn */ true );
+ $p_string = string_process_bugnote_link( $p_string, /* anchor */ true, /* detailInfo */ false, /* fqdn */ true );
+ $p_string = string_process_cvs_link( $p_string );
+ }
+
+ return $p_string;
+}
+
+/**
+ * Email text processing.
+ * @param string Event name
+ * @param string Unformatted text
+ * @return string Formatted text
+ */
+function plugin_event_format_email( $p_event, $p_string ) {
+ if ( ON == plugin_config_get( 'process_text' ) ) {
+ $p_string = string_strip_hrefs( $p_string );
+ }
+
+ if ( ON == plugin_config_get( 'process_buglinks' ) ) {
+ $p_string = string_process_bug_link( $p_string, false );
+ $p_string = string_process_bugnote_link( $p_string, false );
+ $p_string = string_process_cvs_link( $p_string, false );
+ }
+
+ return $p_string;
+}
+
+
diff --git a/plugins/format/lang/strings_english.txt b/plugins/format/lang/strings_english.txt
new file mode 100644
index 0000000..68d2ba9
--- /dev/null
+++ b/plugins/format/lang/strings_english.txt
@@ -0,0 +1,13 @@
+<?php
+
+$s_plugin_format_title = 'Mantis Formatting';
+$s_plugin_format_description = 'Standard text processing and formatting plugin for the Mantis Bug Tracker.';
+
+$s_plugin_format_config = 'Configuration';
+$s_plugin_format_process_text = 'Text Processing';
+$s_plugin_format_process_urls = 'URL Processing';
+$s_plugin_format_process_buglinks = 'Mantis Links ( Bug/Bugnote )';
+
+$s_plugin_format_on = 'On';
+$s_plugin_format_off = 'Off';
+$s_plugin_format_save = 'Save Configuration';
diff --git a/plugins/format/pages/config.php b/plugins/format/pages/config.php
new file mode 100644
index 0000000..7868331
--- /dev/null
+++ b/plugins/format/pages/config.php
@@ -0,0 +1,76 @@
+<?php
+
+auth_reauthenticate();
+access_ensure_global_level( config_get( 'manage_plugin_threshold' ) );
+
+html_page_top1( lang_get( 'plugin_format_title' ) );
+html_page_top2();
+
+print_manage_menu();
+
+?>
+
+<br/>
+<form action="<?php echo plugin_page( 'config_edit' ) ?>" method="post">
+<table align="center" class="width50" cellspacing="1">
+
+<tr>
+ <td class="form-title" colspan="3">
+ <?php echo lang_get( 'plugin_format_title' ) . ': ' . lang_get( 'plugin_format_config' ) ?>
+ </td>
+</tr>
+
+<tr <?php echo helper_alternate_class() ?>>
+ <td class="category" width="60%">
+ <?php echo lang_get( 'plugin_format_process_text' ) ?>
+ </td>
+ <td class="center" width="20%">
+ <label><input type="radio" name="process_text" value="1" <?php echo ( ON == plugin_config_get( 'process_text' ) ) ? 'checked="checked" ' : ''?>/>
+ <?php echo lang_get( 'plugin_format_on' ) ?></label>
+ </td>
+ <td class="center" width="20%">
+ <label><input type="radio" name="process_text" value="0" <?php echo ( OFF == plugin_config_get( 'process_text' ) ) ? 'checked="checked" ' : ''?>/>
+ <?php echo lang_get( 'plugin_format_off' ) ?></label>
+ </td>
+</tr>
+
+<tr <?php echo helper_alternate_class() ?>>
+ <td class="category">
+ <?php echo lang_get( 'plugin_format_process_urls' ) ?>
+ </td>
+ <td class="center">
+ <label><input type="radio" name="process_urls" value="1" <?php echo ( ON == plugin_config_get( 'process_urls' ) ) ? 'checked="checked" ' : ''?>/>
+ <?php echo lang_get( 'plugin_format_on' ) ?></label>
+ </td>
+ <td class="center">
+ <label><input type="radio" name="process_urls" value="0" <?php echo ( OFF == plugin_config_get( 'process_urls' ) ) ? 'checked="checked" ' : ''?>/>
+ <?php echo lang_get( 'plugin_format_off' ) ?></label>
+ </td>
+</tr>
+
+<tr <?php echo helper_alternate_class() ?>>
+ <td class="category">
+ <?php echo lang_get( 'plugin_format_process_buglinks' ) ?>
+ </td>
+ <td class="center">
+ <label><input type="radio" name="process_buglinks" value="1" <?php echo ( ON == plugin_config_get( 'process_buglinks' ) ) ? 'checked="checked" ' : ''?>/>
+ <?php echo lang_get( 'plugin_format_on' ) ?></label>
+ </td>
+ <td class="center">
+ <label><input type="radio" name="process_buglinks" value="0" <?php echo ( OFF == plugin_config_get( 'process_buglinks' ) ) ? 'checked="checked" ' : ''?>/>
+ <?php echo lang_get( 'plugin_format_off' ) ?></label>
+ </td>
+</tr>
+
+<tr>
+ <td class="center" colspan="3">
+ <input type="submit" class="button" value="<?php echo lang_get( 'plugin_format_save' ) ?>" />
+ </td>
+</tr>
+
+</table>
+<form>
+
+<?php
+html_page_bottom1( __FILE__ );
+
diff --git a/plugins/format/pages/config_edit.php b/plugins/format/pages/config_edit.php
new file mode 100644
index 0000000..2ce6e5a
--- /dev/null
+++ b/plugins/format/pages/config_edit.php
@@ -0,0 +1,23 @@
+<?php
+
+auth_reauthenticate();
+access_ensure_global_level( config_get( 'manage_plugin_threshold' ) );
+
+$f_process_text = gpc_get_int( 'process_text', ON );
+$f_process_urls = gpc_get_int( 'process_urls', ON );
+$f_process_mantis_links = gpc_get_int( 'process_buglinks', ON );
+
+if ( plugin_config_get( 'process_text' ) != $f_process_text ) {
+ plugin_config_set( 'process_text', $f_process_text );
+}
+
+if ( plugin_config_get( 'process_urls' ) != $f_process_urls ) {
+ plugin_config_set( 'process_urls', $f_process_urls );
+}
+
+if ( plugin_config_get( 'process_buglinks' ) != $f_process_buglinks ) {
+ plugin_config_set( 'process_buglinks', $f_process_buglinks );
+}
+
+print_successful_redirect( plugin_page( 'config' ) );
+
diff --git a/plugins/format/register.php b/plugins/format/register.php
new file mode 100644
index 0000000..1a7bab7
--- /dev/null
+++ b/plugins/format/register.php
@@ -0,0 +1,51 @@
+<?php
+
+/**
+ * Plugin information.
+ */
+function plugin_callback_format_info() {
+ return array(
+ 'name' => lang_get( 'plugin_format_title' ),
+ 'description' => lang_get( 'plugin_format_description' ),
+ 'version' => '0.1',
+ 'author' => 'Mantis Team',
+ 'contact' => 'mantisbt-dev@lists.sourceforge.net',
+ 'url' => 'http://www.mantisbt.org',
+ 'page' => 'config',
+ 'requires' => array(
+ 'mantis' => '1.2.0',
+ ),
+ );
+}
+
+/**
+ * Default plugin configuration.
+ */
+function plugin_callback_format_config() {
+ return array(
+ 'process_text' => ON,
+ 'process_urls' => ON,
+ 'process_buglinks' => ON,
+ );
+}
+
+/**
+ * Event hook declaration.
+ */
+function plugin_callback_format_hook() {
+ return array(
+
+ # Text String Display
+ 'EVENT_DISPLAY_TEXT' => 'text',
+
+ # Formatted String Display
+ 'EVENT_DISPLAY_FORMATTED' => 'formatted',
+
+ # RSS String Display
+ 'EVENT_DISPLAY_RSS' => 'rss',
+
+ # Email String Display
+ 'EVENT_DISPLAY_EMAIL' => 'email',
+
+ );
+}
mantis-format.2008-01-18.patch (14,555 bytes)
diff --git a/admin/schema.php b/admin/schema.php
index fec1314..0001b80 100644
--- a/admin/schema.php
+++ b/admin/schema.php
@@ -389,4 +389,8 @@ $upgrade[] = Array( 'DropColumnSQL', Array( db_get_table( 'mantis_bug_table' ),
$upgrade[] = Array( 'DropTableSQL', Array( db_get_table( 'mantis_project_category_table' ) ) );
$upgrade[] = Array( 'AddColumnSQL', Array( db_get_table( 'mantis_project_table' ), "category_id I UNSIGNED NOTNULL DEFAULT '1'" ) );
+$upgrade[] = Array( 'InsertData', Array( db_get_table( 'mantis_plugin_table' ), "
+ ( basename, enabled ) VALUES
+ ( 'format', '1' )" ) );
+
?>
diff --git a/core/string_api.php b/core/string_api.php
index d5f610c..e5a64e6 100644
--- a/core/string_api.php
+++ b/core/string_api.php
@@ -106,49 +106,31 @@
# --------------------
# Prepare a multiple line string for display to HTML
function string_display( $p_string ) {
- $p_string = string_strip_hrefs( $p_string );
- $p_string = string_html_specialchars( $p_string );
- $p_string = string_restore_valid_html_tags( $p_string, /* multiline = */ true );
- $p_string = string_preserve_spaces_at_bol( $p_string );
- $p_string = string_nl2br( $p_string );
-
- return event_signal( 'EVENT_DISPLAY_TEXT', $p_string );
+ $t_data = event_signal( 'EVENT_DISPLAY_TEXT', array( $p_string, true ) );
+ return $t_data[0];
}
# --------------------
# Prepare a single line string for display to HTML
function string_display_line( $p_string ) {
- $p_string = string_strip_hrefs( $p_string );
- $p_string = string_html_specialchars( $p_string );
- $p_string = string_restore_valid_html_tags( $p_string, /* multiline = */ false );
-
- return event_signal( 'EVENT_DISPLAY_TEXT', $p_string );
+ $t_data = event_signal( 'EVENT_DISPLAY_TEXT', array( $p_string, false ) );
+ return $t_data[0];
}
# --------------------
# Prepare a string for display to HTML and add href anchors for URLs, emails,
# bug references, and cvs references
function string_display_links( $p_string ) {
- $p_string = string_display( $p_string );
- $p_string = string_insert_hrefs( $p_string );
- $p_string = string_process_bug_link( $p_string );
- $p_string = string_process_bugnote_link( $p_string );
- $p_string = string_process_cvs_link( $p_string );
-
- return event_signal( 'EVENT_DISPLAY_FORMATTED', $p_string );
+ $t_data = event_signal( 'EVENT_DISPLAY_FORMATTED', array( $p_string, true ) );
+ return $t_data[0];
}
# --------------------
# Prepare a single line string for display to HTML and add href anchors for
# URLs, emails, bug references, and cvs references
function string_display_line_links( $p_string ) {
- $p_string = string_display_line( $p_string );
- $p_string = string_insert_hrefs( $p_string );
- $p_string = string_process_bug_link( $p_string );
- $p_string = string_process_bugnote_link( $p_string );
- $p_string = string_process_cvs_link( $p_string );
-
- return event_signal( 'EVENT_DISPLAY_FORMATTED', $p_string );
+ $t_data = event_signal( 'EVENT_DISPLAY_FORMATTED', array( $p_string, false ) );
+ return $t_data[0];
}
# --------------------
@@ -157,16 +139,6 @@
# rss can not start with which spaces will be replaced into by string_display().
$t_string = trim( $p_string );
- # same steps as string_display_links() without the preservation of spaces since is undefined in XML.
- $t_string = string_strip_hrefs( $t_string );
- $t_string = string_html_specialchars( $t_string );
- $t_string = string_restore_valid_html_tags( $t_string );
- $t_string = string_nl2br( $t_string );
- $t_string = string_insert_hrefs( $t_string );
- $t_string = string_process_bug_link( $t_string, /* anchor */ true, /* detailInfo */ false, /* fqdn */ true );
- $t_string = string_process_bugnote_link( $t_string, /* anchor */ true, /* detailInfo */ false, /* fqdn */ true );
- $t_string = string_process_cvs_link( $t_string );
-
$t_string = event_signal( 'EVENT_DISPLAY_RSS', $t_string );
# another escaping to escape the special characters created by the generated links
@@ -185,12 +157,7 @@
# Prepare a string for plain text display in email and add URLs for bug
# links and cvs links
function string_email_links( $p_string ) {
- $p_string = string_email( $p_string );
- $p_string = string_process_bug_link( $p_string, false );
- $p_string = string_process_bugnote_link( $p_string, false );
- $p_string = string_process_cvs_link( $p_string, false );
-
- return $p_string;
+ return event_signal( 'EVENT_DISPLAY_EMAIL', $p_string );
}
diff --git a/plugins/format/events.php b/plugins/format/events.php
new file mode 100644
index 0000000..e936d15
--- /dev/null
+++ b/plugins/format/events.php
@@ -0,0 +1,113 @@
+<?php
+
+/**
+ * Plain text processing.
+ * @param string Event name
+ * @param string Unformatted text
+ * @param boolean Multiline text
+ * @return multi Array with formatted text and multiline paramater
+ */
+function plugin_event_format_text( $p_event, $p_string, $p_multiline = true ) {
+ if ( ON == plugin_config_get( 'process_text' ) ) {
+ $p_string = string_strip_hrefs( $p_string );
+ $p_string = string_html_specialchars( $p_string );
+ $p_string = string_restore_valid_html_tags( $p_string, /* multiline = */ true );
+
+ if ( $p_multiline ) {
+ $p_string = string_preserve_spaces_at_bol( $p_string );
+ $p_string = string_nl2br( $p_string );
+ }
+ }
+
+ return array( $p_string, $p_multiline );
+}
+
+/**
+ * Formatted text processing.
+ * @param string Event name
+ * @param string Unformatted text
+ * @param boolean Multiline text
+ * @return multi Array with formatted text and multiline paramater
+ */
+function plugin_event_format_formatted( $p_event, $p_string, $p_multiline = true ) {
+ if ( ON == plugin_config_get( 'process_text' ) ) {
+ $p_string = string_strip_hrefs( $p_string );
+ $p_string = string_html_specialchars( $p_string );
+ $p_string = string_restore_valid_html_tags( $p_string, /* multiline = */ true );
+
+ if ( $p_multiline ) {
+ $p_string = string_preserve_spaces_at_bol( $p_string );
+ $p_string = string_nl2br( $p_string );
+ }
+ }
+
+ if ( ON == plugin_config_get( 'process_urls' ) ) {
+ $p_string = string_insert_hrefs( $p_string );
+ }
+
+ if ( ON == plugin_config_get( 'process_buglinks' ) ) {
+ $p_string = string_process_bug_link( $p_string );
+ $p_string = string_process_bugnote_link( $p_string );
+ }
+
+ if ( ON == plugin_config_get( 'process_vcslinks' ) ) {
+ $p_string = string_process_cvs_link( $p_string );
+ }
+
+ return array( $p_string, $p_multiline );
+}
+
+/**
+ * RSS text processing.
+ * @param string Event name
+ * @param string Unformatted text
+ * @return string Formatted text
+ */
+function plugin_event_format_rss( $p_event, $p_string ) {
+ if ( ON == plugin_config_get( 'process_text' ) ) {
+ $p_string = string_strip_hrefs( $p_string );
+ $p_string = string_html_specialchars( $p_string );
+ $p_string = string_restore_valid_html_tags( $p_string );
+ $p_string = string_nl2br( $p_string );
+ }
+
+ if ( ON == plugin_config_get( 'process_urls' ) ) {
+ $p_string = string_insert_hrefs( $p_string );
+ }
+
+ if ( ON == plugin_config_get( 'process_buglinks' ) ) {
+ $p_string = string_process_bug_link( $p_string, /* anchor */ true, /* detailInfo */ false, /* fqdn */ true );
+ $p_string = string_process_bugnote_link( $p_string, /* anchor */ true, /* detailInfo */ false, /* fqdn */ true );
+ }
+
+ if ( ON == plugin_config_get( 'process_vcslinks' ) ) {
+ $p_string = string_process_cvs_link( $p_string );
+ }
+
+ return $p_string;
+}
+
+/**
+ * Email text processing.
+ * @param string Event name
+ * @param string Unformatted text
+ * @return string Formatted text
+ */
+function plugin_event_format_email( $p_event, $p_string ) {
+ if ( ON == plugin_config_get( 'process_text' ) ) {
+ $p_string = string_strip_hrefs( $p_string );
+ }
+
+ if ( ON == plugin_config_get( 'process_buglinks' ) ) {
+ $p_string = string_process_bug_link( $p_string, false );
+ $p_string = string_process_bugnote_link( $p_string, false );
+ }
+
+ if ( ON == plugin_config_get( 'process_vcslinks' ) ) {
+ $p_string = string_process_cvs_link( $p_string, false );
+ }
+
+ return $p_string;
+}
+
+
diff --git a/plugins/format/lang/strings_english.txt b/plugins/format/lang/strings_english.txt
new file mode 100644
index 0000000..b7e5ef2
--- /dev/null
+++ b/plugins/format/lang/strings_english.txt
@@ -0,0 +1,10 @@
+<?php
+
+$s_plugin_format_title = 'Mantis Formatting';
+$s_plugin_format_description = 'Standard text processing and formatting plugin for the Mantis Bug Tracker.';
+
+$s_plugin_format_config = 'Configuration';
+$s_plugin_format_process_text = 'Text Processing';
+$s_plugin_format_process_urls = 'URL Processing';
+$s_plugin_format_process_buglinks = 'Mantis Links ( Bug/Bugnote )';
+$s_plugin_format_process_vcslinks = 'VCS Links';
diff --git a/plugins/format/pages/config.php b/plugins/format/pages/config.php
new file mode 100644
index 0000000..225d710
--- /dev/null
+++ b/plugins/format/pages/config.php
@@ -0,0 +1,90 @@
+<?php
+
+auth_reauthenticate();
+access_ensure_global_level( config_get( 'manage_plugin_threshold' ) );
+
+html_page_top1( lang_get( 'plugin_format_title' ) );
+html_page_top2();
+
+print_manage_menu();
+
+?>
+
+<br/>
+<form action="<?php echo plugin_page( 'config_edit' ) ?>" method="post">
+<table align="center" class="width50" cellspacing="1">
+
+<tr>
+ <td class="form-title" colspan="3">
+ <?php echo lang_get( 'plugin_format_title' ) . ': ' . lang_get( 'plugin_format_config' ) ?>
+ </td>
+</tr>
+
+<tr <?php echo helper_alternate_class() ?>>
+ <td class="category" width="60%">
+ <?php echo lang_get( 'plugin_format_process_text' ) ?>
+ </td>
+ <td class="center" width="20%">
+ <label><input type="radio" name="process_text" value="1" <?php echo ( ON == plugin_config_get( 'process_text' ) ) ? 'checked="checked" ' : ''?>/>
+ <?php echo lang_get( 'on' ) ?></label>
+ </td>
+ <td class="center" width="20%">
+ <label><input type="radio" name="process_text" value="0" <?php echo ( OFF == plugin_config_get( 'process_text' ) ) ? 'checked="checked" ' : ''?>/>
+ <?php echo lang_get( 'off' ) ?></label>
+ </td>
+</tr>
+
+<tr <?php echo helper_alternate_class() ?>>
+ <td class="category">
+ <?php echo lang_get( 'plugin_format_process_urls' ) ?>
+ </td>
+ <td class="center">
+ <label><input type="radio" name="process_urls" value="1" <?php echo ( ON == plugin_config_get( 'process_urls' ) ) ? 'checked="checked" ' : ''?>/>
+ <?php echo lang_get( 'on' ) ?></label>
+ </td>
+ <td class="center">
+ <label><input type="radio" name="process_urls" value="0" <?php echo ( OFF == plugin_config_get( 'process_urls' ) ) ? 'checked="checked" ' : ''?>/>
+ <?php echo lang_get( 'off' ) ?></label>
+ </td>
+</tr>
+
+<tr <?php echo helper_alternate_class() ?>>
+ <td class="category">
+ <?php echo lang_get( 'plugin_format_process_buglinks' ) ?>
+ </td>
+ <td class="center">
+ <label><input type="radio" name="process_buglinks" value="1" <?php echo ( ON == plugin_config_get( 'process_buglinks' ) ) ? 'checked="checked" ' : ''?>/>
+ <?php echo lang_get( 'on' ) ?></label>
+ </td>
+ <td class="center">
+ <label><input type="radio" name="process_buglinks" value="0" <?php echo ( OFF == plugin_config_get( 'process_buglinks' ) ) ? 'checked="checked" ' : ''?>/>
+ <?php echo lang_get( 'off' ) ?></label>
+ </td>
+</tr>
+
+<tr <?php echo helper_alternate_class() ?>>
+ <td class="category">
+ <?php echo lang_get( 'plugin_format_process_vcslinks' ) ?>
+ </td>
+ <td class="center">
+ <label><input type="radio" name="process_vcslinks" value="1" <?php echo ( ON == plugin_config_get( 'process_vcslinks' ) ) ? 'checked="checked" ' : ''?>/>
+ <?php echo lang_get( 'on' ) ?></label>
+ </td>
+ <td class="center">
+ <label><input type="radio" name="process_vcslinks" value="0" <?php echo ( OFF == plugin_config_get( 'process_vcslinks' ) ) ? 'checked="checked" ' : ''?>/>
+ <?php echo lang_get( 'off' ) ?></label>
+ </td>
+</tr>
+
+<tr>
+ <td class="center" colspan="3">
+ <input type="submit" class="button" value="<?php echo lang_get( 'change_configuration' ) ?>" />
+ </td>
+</tr>
+
+</table>
+<form>
+
+<?php
+html_page_bottom1( __FILE__ );
+
diff --git a/plugins/format/pages/config_edit.php b/plugins/format/pages/config_edit.php
new file mode 100644
index 0000000..48b1df4
--- /dev/null
+++ b/plugins/format/pages/config_edit.php
@@ -0,0 +1,28 @@
+<?php
+
+auth_reauthenticate();
+access_ensure_global_level( config_get( 'manage_plugin_threshold' ) );
+
+$f_process_text = gpc_get_int( 'process_text', ON );
+$f_process_urls = gpc_get_int( 'process_urls', ON );
+$f_process_buglinks = gpc_get_int( 'process_buglinks', ON );
+$f_process_vcslinks = gpc_get_int( 'process_vcslinks', ON );
+
+if ( plugin_config_get( 'process_text' ) != $f_process_text ) {
+ plugin_config_set( 'process_text', $f_process_text );
+}
+
+if ( plugin_config_get( 'process_urls' ) != $f_process_urls ) {
+ plugin_config_set( 'process_urls', $f_process_urls );
+}
+
+if ( plugin_config_get( 'process_buglinks' ) != $f_process_buglinks ) {
+ plugin_config_set( 'process_buglinks', $f_process_buglinks );
+}
+
+if ( plugin_config_get( 'process_vcslinks' ) != $f_process_vcslinks ) {
+ plugin_config_set( 'process_vcslinks', $f_process_vcslinks );
+}
+
+print_successful_redirect( plugin_page( 'config' ) );
+
diff --git a/plugins/format/register.php b/plugins/format/register.php
new file mode 100644
index 0000000..fff2696
--- /dev/null
+++ b/plugins/format/register.php
@@ -0,0 +1,52 @@
+<?php
+
+/**
+ * Plugin information.
+ */
+function plugin_callback_format_info() {
+ return array(
+ 'name' => lang_get( 'plugin_format_title' ),
+ 'description' => lang_get( 'plugin_format_description' ),
+ 'version' => '0.1',
+ 'author' => 'Mantis Team',
+ 'contact' => 'mantisbt-dev@lists.sourceforge.net',
+ 'url' => 'http://www.mantisbt.org',
+ 'page' => 'config',
+ 'requires' => array(
+ 'mantis' => '1.2.0',
+ ),
+ );
+}
+
+/**
+ * Default plugin configuration.
+ */
+function plugin_callback_format_config() {
+ return array(
+ 'process_text' => ON,
+ 'process_urls' => ON,
+ 'process_buglinks' => ON,
+ 'process_vcslinks' => ON,
+ );
+}
+
+/**
+ * Event hook declaration.
+ */
+function plugin_callback_format_hook() {
+ return array(
+
+ # Text String Display
+ 'EVENT_DISPLAY_TEXT' => 'text',
+
+ # Formatted String Display
+ 'EVENT_DISPLAY_FORMATTED' => 'formatted',
+
+ # RSS String Display
+ 'EVENT_DISPLAY_RSS' => 'rss',
+
+ # Email String Display
+ 'EVENT_DISPLAY_EMAIL' => 'email',
+
+ );
+}
| ||||
|
Hi John, here is my first take on it:
|
|
|
|
|
Added a new patch with changes suggested by Victor. |
|
|
Changeset has been committed to trunk, SVN r4933. |
|