commit 1add008055c65e8965c229be9b6c0e02815afda6 Author: Vincent Sels Date: Mon Jan 9 20:15:01 2012 +0100 Fixed output of plugin columns to css and excel diff --git a/core/columns_api.php b/core/columns_api.php index 6fc25d9..9baf766 100644 --- a/core/columns_api.php +++ b/core/columns_api.php @@ -143,6 +143,15 @@ function columns_get_plugin_columns() { } /** + * Returns true if the specified $p_column is a plugin column. + * @param string $p_column A column name. + */ +function column_is_plugin_column( $p_column ) { + $t_plugin_columns = columns_get_plugin_columns(); + return isset( $t_plugin_columns[ $p_column ] ); +} + +/** * Allow plugin columns to pre-cache data for a set of issues * rather than requiring repeated queries for each issue. * @param array Bug objects diff --git a/core/excel_api.php b/core/excel_api.php index ff32d01..8662492 100644 --- a/core/excel_api.php +++ b/core/excel_api.php @@ -474,6 +474,26 @@ function excel_format_custom_field( $p_issue_id, $p_project_id, $p_custom_field } /** + * Gets the formatted value for the specified plugin column value. + * @param $p_custom_field The plugin column name. + * @param $p_bug The bug to print the column for (needed for the display function of the plugin column). + * @returns The custom field value. + */ +function excel_format_plugin_column_value( $p_column, $p_bug ) { + $t_plugin_columns = columns_get_plugin_columns(); + + if ( !isset( $t_plugin_columns[$p_column] ) ) { + return excel_prepare_string( '' ); + } else { + $t_column_object = $t_plugin_columns[ $p_column ]; + ob_start(); + $t_column_object->display( $p_bug, COLUMNS_TARGET_EXCEL_PAGE ); + $t_value = ob_get_clean(); + return excel_prepare_string( $t_value ); + } +} + +/** * Gets the formatted due date. * @param $p_due_date The due date. * @returns The formatted due date. diff --git a/csv_export.php b/csv_export.php index 5dff44f..8121513 100644 --- a/csv_export.php +++ b/csv_export.php @@ -46,6 +46,9 @@ if ( $t_rows === false ) { print_header_redirect( 'view_all_set.php?type=0' ); } + + # pre-cache custom column data + columns_plugin_cache_issue_data( $t_rows ); $t_filename = csv_get_default_filename(); @@ -103,8 +106,7 @@ $t_first_column = false; } - $t_custom_field = column_get_custom_field_name( $t_column ); - if ( $t_custom_field !== null ) { + if ( column_get_custom_field_name( $t_column ) !== null || column_is_plugin_column( $t_column )) { ob_start(); $t_column_value_function = 'print_column_value'; helper_call_custom_function( $t_column_value_function, array( $t_column, $t_row, COLUMNS_TARGET_CSV_PAGE ) ); diff --git a/excel_xml_export.php b/excel_xml_export.php index dbd9152..4d461e1 100644 --- a/excel_xml_export.php +++ b/excel_xml_export.php @@ -55,6 +55,9 @@ if ( $result === false ) { print_header_redirect( 'view_all_set.php?type=0&print=1' ); } + + # pre-cache custom column data + columns_plugin_cache_issue_data( $result ); header( 'Content-Type: application/vnd.ms-excel; charset=UTF-8' ); header( 'Pragma: public' ); @@ -91,7 +94,9 @@ $t_custom_field = column_get_custom_field_name( $t_column ); if ( $t_custom_field !== null ) { echo excel_format_custom_field( $t_row->id, $t_row->project_id, $t_custom_field ); - } else { + } else if ( column_is_plugin_column( $t_column ) ) { + echo excel_format_plugin_column_value( $t_column, $t_row ); + } else{ $t_function = 'excel_format_' . $t_column; echo $t_function( $t_row->$t_column ); } diff --git a/print_all_bug_page.php b/print_all_bug_page.php index 8275c45..b5a1d67 100644 --- a/print_all_bug_page.php +++ b/print_all_bug_page.php @@ -80,6 +80,9 @@ $result = filter_get_bug_rows( $f_page_number, $t_per_page, $t_page_count, $t_bug_count ); $row_count = count( $result ); + + # pre-cache custom column data + columns_plugin_cache_issue_data( $result ); # for export $t_show_flag = gpc_get_int( 'show_flag', 0 );