aboutsummaryrefslogtreecommitdiffstats
path: root/include/event.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-11-23 20:29:34 -0800
committerfriendica <info@friendica.com>2014-11-23 20:29:34 -0800
commit53dc9cf2eb078f452979dc1dc9146ab993425621 (patch)
treea5d0217c4feb92e6ef56b181b8eab37dc99e44df /include/event.php
parent79e5c2456bfc78296d77d1a4caedd5a32b7d9d12 (diff)
downloadvolse-hubzilla-53dc9cf2eb078f452979dc1dc9146ab993425621.tar.gz
volse-hubzilla-53dc9cf2eb078f452979dc1dc9146ab993425621.tar.bz2
volse-hubzilla-53dc9cf2eb078f452979dc1dc9146ab993425621.zip
basic vcalendar formatting support
Diffstat (limited to 'include/event.php')
-rw-r--r--include/event.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/include/event.php b/include/event.php
index d95e8b401..a79770d23 100644
--- a/include/event.php
+++ b/include/event.php
@@ -45,6 +45,56 @@ function format_event_html($ev) {
return $o;
}
+
+
+function ical_wrapper($ev) {
+
+ if(! ((is_array($ev)) && count($ev)))
+ return '';
+
+ $o .= "BEGIN:VCALENDAR";
+ $o .= "\nVERSION:2.0";
+ $o .= "\nMETHOD:PUBLISH";
+ $o .= "\nPRODID:-//" . get_config('system','sitename') . "//" . RED_PLATFORM . "//" . strtoupper(get_app()->language). "\n";
+ if(array_key_exists('start',$ev))
+ $o .= format_event_ical($ev);
+ else {
+ foreach($ev as $e) {
+ $o .= format_event_ical($e);
+ }
+ }
+ $o .= "\nEND:VCALENDAR\n";
+
+ return $o;
+}
+
+function format_event_ical($ev) {
+
+ $o = '';
+
+ $o .= "\nBEGIN:VEVENT";
+ if($ev['start'])
+ $o .= "\nDTSTART:" . datetime_convert('UTC','UTC', $ev['start'],'Ymd\\This' . (($ev['adjust']) ? '\\Z' : ''));
+ if($ev['finish'] && ! $ev['nofinish'])
+ $o .= "\nDTEND:" . datetime_convert('UTC','UTC', $ev['finish'],'Ymd\\This' . (($ev['adjust']) ? '\\Z' : ''));
+ if($ev['summary'])
+ $o .= "\nSUMMARY:" . format_ical_text($ev['summary']);
+ if($ev['location'])
+ $o .= "\nLOCATION:" . format_ical_text($ev['location']);
+ if($ev['description'])
+ $o .= "\nDESCRIPTION:" . format_ical_text($ev['description']);
+ $o .= "\nEND:VEVENT\n";
+ return $o;
+}
+
+function format_ical_text($s) {
+
+ require_once('include/bbcode.php');
+ require_once('include/html2plain.php');
+ return(wordwrap(html2plain(bbcode($s)),72,"\n ",true));
+}
+
+
function format_event_bbcode($ev) {
$o = '';