Browse Source

Update export.php

include changes from upstream
master
René Wagner 1 year ago
committed by GitHub
parent
commit
96de9434be
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      export.php

24
export.php

@ -1,7 +1,7 @@
<?php
/*
(C) Copyright 2009-2010 myTinyTodo by Max Pozdeev <maxpozdeev@gmail.com>
(C) Copyright 2009-2011,2019 myTinyTodo by Max Pozdeev <maxpozdeev@gmail.com>
(C) Copyright 2017 fork myTDX by Jérémie FRANCOIS <jeremie.francois@gmail.com>
Licensed under the GNU GPL v2 license. See file COPYRIGHT for details.
*/
@ -46,12 +46,16 @@ function have_write_access()
function printCSV($listData, $data)
{
$s = /*chr(0xEF).chr(0xBB).chr(0xBF).*/ "Completed,Priority,Task,Notes,Tags,Due,DateCreated,DateCompleted\n";
$s = "\xEF\xBB\xBF". "Completed;Priority;Task;Notes;Tags;Due;DateCreated;DateCompleted\n";
foreach($data as $r)
{
$s .= ($r['compl']?'1':'0'). ','. $r['prio']. ','. escape_csv($r['title']). ','.
escape_csv($r['note']). ','. escape_csv($r['tags']). ','. $r['duedate'].
','. date('Y-m-d H:i:s O',$r['d_created']). ','. ($r['d_completed'] ? date('Y-m-d H:i:s O',$r['d_completed']) :''). "\n";
$s .= ($r['compl']?'1':'0'). ';'.
$r['prio']. ';'. escape_csv($r['title']). ';'.
escape_csv($r['note']). ';'.
escape_csv($r['tags']). ';'.
$r['duedate']. ';'.
date('Y-m-d H:i:s O',$r['d_created']). ';'.
($r['d_completed'] ? date('Y-m-d H:i:s O',$r['d_completed']) :''). "\n";
}
header('Content-type: text/csv; charset=utf-8');
header('Content-disposition: attachment; filename=list_'.$listData['id'].'.csv');
@ -60,7 +64,13 @@ function printCSV($listData, $data)
function escape_csv($v)
{
return '"'.str_replace('"', '""', $v).'"';
//escape formulas
$nf = '';
$trimmed = ltrim($v);
if (strlen($trimmed) > 0 && in_array(substr($trimmed, 0, 1), array('=', '+', '-', '@'))) {
$nf = "'";
}
return '"'. $nf. str_replace('"', '""', $v). '"';
}
function printICal($listData, $data)
@ -149,4 +159,4 @@ function utf8chunks($text, $chunklen=75, $delimiter="\r\n\t")
return implode($delimiter, $a);
}
?>
?>
Loading…
Cancel
Save