diff -pur mantis-1.1.1.orig/core/custom_field_api.php mantis-1.1.1.octo/core/custom_field_api.php --- mantis-1.1.1.orig/core/custom_field_api.php 2007-10-14 00:36:41.000000000 +0200 +++ mantis-1.1.1.octo/core/custom_field_api.php 2008-03-28 11:57:56.000000000 +0100 @@ -1266,30 +1266,12 @@ # -------------------- # Prepare a string containing a custom field value for display - # $p_def contains the definition of the custom field # $p_field_id contains the id of the field # $p_bug_id contains the bug id to display the custom field value for # NOTE: This probably belongs in the string_api.php - function string_custom_field_value( $p_def, $p_field_id, $p_bug_id ) { - $t_custom_field_value = custom_field_get_value( $p_field_id, $p_bug_id ); - switch( $p_def['type'] ) { - case CUSTOM_FIELD_TYPE_EMAIL: - return "$t_custom_field_value"; - break; - case CUSTOM_FIELD_TYPE_ENUM: - case CUSTOM_FIELD_TYPE_LIST: - case CUSTOM_FIELD_TYPE_MULTILIST: - case CUSTOM_FIELD_TYPE_CHECKBOX: - return str_replace( '|', ', ', $t_custom_field_value ); - break; - case CUSTOM_FIELD_TYPE_DATE: - if ($t_custom_field_value != null) { - return date( config_get( 'short_date_format'), $t_custom_field_value) ; - } - break ; - default: - return string_display_links( $t_custom_field_value ); - } + function custom_field_formatted_value( $p_field_id, $p_bug_id ) { + return helper_call_custom_function( 'custom_field_format', + array ($p_field_id, $p_bug_id) ); } # -------------------- @@ -1299,7 +1281,7 @@ # $p_bug_id contains the bug id to display the custom field value for # NOTE: This probably belongs in the print_api.php function print_custom_field_value( $p_def, $p_field_id, $p_bug_id ) { - echo string_custom_field_value( $p_def, $p_field_id, $p_bug_id ); + echo custom_field_formatted_value( $p_field_id, $p_bug_id ); } # -------------------- diff -pur mantis-1.1.1.orig/core/custom_function_api.php mantis-1.1.1.octo/core/custom_function_api.php --- mantis-1.1.1.orig/core/custom_function_api.php 2007-10-14 00:36:41.000000000 +0200 +++ mantis-1.1.1.octo/core/custom_function_api.php 2008-03-28 11:57:56.000000000 +0100 @@ -392,4 +392,34 @@ # html_api.php. For each button, this function needs to generate the enclosing '' and ''. function custom_function_default_print_bug_view_page_custom_buttons( $p_bug_id ) { } + + # -------------------- + # This function formats the value of a custom field for displaying in + # a web page. This function is called from + # core/custom_field_api.php:custom_field_formatted_value, so don't + # call this function when overriding 'custom_field_format' or you'll + # end up with a deep recursion. + function custom_function_default_custom_field_format( $p_field_id, $p_bug_id ) { + $t_field_type = custom_field_type ($p_field_id); + $t_field_value = custom_field_get_value ($p_field_id, $p_bug_id); + + switch ($t_field_type) { + case CUSTOM_FIELD_TYPE_EMAIL: + return "$t_field_value"; + break; + case CUSTOM_FIELD_TYPE_ENUM: + case CUSTOM_FIELD_TYPE_LIST: + case CUSTOM_FIELD_TYPE_MULTILIST: + case CUSTOM_FIELD_TYPE_CHECKBOX: + return str_replace( '|', ', ', $t_field_value ); + break; + case CUSTOM_FIELD_TYPE_DATE: + if ($t_field_value != null) { + return date( config_get( 'short_date_format'), $t_field_value) ; + } + break ; + default: + return string_display_links( $t_field_value ); + } + } # custom_function_default_custom_field_format ?>