Skip to content

Commit

Permalink
Optimized core formatting plugin config calls
Browse files Browse the repository at this point in the history
  • Loading branch information
amyreese committed Jul 8, 2009
1 parent a9c15e0 commit d977b97
Showing 1 changed file with 44 additions and 12 deletions.
56 changes: 44 additions & 12 deletions plugins/MantisCoreFormatting/MantisCoreFormatting.php
Expand Up @@ -56,9 +56,15 @@ function config() {
* @return multi Array with formatted text and multiline paramater
*/
function text( $p_event, $p_string, $p_multiline = true ) {
static $s_text;

$t_string = $p_string;

if( ON == plugin_config_get( 'process_text' ) ) {
if( null === $s_text ) {
$s_text = plugin_config_get( 'process_text' );
}

if( ON == $s_text ) {
$t_string = string_strip_hrefs( $t_string );
$t_string = string_html_specialchars( $t_string );
$t_string = string_restore_valid_html_tags( $t_string, /* multiline = */ true );
Expand All @@ -80,9 +86,18 @@ function text( $p_event, $p_string, $p_multiline = true ) {
* @return multi Array with formatted text and multiline paramater
*/
function formatted( $p_event, $p_string, $p_multiline = true ) {
static $s_text, $s_urls, $s_buglinks, $s_vcslinks;

$t_string = $p_string;

if( ON == plugin_config_get( 'process_text' ) ) {
if( null === $s_text ) {
$s_text = plugin_config_get( 'process_text' );
$s_urls = plugin_config_get( 'process_urls' );
$s_buglinks = plugin_config_get( 'process_buglinks' );
$s_vcslinks = plugin_config_get( 'process_vcslinks' );
}

if( ON == $s_text ) {
$t_string = string_strip_hrefs( $t_string );
$t_string = string_html_specialchars( $t_string );
$t_string = string_restore_valid_html_tags( $t_string, /* multiline = */ true );
Expand All @@ -93,16 +108,16 @@ function formatted( $p_event, $p_string, $p_multiline = true ) {
}
}

if( ON == plugin_config_get( 'process_urls' ) ) {
if( ON == $s_urls ) {
$t_string = string_insert_hrefs( $t_string );
}

if( ON == plugin_config_get( 'process_buglinks' ) ) {
if( ON == $s_buglinks ) {
$t_string = string_process_bug_link( $t_string );
$t_string = string_process_bugnote_link( $t_string );
}

if( ON == plugin_config_get( 'process_vcslinks' ) ) {
if( ON == $s_vcslinks ) {
$t_string = string_process_cvs_link( $t_string );
}

Expand All @@ -116,25 +131,34 @@ function formatted( $p_event, $p_string, $p_multiline = true ) {
* @return string Formatted text
*/
function rss( $p_event, $p_string ) {
static $s_text, $s_urls, $s_buglinks, $s_vcslinks;

$t_string = $p_string;

if( ON == plugin_config_get( 'process_text' ) ) {
if( null === $s_text ) {
$s_text = plugin_config_get( 'process_text' );
$s_urls = plugin_config_get( 'process_urls' );
$s_buglinks = plugin_config_get( 'process_buglinks' );
$s_vcslinks = plugin_config_get( 'process_vcslinks' );
}

if( ON == $s_text ) {
$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 );
}

if( ON == plugin_config_get( 'process_urls' ) ) {
if( ON == $s_urls ) {
$t_string = string_insert_hrefs( $t_string );
}

if( ON == plugin_config_get( 'process_buglinks' ) ) {
if( ON == $s_buglinks ) {
$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 );
}

if( ON == plugin_config_get( 'process_vcslinks' ) ) {
if( ON == $s_vcslinks ) {
$t_string = string_process_cvs_link( $t_string );
}

Expand All @@ -148,18 +172,26 @@ function rss( $p_event, $p_string ) {
* @return string Formatted text
*/
function email( $p_event, $p_string ) {
static $s_text, $s_buglinks, $s_vcslinks;

$t_string = $p_string;

if( ON == plugin_config_get( 'process_text' ) ) {
if( null === $s_text ) {
$s_text = plugin_config_get( 'process_text' );
$s_buglinks = plugin_config_get( 'process_buglinks' );
$s_vcslinks = plugin_config_get( 'process_vcslinks' );
}

if( ON == $s_text ) {
$t_string = string_strip_hrefs( $t_string );
}

if( ON == plugin_config_get( 'process_buglinks' ) ) {
if( ON == $s_buglinks ) {
$t_string = string_process_bug_link( $t_string, false );
$t_string = string_process_bugnote_link( $t_string, false );
}

if( ON == plugin_config_get( 'process_vcslinks' ) ) {
if( ON == $s_vcslinks ) {
$t_string = string_process_cvs_link( $t_string, false );
}

Expand Down

0 comments on commit d977b97

Please sign in to comment.