Exemple #1
0
/**
 * Gets the localized title for the specified column.  The column can be native or custom.
 * The custom fields must contain the 'custom_' prefix.
 *
 * @param string $p_column - The column name.
 * @return string The column localized name.
 * @access public
 */
function column_get_title($p_column)
{
    $t_custom_field = column_get_custom_field_name($p_column);
    if ($t_custom_field !== null) {
        $t_field_id = custom_field_get_id_from_name($t_custom_field);
        if ($t_field_id === false) {
            $t_custom_field = '@' . $t_custom_field . '@';
        } else {
            $t_def = custom_field_get_definition($t_field_id);
            $t_custom_field = lang_get_defaulted($t_def['name']);
        }
        return $t_custom_field;
    }
    $t_plugin_columns = columns_get_plugin_columns();
    if (isset($t_plugin_columns[$p_column])) {
        $t_column_object = $t_plugin_columns[$p_column];
        return $t_column_object->title;
    }
    switch ($p_column) {
        case 'attachment_count':
            return lang_get('attachments');
        case 'bugnotes_count':
            return '#';
        case 'category_id':
            return lang_get('category');
        case 'edit':
            return '';
        case 'handler_id':
            return lang_get('assigned_to');
        case 'last_updated':
            return lang_get('updated');
        case 'os_build':
            return lang_get('os_version');
        case 'project_id':
            return lang_get('email_project');
        case 'reporter_id':
            return lang_get('reporter');
        case 'selection':
            return '';
        case 'sponsorship_total':
            return sponsorship_get_currency();
        case 'version':
            return lang_get('product_version');
        case 'view_state':
            return lang_get('view_status');
        default:
            return lang_get_defaulted($p_column);
    }
}
}
header('Content-Type: application/vnd.ms-excel; charset=UTF-8');
header('Pragma: public');
header('Content-Disposition: attachment; filename="' . urlencode(file_clean_name($t_export_title)) . '.xml"');
echo excel_get_header($t_export_title);
echo excel_get_titles_row();
$f_bug_arr = explode(',', $f_export);
$t_columns = excel_get_columns();
do {
    # pre-cache custom column data
    columns_plugin_cache_issue_data($t_result);
    foreach ($t_result as $t_row) {
        if (is_blank($f_export) || in_array($t_row->id, $f_bug_arr)) {
            echo excel_get_start_row();
            foreach ($t_columns as $t_column) {
                $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 {
                    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);
                    }
                }
            }
            echo excel_get_end_row();
        }
        #in_array
    }
Exemple #3
0
/**
 * Print the value of the custom field (if the field is applicable to the project of
 * the specified issue and the current user has read access to it.
 * see custom_function_default_print_column_title() for rules about column names.
 * @param string  $p_column         Name of field to show in the column.
 * @param BugData $p_bug            Bug object.
 * @param integer $p_columns_target See COLUMNS_TARGET_* in constant_inc.php.
 * @return void
 */
