Created
September 16, 2010 23:25
-
-
Save dabit/583366 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once( 'core.php' ); | |
$t_core_path = config_get( 'core_path' ); | |
require_once( $t_core_path . 'filter_api.php' ); | |
require_once( $t_core_path . 'csv_api.php' ); | |
require_once( $t_core_path . 'columns_api.php' ); | |
?> | |
<?php auth_attempt_script_login('$MANTIS_USER', '$MANTIS_PASSWORD') ?> | |
<?php auth_ensure_user_authenticated() ?> | |
<?php | |
helper_begin_long_process(); | |
$t_page_number = 1; | |
$t_per_page = -1; | |
$t_bug_count = null; | |
$t_page_count = null; | |
$t_nl = csv_get_newline(); | |
$t_sep = csv_get_separator(); | |
# Get bug rows according to the current filter | |
$t_rows = filter_get_bug_rows( $t_page_number, $t_per_page, $t_page_count, $t_bug_count ); | |
if ( $t_rows === false ) { | |
print_header_redirect( 'view_all_set.php?type=0' ); | |
} | |
$t_filename = csv_get_default_filename(); | |
# Send headers to browser to activate mime loading | |
# Make sure that IE can download the attachments under https. | |
header( 'Content-Type: text/xml'); | |
# Get columns to be exported | |
$t_columns = csv_get_columns(); | |
$t_header = ob_get_clean(); | |
# 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 = 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; | |
// foreach ( $t_columns as $t_column ) { | |
// echo $t_column; | |
// echo $t_nl; | |
// } | |
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; | |
echo "<external_stories type=\"array\">\n"; | |
# export the rows | |
foreach ( $t_rows as $t_row ) { | |
echo "<external_story>\n"; | |
foreach ( $t_columns as $t_column ) { | |
if ( $t_column == 'id') { | |
echo "<external_id>" . $t_row[0] . "</external_id>\n"; | |
} | |
if ( $t_column == 'summary') { | |
$t_function = 'csv_format_' . $t_column; | |
echo "<name><![CDATA[ " . $t_function( $t_row[ $t_column ] ) . "]]></name>\n"; | |
echo "<description><![CDATA[ " . $t_function( $t_row[ $t_column ] ) . "]]></description>\n"; | |
} | |
if ( $t_column == 'reporter_id') { | |
$t_function = 'csv_format_' . $t_column; | |
echo "<requested_by>" . $t_function( $t_row[ $t_column ] ) . "</requested_by>\n"; | |
} | |
if ( $t_column == 'date_submitted') { | |
$t_function = 'csv_format_' . $t_column; | |
echo "<created_at type=\"datetime\">" . $t_function( $t_row[ $t_column ] ) . "</created_at>\n"; | |
} | |
} | |
echo "<story_type>feature</story_type>\n"; | |
echo "</external_story>\n"; | |
} | |
echo "</external_stories>"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment