| 1 | <?php |
| 2 | |
| 3 | /***************************************************************************\ |
| 4 | * SPIP, Systeme de publication pour l'internet * |
| 5 | * * |
| 6 | * Copyright (c) 2001-2007 * |
| 7 | * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * |
| 8 | * * |
| 9 | * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * |
| 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | \***************************************************************************/ |
| 12 | |
| 13 | |
| 14 | if (!defined("_ECRIRE_INC_VERSION")) return; |
| 15 | |
| 16 | include_spip('inc/minipres'); |
| 17 | include_spip('inc/acces'); |
| 18 | include_spip('inc/texte'); // utile pour l'espace public, deja fait sinon |
| 19 | |
| 20 | function xml_ical_dist($rss, $intro = '') { |
| 21 | |
| 22 | // entetes |
| 23 | $u = |
| 24 | 'BEGIN:VCALENDAR |
| 25 | CALSCALE:GREGORIAN |
| 26 | X-WR-CALNAME;VALUE=TEXT:'.filtrer_ical($intro['title']).' |
| 27 | X-WR-RELCALID:'.filtrer_ical(url_absolue($intro['url'])).' |
| 28 | '; |
| 29 | |
| 30 | // elements |
| 31 | if (is_array($rss)) { |
| 32 | usort($rss, 'trier_par_date'); |
| 33 | foreach ($rss as $article) { |
| 34 | |
| 35 | // Regler la date de fin a h+60min |
| 36 | if (!$article['enddate']) |
| 37 | $article['enddate'] = date_ical($article['date'],60); |
| 38 | else |
| 39 | $article['enddate'] = date_ical($article['enddate']); |
| 40 | |
| 41 | // Type d'evenement |
| 42 | if ($article['type'] == 'todo') |
| 43 | $type = 'VTODO'; |
| 44 | else |
| 45 | $type = 'VEVENT'; |
| 46 | |
| 47 | $u .= |
| 48 | 'BEGIN:'.$type.' |
| 49 | SUMMARY:'.filtrer_ical($article['title']).' |
| 50 | URL:'.filtrer_ical(url_absolue($article['url'])).' |
| 51 | DTSTAMP:'. date_ical($article['date']).' |
| 52 | DTSTART:'. date_ical($article['date']).' |
| 53 | DTEND:'. $article['enddate'].' |
| 54 | DESCRIPTION:'.filtrer_ical(liens_absolus($article['description'])).' |
| 55 | ORGANIZER:'.filtrer_ical($article['author']).' |
| 56 | CATEGORIES:-- |
| 57 | END:'.$type.' |
| 58 | '; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | // pied |
| 63 | $u .= 'END:VCALENDAR'; |
| 64 | |
| 65 | header('Content-Type: text/calendar; charset=utf-8'); |
| 66 | echo $u; |
| 67 | } |
| 68 | ?> |