Improved ODS date/time/datetime export format. Patch #2856664
This commit is contained in:
@@ -69,6 +69,40 @@ function PMA_exportFooter() {
|
|||||||
function PMA_exportHeader() {
|
function PMA_exportHeader() {
|
||||||
$GLOBALS['ods_buffer'] .= '<?xml version="1.0" encoding="' . $GLOBALS['charset'] . '"?' . '>'
|
$GLOBALS['ods_buffer'] .= '<?xml version="1.0" encoding="' . $GLOBALS['charset'] . '"?' . '>'
|
||||||
. '<office:document-content '. $GLOBALS['OpenDocumentNS'] . 'office:version="1.0">'
|
. '<office:document-content '. $GLOBALS['OpenDocumentNS'] . 'office:version="1.0">'
|
||||||
|
. '<office:automatic-styles>'
|
||||||
|
. '<number:date-style style:name="N37" number:automatic-order="true">'
|
||||||
|
. '<number:month number:style="long"/>'
|
||||||
|
. '<number:text>/</number:text>'
|
||||||
|
. '<number:day number:style="long"/>'
|
||||||
|
. '<number:text>/</number:text>'
|
||||||
|
. '<number:year/>'
|
||||||
|
. '</number:date-style>'
|
||||||
|
. '<number:time-style style:name="N43">'
|
||||||
|
. '<number:hours number:style="long"/>'
|
||||||
|
. '<number:text>:</number:text>'
|
||||||
|
. '<number:minutes number:style="long"/>'
|
||||||
|
. '<number:text>:</number:text>'
|
||||||
|
. '<number:seconds number:style="long"/>'
|
||||||
|
. '<number:text> </number:text>'
|
||||||
|
. '<number:am-pm/>'
|
||||||
|
. '</number:time-style>'
|
||||||
|
. '<number:date-style style:name="N50" number:automatic-order="true" number:format-source="language">'
|
||||||
|
. '<number:month/>'
|
||||||
|
. '<number:text>/</number:text>'
|
||||||
|
. '<number:day/>'
|
||||||
|
. '<number:text>/</number:text>'
|
||||||
|
. '<number:year/>'
|
||||||
|
. '<number:text> </number:text>'
|
||||||
|
. '<number:hours number:style="long"/>'
|
||||||
|
. '<number:text>:</number:text>'
|
||||||
|
. '<number:minutes number:style="long"/>'
|
||||||
|
. '<number:text> </number:text>'
|
||||||
|
. '<number:am-pm/>'
|
||||||
|
. '</number:date-style>'
|
||||||
|
. '<style:style style:name="DateCell" style:family="table-cell" style:parent-style-name="Default" style:data-style-name="N37"/>'
|
||||||
|
. '<style:style style:name="TimeCell" style:family="table-cell" style:parent-style-name="Default" style:data-style-name="N43"/>'
|
||||||
|
. '<style:style style:name="DateTimeCell" style:family="table-cell" style:parent-style-name="Default" style:data-style-name="N50"/>'
|
||||||
|
. '</office:automatic-styles>'
|
||||||
. '<office:body>'
|
. '<office:body>'
|
||||||
. '<office:spreadsheet>';
|
. '<office:spreadsheet>';
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -165,6 +199,18 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
|
|||||||
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">'
|
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||||
. '<text:p></text:p>'
|
. '<text:p></text:p>'
|
||||||
. '</table:table-cell>';
|
. '</table:table-cell>';
|
||||||
|
} elseif ($fields_meta[$j]->type == "date") {
|
||||||
|
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="date" office:date-value="' . date("Y-m-d", strtotime($row[$j])) . '" table:style-name="DateCell">'
|
||||||
|
. '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>'
|
||||||
|
. '</table:table-cell>';
|
||||||
|
} elseif ($fields_meta[$j]->type == "time") {
|
||||||
|
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="time" office:time-value="' . date("\P\TH\Hi\Ms\S", strtotime($row[$j])) . '" table:style-name="TimeCell">'
|
||||||
|
. '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>'
|
||||||
|
. '</table:table-cell>';
|
||||||
|
} elseif ($fields_meta[$j]->type == "datetime") {
|
||||||
|
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="date" office:date-value="' . date("Y-m-d\TH:i:s", strtotime($row[$j])) . '" table:style-name="DateTimeCell">'
|
||||||
|
. '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>'
|
||||||
|
. '</table:table-cell>';
|
||||||
} elseif ($fields_meta[$j]->numeric && $fields_meta[$j]->type != 'timestamp' && ! $fields_meta[$j]->blob) {
|
} elseif ($fields_meta[$j]->numeric && $fields_meta[$j]->type != 'timestamp' && ! $fields_meta[$j]->blob) {
|
||||||
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="float" office:value="' . $row[$j] . '" >'
|
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="float" office:value="' . $row[$j] . '" >'
|
||||||
. '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>'
|
. '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>'
|
||||||
|
Reference in New Issue
Block a user