diff --git a/README.md b/README.md index a8df510..2fcffc3 120000 --- a/README.md +++ b/README.md @@ -1 +1 @@ -system/expressionengine/third_party/easy_ical/README.md \ No newline at end of file +easy_ical/README.md \ No newline at end of file diff --git a/easy_ical/README.md b/easy_ical/README.md new file mode 100755 index 0000000..fbb2d58 --- /dev/null +++ b/easy_ical/README.md @@ -0,0 +1,164 @@ +# Easy iCalendar + +ExpressionEngine plugin that builds valid iCalendar files. + +*Forked from Expresso's Easy iCalendar ExpressionEngine Plugin* + +## Requirements + +ExpressionEngine v2+ + +*Compatible with EE v2-5* + +## Installation + +- **EE v2:** Copy `easy_ical` directory into `/system/expressionengine/third_party/` +- **EE v3:** Copy `easy_ical` directory into `/system/user/addons/` +- **EE v4:** Copy `easy_ical` directory into `/system/user/addons/` +- **EE v5:** Copy `easy_ical` directory into `/system/user/addons/` + +## Usage + +### `{exp:easy_ical:calendar}` + +Along with `{exp:easy_ical:event}`, builds the iCalendar Core Object + +#### Parameters + +##### `timezone` *(optional)* + +Specify the timezone for all events + +- **Type:** string +- **Default:** `America/New_York` +- **Options:** PHP timezones + +##### `calendar_name` *(optional)* + +Give your calendar a name + +- **Type:** string +- **Default:** `Save the Date!` + +##### `content_type` *(optional)* + +Force the specified content type (for debugging) + +- **Type:** string +- **Default:** `text/calendar; charset=UTF-8` +- **Options:** `text/plain` + +##### `filename` *(optional)* + +Name for the generated iCalendar file + +- **Type:** string +- **Default:** `save-the-date` + +### `{exp:easy_ical:event}` + +Along with `{exp:easy_ical:calendar}`, builds the iCalendar Core Object + +#### Parameters + +##### `uid` *(optional)* + +A unique identifier for the event, typically `{entry_id}` + +- **Type:** string +- **Default:** unix timestamp + +##### `start_time` *(optional)* + +The event start date and time, typically `{entry_date}` + +- **Type:** int +- **Default:** Current date and time (unix timestamp) + +##### `end_time` *(optional)* + +The event end date and time, typically `{expiration_date}` or custom channel field (date) + +- **Type:** int +- **Default:** Current date and time + 24 hours (unix timestamp) + +##### `location` *(optional)* + +The event location, typically a custom channel field (text). + +- **Type:** string +- **Default:** `New York, NY` + +##### `summary` *(optional)* + +The event summary, typically `{title}` or a custom channel field (text) + +- **Type:** string +- **Default:** `An event happening in New York, NY` + +##### `url` *(optional)* + +Allows you to add a link to the event. + +- **Type:** string + +##### `sequence` *(optional)* + +Needed if you update an entry with the same `uid`, otherwise iCal will not update the event. + +- **Type:** int +- **Default:** unix timestamp + +### Example +``` +{exp:easy_ical:calendar timezone="Pacific/Auckland" name="My Event Calendar"} + {exp:channel:entries channel="events" show_future_entries="yes" show_expired="yes" limit="20"} + {exp:easy_ical:event uid="{entry_id}" start_time="{entry_date}" end_time="{expiration_date}" location="{event_location}" summary="{title}"} + {event_description} + {/exp:easy_ical:event} + {/exp:channel:entries} +{/exp:easy_ical:calendar} +``` + +## Changelog + +### 2.0.0 *(2020-03-11)* + +- ExpressionEngine 3+ compatibility +- Refactored methods +- Overhauled documentation + +### 1.3.0 *(2013-07-08)* + +- Updated `name` attr to `calendar_name` +- Fixed a few conditionals + +### 1.2.0 *(2013-07-08)* + +- ExpressionEngine 2.6 compatibility + +### 1.1.1 *(2011-06-09)* + +- Adjusted the output slightly to fix compatibility issues with some versions of iCal + +### 1.1.0 *(2011-05-05)* + +- Added url="" and sequence="" parameters (thanks to [GDmac](http://github.com/GDmac)) + +### 1.0.0 *(2010-11-24)* + +- Initial release + +## License + +Copyright © Crescendo Multimedia Ltd and individual contributors. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. +3. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +## Disclaimer + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/easy_ical/addon.setup.php b/easy_ical/addon.setup.php new file mode 100755 index 0000000..85c424f --- /dev/null +++ b/easy_ical/addon.setup.php @@ -0,0 +1,28 @@ + EASY_ICAL_NAME, + 'version' => EASY_ICAL_VERSION, + 'author' => EASY_ICAL_AUTHOR, + 'author_url' => EASY_ICAL_AUTHOR_URL, + 'docs_url' => EASY_ICAL_DOCS, + 'description' => EASY_ICAL_DESC, + 'namespace' => EASY_ICAL_NAMESPACE, + 'settings_exist' => FALSE +); + +/* End of file addon.setup.php */ +/* Location: /system/expressionengine/third_party/easy_ical/addon.setup.php */ \ No newline at end of file diff --git a/easy_ical/config.php b/easy_ical/config.php new file mode 100755 index 0000000..de30c75 --- /dev/null +++ b/easy_ical/config.php @@ -0,0 +1,27 @@ +ExpressionEngine Plugin that creates valid iCalendar ICS files.
Documentation and Usage: ' . EASY_ICAL_DOCS . ''); + define('EASY_ICAL_PACKAGE', 'easy_ical'); + define('EASY_ICAL_NAMESPACE', 'javashakes\EasyiCal'); + define('EASY_ICAL_CLASS_NAME', 'Easy_ical'); +} + +/* End of file config.php */ +/* Location: ./system/expressionengine/third_party/easy_ical/config.php */ diff --git a/easy_ical/pi.easy_ical.php b/easy_ical/pi.easy_ical.php new file mode 100755 index 0000000..77b5de6 --- /dev/null +++ b/easy_ical/pi.easy_ical.php @@ -0,0 +1,158 @@ + EASY_ICAL_NAME, + 'pi_version' => EASY_ICAL_VERSION, + 'pi_author' => EASY_ICAL_AUTHOR, + 'pi_author_url' => EASY_ICAL_AUTHOR_URL, + 'pi_description' => EASY_ICAL_DESC +); + +class Easy_ical +{ + + public $return_data = ''; + + /** + * Constructor + * + * @access public + * @return string + */ + public function __construct() + { + // default output + $this->return_data = '' . EASY_ICAL_NAME . '/i', "\n\n", $str);
+ $str = preg_replace('/\
/i', "\n", $str);
+ $str = strip_tags($str);
+ $str = trim(html_entity_decode($str, ENT_QUOTES, 'UTF-8'));
+
+ // no more than two newlines please
+ $str = preg_replace("/(\r?\n){3,}/", "\n\n", $str);
+
+ // lines can't be more than 75 chars, use 60 to be safe
+ $lines = str_split($str, 60);
+
+ foreach ($lines as $key => $line) {
+ // escape special icalendar chars and convert newlines to '\n'
+ $lines[$key] = str_replace(array('\\', ',', ';'), array('\\\\', '\,', '\;'), $lines[$key]);
+ $lines[$key] = preg_replace("/\r?\n/", '\n', $lines[$key]);
+ }
+
+ return implode("\r\n ", $lines);
+ }
+
+ /**
+ * HELPER: DATE FORMATTING
+ *
+ * @access public
+ * @return string
+ */
+ public function ical_time($time)
+ {
+ return ee()->localize->format_date('%Y%m%dT%H%i%s', $time);
+ }
+
+}
+
+/* End of file pi.easy_ical.php */
+/* Location: /system/expressionengine/third_party/easy_ical/pi.easy_ical.php */
\ No newline at end of file
diff --git a/system/expressionengine/third_party/easy_ical/README.md b/system/expressionengine/third_party/easy_ical/README.md
deleted file mode 100755
index 6fd6a40..0000000
--- a/system/expressionengine/third_party/easy_ical/README.md
+++ /dev/null
@@ -1,98 +0,0 @@
-Easy iCalendar ExpressionEngine Plugin
-======================================
-
-Create valid iCalendars in seconds.
-
-Requirements
-------------
-
-* ExpressionEngine 2.1.3+
-
-Installation
-------------
-
-To install Easy iCalendar, simply copy the entire `easy_ical` folder to
-`/system/expressionengine/third_party` on your server.
-
-Complete Example
-----------------
-
- {exp:easy_ical:calendar timezone="Pacific/Auckland" name="My Simple Event Calendar"}
- {exp:channel:entries channel="events" show_future_entries="yes" show_expired="yes" limit="20"}
- {exp:easy_ical:event uid="{entry_id}" start_time="{entry_date}" end_time="{expiration_date}" location="{event_location}" summary="{title}"}
- {event_description}
- {/exp:easy_ical:event}
- {/exp:channel:entries}
- {/exp:easy_ical:calendar}
-
-All of the CRLF line endings and character escaping will be handled for you automatically.
-
-**NOTE: Any code in your template outside of the {exp:easy_ical:calendar} tag will be ignored!**
-
-Calendar Tag Parameters
------------------------
-
-### timezone="Pacific/Auckland"
-
-Specify the timezone for all dates
-
-### name="My Calendar"
-
-Give your calendar a name
-
-### content_type="text/plain"
-
-Force the specified content type (for debugging). Defaults to `text/calendar; charset=UTF-8`
-
-Event Tag Parameters
---------------------
-
-Any text inside the event tag will be used as the event description.
-
-### uid="{entry_id}"
-
-A unique identifier for the event
-
-### start_time="{entry_date}"
-
-The event start time/date
-
-### end_time="{expiration_date}"
-
-The event end time/date
-
-### location="{event_location}"
-
-The event location (text). You probably want to pull this from a custom channel field.
-
-### summary="{title}"
-
-The event summary (title). You probably want to pull this from a custom channel field.
-
-### url="{url_title_path='group/template'}"
-
-Allows you to add a link to the event.
-
-### sequence="{event_sequence}"
-
-This adds a simple sequence number to the event. This is needed if you update an entry, otherwise
-iCal won't update the event. Use a simple counter custom field, like [Reevision](http://github.com/GDmac/Reevision.ee_addon)
-
-Changelog
----------
-
-**1.2** *(2013-07-08)*
-
-* ExpressionEngine 2.6 compatibility
-
-**1.1.1** *(2011-06-09)*
-
-* Adjusted the output slightly to fix compatibility issues with some versions of iCal
-
-**1.1** *(2011-05-05)*
-
-* Added url="" and sequence="" parameters (thanks to [GDmac](http://github.com/GDmac))
-
-**1.0** *(2010-11-24)*
-
-* Initial release
diff --git a/system/expressionengine/third_party/easy_ical/pi.easy_ical.php b/system/expressionengine/third_party/easy_ical/pi.easy_ical.php
deleted file mode 100755
index ed75665..0000000
--- a/system/expressionengine/third_party/easy_ical/pi.easy_ical.php
+++ /dev/null
@@ -1,143 +0,0 @@
- 'Easy iCalendar',
- 'pi_version' => Easy_ical::VERSION,
- 'pi_author' => 'Exp:resso',
- 'pi_author_url' => 'http://exp-resso.com/',
- 'pi_description' => 'Create valid iCalendars in seconds',
- 'pi_usage' => Easy_ical::usage(),
-);
-
-class Easy_ical
-{
- const VERSION = '1.2';
-
- public function calendar()
- {
- $out = "BEGIN:VCALENDAR\r\nVERSION:2.0\r\n";
- $out .= "PRODID:-//ExpressionEngine Easy iCalendar plugin//NONSGML v".self::VERSION ."//EN\r\n";
-
- if (ee()->TMPL->fetch_param('timezone') !== FALSE) {
- $out .= "X-WR-TIMEZONE:".$this->escape(ee()->TMPL->fetch_param('timezone'))."\r\n";
- }
-
- if (ee()->TMPL->fetch_param('calname') !== FALSE) {
- $out .= "X-WR-CALNAME:".$this->escape(ee()->TMPL->fetch_param('calname'))."\r\n";
- }
-
- // EE has probably put heaps of useless whitespace between each entry
- $tagdata = trim(ee()->TMPL->tagdata);
- $tagdata = preg_replace('/END\:VEVENT\s*BEGIN\:VEVENT/', "END:VEVENT\r\nBEGIN:VEVENT", $tagdata);
- if (!empty($tagdata)) $out .= $tagdata."\r\n";
-
- $out .= "END:VCALENDAR";
-
- // print output directly with the correct content-type
- $content_type = ee()->TMPL->fetch_param('content_type');
- if (empty($content_type)) $content_type = 'text/calendar; charset=UTF-8';
-
- header('Content-Type: '.$content_type);
- exit($out);
- }
-
- public function event()
- {
- $out = "BEGIN:VEVENT\r\n".
- "UID:".$this->escape(ee()->TMPL->fetch_param('uid'))."\r\n";
-
- 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";
-
- if (ee()->TMPL->fetch_param('end_time') !== FALSE) {
- $out .= "DTEND:".$this->ical_time(ee()->TMPL->fetch_param('end_time'))."\r\n";
- }
-
- if (ee()->TMPL->fetch_param('summary') !== FALSE) {
- $out .= "SUMMARY:".$this->escape(ee()->TMPL->fetch_param('summary'))."\r\n";
- }
-
- if (ee()->TMPL->fetch_param('sequence') !== FALSE) {
- $out .= "SEQUENCE:".$this->escape(ee()->TMPL->fetch_param('sequence'))."\r\n";
- }
- if (ee()->TMPL->fetch_param('url') !== FALSE) {
- $out .= "URL:".$this->escape(ee()->TMPL->fetch_param('url'))."\r\n";
- }
-
- $description = trim(ee()->TMPL->tagdata);
- if (!empty($description)) {
- $out .= "DESCRIPTION:".$this->escape($description)."\r\n";
- }
-
- $out .= "END:VEVENT"."\r\n";
-
- return $out;
- }
-
- public function escape($str)
- {
- // strip any html tags
- $str = preg_replace('/\
/i', "\n\n", $str);
- $str = preg_replace('/\
/i', "\n", $str);
- $str = strip_tags($str);
- $str = trim(html_entity_decode($str, ENT_QUOTES, 'UTF-8'));
-
- // no more than two newlines please
- $str = preg_replace("/(\r?\n){3,}/", "\n\n", $str);
-
- // lines can't be more than 75 chars, use 60 to be safe
- $lines = str_split($str, 60);
-
- foreach ($lines as $key => $line) {
- // escape special icalendar chars and convert newlines to '\n'
- $lines[$key] = str_replace(array('\\', ',', ';'), array('\\\\', '\,', '\;'), $lines[$key]);
- $lines[$key] = preg_replace("/\r?\n/", '\n', $lines[$key]);
- }
-
- return implode("\r\n ", $lines);
- }
-
- public function ical_time($time)
- {
- return ee()->localize->format_date('%Y%m%dT%H%i%s', $time);
- }
-
- public static function usage()
- {
- // for performance only load README if inside control panel
- return REQ == 'CP' ? file_get_contents(PATH_THIRD.'easy_ical/README.md') : '';
- }
-}