dokufreaks / plugin-task

This URL has Read+Write access

plugin-task / ics.php
100644 41 lines (32 sloc) 1.195 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Esther Brunner <wikidesign@gmail.com>
*/
if (!defined('CRLF')) define('CRLF', "\r\n");
if(!defined('DOKU_INC')) define('DOKU_INC', realpath(dirname(__FILE__)).'/../../../');
 
require_once(DOKU_INC.'inc/init.php');
require_once(DOKU_INC.'inc/common.php');
require_once(DOKU_INC.'inc/infoutils.php');
require_once(DOKU_INC.'inc/pageutils.php');
require_once(DOKU_INC.'inc/parserutils.php');
 
$id = $_REQUEST['id'];
 
$data = unserialize(io_readFile(metaFN($id, '.task'), false));
if (!$data['vtodo']) msg('No VTODO data for this task.', -1);
 
$title = p_get_metadata($id, 'title');
if($title) {
    $filename = $title . '.ics';
} else {
    $filename = str_replace(':', '/', cleanID($id)) . '.ics';
}
 
$output = 'BEGIN:VCALENDAR'.CRLF.
  'PRODID:-//Wikidesign//NONSGML Task Plugin for DokuWiki//EN'.CRLF.
  'VERSION:2.0'.CRLF.
  $data['vtodo'].
  'END:VCALENDAR'.CRLF;
 
header("Content-Disposition: attachment; filename='$filename'");
header('Content-Length: '.strlen($output));
header('Connection: close');
header("Content-Type: text/Calendar; name='$filename'");
 
echo $output;
 
// vim:ts=4:sw=4:et:enc=utf-8: