1
0
Fork 0
forked from ChCh/chch_api
chch_api/include/chch_ical2mediawiki.php

44 lines
1.4 KiB
PHP

<?php
$ical_file=$argv[1];
$backward_seconds=60*60*6;
$preview_seconds=60*60*24*15;
?>
{| class="wikitable"
|-
! scope="col" rowspan="2"| Datum
! scope="col"| Titel
! scope="col"| Ort
|-
! scope="col" colspan="2"| Beschreibung
|-
<?php
require_once __DIR__ . '/icalparser/src/EventsList.php';
require_once __DIR__ . '/icalparser/src/IcalParser.php';
require_once __DIR__ . '/icalparser/src/Recurrence.php';
require_once __DIR__ . '/icalparser/src/Freq.php';
$cal = new \om\IcalParser();
$results = $cal->parseFile("$ical_file");
foreach ($cal->getSortedEvents() as $r) {
if($r['DTEND']->getTimestamp()>(time()-$backward_seconds) and $r['DTSTART']->getTimestamp()<(time()+$preview_seconds)) {
if($r['DTSTART']->format('d.m.Y')!=$r['DTEND']->format('d.m.Y') and $r['DTEND']->format('H:i')=="00:00") {
$chch_end_date=date('d.m.Y' ,$r['DTEND']->getTimestamp()-1);
$chch_end_time="23:59";
} else {
$chch_end_date=$r['DTEND']->format('d.m.Y');
$chch_end_time=$r['DTEND']->format('H:i');
}
echo sprintf('|rowspan="2" style="text-align:center;"|%s&nbsp;%s<br>-<br>%s&nbsp;%s' . PHP_EOL .
'|\'\'\'%s\'\'\'' . PHP_EOL .
'|%s&nbsp;' . PHP_EOL .
'|-' . PHP_EOL .
'|colspan="2"|%s&nbsp;' . PHP_EOL .
'|-' . PHP_EOL,
$r['DTSTART']->format('d.m.Y'), $r['DTSTART']->format('H:i'), $chch_end_date, $chch_end_time,
$r['SUMMARY'],
$r['LOCATION'],
$r['DESCRIPTION']);
}
}
?>
|}