function custom_function_default_print_column_value($p_column, BugData $p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE)
{
    if (COLUMNS_TARGET_CSV_PAGE == $p_columns_target) {
        $t_column_start = '';
        $t_column_end = '';
        $t_column_empty = '';
    } else {
        $t_column_start = '<td class="column-%s">';
        $t_column_end = '</td>';
        $t_column_empty = '&#160;';
    }
    $t_custom_field = column_get_custom_field_name($p_column);
    if ($t_custom_field !== null) {
        printf($t_column_start, 'custom-' . $t_custom_field);
        $t_field_id = custom_field_get_id_from_name($t_custom_field);
        if ($t_field_id === false) {
            echo '@', $t_custom_field, '@';
        } else {
            $t_issue_id = $p_bug->id;
            $t_project_id = $p_bug->project_id;
            if (custom_field_is_linked($t_field_id, $t_project_id)) {
                $t_def = custom_field_get_definition($t_field_id);
                print_custom_field_value($t_def, $t_field_id, $t_issue_id);
            } else {
                # field is not linked to project
                echo $t_column_empty;
            }
        }
        echo $t_column_end;
    } else {
        $t_plugin_columns = columns_get_plugin_columns();
        if ($p_columns_target != COLUMNS_TARGET_CSV_PAGE) {
            $t_function = 'print_column_' . $p_column;
        } else {
            $t_function = 'csv_format_' . $p_column;
        }
        if (function_exists($t_function)) {
            if ($p_columns_target != COLUMNS_TARGET_CSV_PAGE) {
                $t_function($p_bug, $p_columns_target);
            } else {
                $t_function($p_bug);
            }
        } else {
            if (isset($t_plugin_columns[$p_column])) {
                $t_column_object = $t_plugin_columns[$p_column];
                print_column_plugin($t_column_object, $p_bug, $p_columns_target);
            } else {
                printf($t_column_start, $p_column);
                if (isset($p_bug->{$p_column})) {
                    echo string_display_line($p_bug->{$p_column}) . $t_column_end;
                } else {
                    echo '@' . $p_column . '@' . $t_column_end;
                }
            }
        }
    }
}
Exemple #4
0
# Fixed for a problem in Excel where it prompts error message "SYLK: File Format Is Not Valid"
# See Microsoft Knowledge Base Article - 323626
# http://support.microsoft.com/default.aspx?scid=kb;en-us;323626&Product=xlw
$t_first_three_chars = utf8_substr($t_header, 0, 3);
if (strcmp($t_first_three_chars, 'ID' . $t_sep) == 0) {
    $t_header = str_replace('ID' . $t_sep, 'Id' . $t_sep, $t_header);
}
# end of fix
echo $t_header;
# export the rows
foreach ($t_rows as $t_row) {
    $t_first_column = true;
    foreach ($t_columns as $t_column) {
        if (!$t_first_column) {
            echo $t_sep;
        } else {
            $t_first_column = false;
        }
        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));
            $t_value = ob_get_clean();
            echo csv_escape_string($t_value);
        } else {
            $t_function = 'csv_format_' . $t_column;
            echo $t_function($t_row);
        }
    }
    echo $t_nl;
}
function custom_function_override_print_column_value($p_column, $p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE)
{
    if (COLUMNS_TARGET_CSV_PAGE == $p_columns_target) {
        $t_column_start = '';
        $t_column_end = '';
        $t_column_empty = '';
    } else {
        $t_column_start = '<td class="center">';
        $t_column_end = '</td>';
        $t_column_empty = '&#160;';
    }
    $t_custom_field = column_get_custom_field_name($p_column);
    if ($t_custom_field !== null) {
        echo $t_column_start;
        $t_field_id = custom_field_get_id_from_name($t_custom_field);
        if ($t_field_id === false) {
            echo '@', $t_custom_field, '@';
        } else {
            $t_issue_id = $p_bug->id;
            $t_project_id = $p_bug->project_id;
            if (custom_field_is_linked($t_field_id, $t_project_id)) {
                $t_def = custom_field_get_definition($t_field_id);
                if (strpos($p_column, 'custom_Deadline') === 0 && $t_def['type'] == CUSTOM_FIELD_TYPE_DATE) {
                    $deadline_date = custom_field_get_value($t_field_id, $t_issue_id);
                    if ($p_issue_row['status'] < 80) {
                        $current_date = strtotime(date("Y-m-d"));
                        if ($current_date >= $deadline_date) {
                            echo '<b><font color="red">';
                            print_custom_field_value($t_def, $t_field_id, $t_issue_id);
                            echo '</font></b>';
                        } else {
                            print_custom_field_value($t_def, $t_field_id, $t_issue_id);
                        }
                    } elseif ($deadline_date) {
                        if (lang_get_current() == 'german') {
                            echo '<b>ERLEDIGT!</b>';
                        } else {
                            echo '<b>DONE!</b>';
                        }
                    }
                } else {
                    print_custom_field_value($t_def, $t_field_id, $t_issue_id);
                }
            } else {
                // field is not linked to project
                echo $t_column_empty;
            }
        }
        echo $t_column_end;
    } else {
        $t_plugin_columns = columns_get_plugin_columns();
        if ($p_columns_target != COLUMNS_TARGET_CSV_PAGE) {
            if ($p_column == 'summary') {
                $t_function = 'print_column_summary_BFE';
            } else {
                $t_function = 'print_column_' . $p_column;
            }
        } else {
            $t_function = 'csv_format_' . $p_column;
        }
        if (function_exists($t_function)) {
            if ($p_columns_target != COLUMNS_TARGET_CSV_PAGE) {
                $t_function($p_bug, $p_columns_target);
            } else {
                $t_function($p_bug);
            }
        } else {
            if (isset($t_plugin_columns[$p_column])) {
                $t_column_object = $t_plugin_columns[$p_column];
                print_column_plugin($t_column_object, $p_bug, $p_columns_target);
            } else {
                if (isset($p_bug->{$p_column})) {
                    echo $t_column_start . string_display_line($p_bug->{$p_column}) . $t_column_end;
                } else {
                    echo $t_column_start . '@' . $p_column . '@' . $t_column_end;
                }
            }
        }
    }
}
Exemple #6
0
/**
 * Gets an Xml Row that contains all column titles.
 * @returns The xml row.
 */
function excel_get_titles_row()
{
    $t_columns = excel_get_columns();
    $t_ret = '<Row>';
    foreach ($t_columns as $t_column) {
        $t_custom_field = column_get_custom_field_name($t_column);
        if ($t_custom_field !== null) {
            $t_ret .= excel_format_column_title(lang_get_defaulted($t_custom_field));
        } else {
            $t_column_title = column_get_title($t_column);
            $t_ret .= excel_format_column_title($t_column_title);
        }
    }
    $t_ret .= '</Row>';
    return $t_ret;
}