]> git.mxchange.org Git - friendica-addons.git/commitdiff
cal: added CSV export
authorTobias Diekershoff <tobias.diekershoff@gmx.net>
Sun, 16 Jun 2013 06:45:55 +0000 (08:45 +0200)
committerTobias Diekershoff <tobias.diekershoff@gmx.net>
Sun, 16 Jun 2013 06:45:55 +0000 (08:45 +0200)
cal/cal.php

index 6e8829de5149f86014e214d3d27fd0b7500497be..fb5ae482c6118f0e6bf5d11071c01c04afc03060 100644 (file)
@@ -83,8 +83,26 @@ function cal_format_output ($r, $f, $tz)
     $res = t('This calendar format is not supported');;
     switch ($f)
     {
+       //  format the exported data as a CSV file
+       case "csv":
+           header("Content-type: text/csv");
+           $o = '"Subject", "Start Date", "Start Time", "Description", "End Date", "End Time", "Location"' . PHP_EOL;
+           foreach ($r as $rr) {
+               $tmp1 = strtotime($rr['start']);
+               $tmp2 = strtotime($rr['finish']);
+               $time_format = "%H:%M:%S";
+               $date_format = "%d.%m.%Y";
+               $o .= '"'.$rr['summary'].'", "'.strftime($date_format, $tmp1) .
+                   '", "'.strftime($time_format, $tmp1).'", "'.$rr['desc'] .
+                   '", "'.strftime($date_format, $tmp2) .
+                   '", "'.strftime($time_format, $tmp2) . 
+                   '", "'.$rr['location'].'"' . PHP_EOL;
+           }
+           echo $o;
+           killme();
+
        case "ical":
-           header("Content-type: text/icon");
+           header("Content-type: text/ics");
            $res = '';
            $o = 'BEGIN:VCALENDAR'. PHP_EOL
                . 'PRODID:-//friendica calendar export//0.1//EN' . PHP_EOL