View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0013715 | mantisbt | plug-ins | public | 2012-01-03 12:05 | 2014-09-23 18:05 |
Reporter | vincent_sels | Assigned To | dregad | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 1.2.8 | ||||
Target Version | 1.2.9 | Fixed in Version | 1.2.9 | ||
Summary | 0013715: Export to csv and excel does not work for plugin columns ? | ||||
Description | When you define columns for your plugin, extending MantisColumn and implementing all the functions, you get an error when trying to export results of the 'view issues' page to css and excel. Surprised that I don't find this bug report yet, or did I miss i ? css: excel: | ||||
Steps To Reproduce |
| ||||
Tags | No tags attached. | ||||
Attached Files | 13715.patch (4,053 bytes)
commit 1add008055c65e8965c229be9b6c0e02815afda6 Author: Vincent Sels <vincent_sels@hotmail.com> 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 ); | ||||
If someone of the devs could confirm this is actually still a bug and that I'm not just missing something, I might try to find the proper solution myself and create a pull request for it, because we urgently need the solution to this in our production environment. |
|
I can confirm it on 1.2.8. |
|
Thanks. Will look for a solution tonight. |
|
I can reproduce this on my dev box with both 1.2.8 and the latest 1.2.x trunk |
|
Created pull request http://www.mantisbt.org/bugs/view.php?id=13715 |
|
Many thanks for the fix, Vincent. |
|
Marking as 'acknowledged' not resolved/closed to track that change gets ported to master-2.0.x branch |
|
MantisBT: master a5708e06 2012-01-09 06:15 Details Diff |
Fix 0013715: Export plugin columns to CSV and Excel Prior to this, trying to include plugin columns in a CSV or Excel export would generate a file containing errors: * CSV: "Fatal error: Call to undefined function csv_format_XXX() in csv_export.php on line 116" * excel: "Fatal error: Call to undefined function excel_format_XXX() in excel_xml_export.php on line 96" where XXX is the column's name. Signed-off-by: Damien Regad <damien.regad@merckgroup.com> |
Affected Issues 0013715 |
|
mod - core/columns_api.php | Diff File | ||
mod - core/excel_api.php | Diff File | ||
mod - csv_export.php | Diff File | ||
mod - excel_xml_export.php | Diff File | ||
mod - print_all_bug_page.php | Diff File | ||
MantisBT: master-1.2.x 45f4f521 2012-01-09 06:15 Details Diff |
Fix 0013715: Export plugin columns to CSV and Excel Prior to this, trying to include plugin columns in a CSV or Excel export would generate a file containing errors: * CSV: "Fatal error: Call to undefined function csv_format_XXX() in csv_export.php on line 116" * excel: "Fatal error: Call to undefined function excel_format_XXX() in excel_xml_export.php on line 96" where XXX is the column's name. Signed-off-by: Damien Regad <damien.regad@merckgroup.com> |
Affected Issues 0013715 |
|
mod - core/columns_api.php | Diff File | ||
mod - core/excel_api.php | Diff File | ||
mod - csv_export.php | Diff File | ||
mod - excel_xml_export.php | Diff File | ||
mod - print_all_bug_page.php | Diff File |