diff --git a/system/expressionengine/third_party/easy_ical/README.md b/system/expressionengine/third_party/easy_ical/README.md index 6fd6a40..4f7cb65 100755 --- a/system/expressionengine/third_party/easy_ical/README.md +++ b/system/expressionengine/third_party/easy_ical/README.md @@ -73,6 +73,14 @@ The event summary (title). You probably want to pull this from a custom channel Allows you to add a link to the event. +### localize="yes" + +Choose whether to run dates through EE's localization class. Set to "no" when using Low Events. + +### all_day="yes" + +Drop time information and treat as an all-day event. (Also useful with Low Events.) + ### sequence="{event_sequence}" This adds a simple sequence number to the event. This is needed if you update an entry, otherwise @@ -81,6 +89,11 @@ iCal won't update the event. Use a simple counter custom field, like [Reevision] Changelog --------- +**1.2.1** *(2013-08-14)* + +* Re-added support for EE < 2.6.0 +* Added localize="" and all_day="" event parameters + **1.2** *(2013-07-08)* * ExpressionEngine 2.6 compatibility diff --git a/system/expressionengine/third_party/easy_ical/pi.easy_ical.php b/system/expressionengine/third_party/easy_ical/pi.easy_ical.php index ed75665..83fde35 100755 --- a/system/expressionengine/third_party/easy_ical/pi.easy_ical.php +++ b/system/expressionengine/third_party/easy_ical/pi.easy_ical.php @@ -40,7 +40,7 @@ class Easy_ical { - const VERSION = '1.2'; + const VERSION = '1.2.1'; public function calendar() { @@ -75,15 +75,42 @@ public function event() $out = "BEGIN:VEVENT\r\n". "UID:".$this->escape(ee()->TMPL->fetch_param('uid'))."\r\n"; + $all_day = FALSE; + $localize = TRUE; + + if (ee()->TMPL->fetch_param('all_day') !== FALSE) { + if ( + ee()->TMPL->fetch_param('all_day') === "y" OR + ee()->TMPL->fetch_param('all_day') === "yes" + ) { + $all_day = TRUE; + } + } + + if (ee()->TMPL->fetch_param('localize') !== FALSE) { + if ( + ee()->TMPL->fetch_param('localize') === "n" OR + ee()->TMPL->fetch_param('localize') === "no" + ) { + $localize = FALSE; + } + } + if (ee()->TMPL->fetch_param('location') !== FALSE) { $out .= "LOCATION:".$this->escape(ee()->TMPL->fetch_param('location'))."\r\n"; } - $out .= "DTSTAMP:".$this->ical_time(ee()->TMPL->fetch_param('start_time'))."\r\n"; - $out .= "DTSTART:".$this->ical_time(ee()->TMPL->fetch_param('start_time'))."\r\n"; + $out .= "DTSTAMP:".$this->ical_time(ee()->TMPL->fetch_param('start_time'), $all_day, $localize)."\r\n"; + $out .= "DTSTART:".$this->ical_time(ee()->TMPL->fetch_param('start_time'), $all_day, $localize)."\r\n"; if (ee()->TMPL->fetch_param('end_time') !== FALSE) { - $out .= "DTEND:".$this->ical_time(ee()->TMPL->fetch_param('end_time'))."\r\n"; + $end_time = ee()->TMPL->fetch_param('end_time'); + + if ($all_day) { + $end_time = strtotime('+1 day', $end_time); + } + + $out .= "DTEND:".$this->ical_time($end_time, $all_day, $localize)."\r\n"; } if (ee()->TMPL->fetch_param('summary') !== FALSE) { @@ -130,9 +157,21 @@ public function escape($str) return implode("\r\n ", $lines); } - public function ical_time($time) + public function ical_time($time, $all_day, $localize) { - return ee()->localize->format_date('%Y%m%dT%H%i%s', $time); + if ($localize) { + if ($all_day) { + return ee()->localize->format_date('%Y%m%d', $time); + } else { + return ee()->localize->format_date('%Y%m%dT%H%i%s', $time); + } + } else { + if ($all_day) { + return date('Ymd', $time); + } else { + return date('Ymd\THis', $time); + } + } } public static function usage()