diff options
author | Kevin Jardine <kevinjardine@yahoo.com> | 2011-09-28 17:02:51 +0200 |
---|---|---|
committer | Kevin Jardine <kevinjardine@yahoo.com> | 2011-09-28 17:02:51 +0200 |
commit | 8b595e63700e1ebaf0f31b08b0009922acc780e3 (patch) | |
tree | 986f80c2acca023c8734e4758f03e96c1a43cd44 | |
parent | 1bba961e3cea230e7d6a62a5016c5ea23a5c0e76 (diff) | |
download | elgg-8b595e63700e1ebaf0f31b08b0009922acc780e3.tar.gz elgg-8b595e63700e1ebaf0f31b08b0009922acc780e3.tar.bz2 |
restored RSS feed and added iCal feed
-rw-r--r-- | images/ics.png | bin | 0 -> 344 bytes | |||
-rw-r--r-- | languages/en.php | 2 | ||||
-rw-r--r-- | models/model.php | 23 | ||||
-rw-r--r-- | views/ical/event_calendar/show_events.php | 7 | ||||
-rw-r--r-- | views/ical/object/event_calendar.php | 44 | ||||
-rw-r--r-- | views/ical/page/default.php | 17 | ||||
-rw-r--r-- | views/ical/page/layouts/default.php | 2 | ||||
-rw-r--r-- | views/rss/event_calendar/show_events.php | 1 |
8 files changed, 94 insertions, 2 deletions
diff --git a/images/ics.png b/images/ics.png Binary files differnew file mode 100644 index 000000000..311ffa221 --- /dev/null +++ b/images/ics.png diff --git a/languages/en.php b/languages/en.php index 5aa96adee..883576b3b 100644 --- a/languages/en.php +++ b/languages/en.php @@ -209,6 +209,8 @@ You can manage calendar requests for this event here: 'event_calendar:error_event_edit' => "Error: there is no such event or you do not have permission to edit it.", 'event_calendar:add' => "Add", + 'feed:ical' => "iCal feed for this page", + /** * Event calendar river **/ diff --git a/models/model.php b/models/model.php index 4a7da3dd1..dafc10bc9 100644 --- a/models/model.php +++ b/models/model.php @@ -1096,6 +1096,8 @@ function event_calendar_send_event_request($event,$user_guid) { // pages function event_calendar_get_page_content_list($page_type,$group_guid,$start_date,$display_mode,$filter,$region='-') { + global $autofeed; + $autofeed = true; if ($page_type == 'group') { if (!event_calendar_activated_for_group($group_guid)) { forward(); @@ -1149,8 +1151,26 @@ function event_calendar_get_page_content_list($page_type,$group_guid,$start_date } } } + + $url = full_url(); + if (substr_count($url, '?')) { + $url .= "&view=ical"; + } else { + $url .= "?view=ical"; + } $params = event_calendar_generate_listing_params($page_type,$group_guid,$start_date,$display_mode,$filter,$region); + + $url = elgg_format_url($url); + $menu_options = array( + 'name' => 'ical', + 'text' => '<img src="'.elgg_get_site_url().'mod/event_calendar/images/ics.png" />', + 'href' => $url, + 'title' => elgg_echo('feed:ical'), + 'priority' => 800, + ); + $menu_item = ElggMenuItem::factory($menu_options); + elgg_register_menu_item('extras', $menu_item); $body = elgg_view_layout("content", $params); @@ -1348,8 +1368,8 @@ function event_calendar_generate_listing_params($page_type,$group_guid,$original $user_guid = elgg_get_logged_in_user_guid(); $offset = get_input('offset'); + $limit = get_input('limit',15); - $limit = 15; if ($event_calendar_spots_display == 'yes') { if (!$filter) { $filter = 'open'; @@ -1391,6 +1411,7 @@ function event_calendar_generate_listing_params($page_type,$group_guid,$original ); $content = elgg_view('event_calendar/show_events', $vars); + $filter_override = elgg_view('event_calendar/filter_menu',$vars); if ($event_calendar_listing_format == 'paged') { diff --git a/views/ical/event_calendar/show_events.php b/views/ical/event_calendar/show_events.php new file mode 100644 index 000000000..19981596f --- /dev/null +++ b/views/ical/event_calendar/show_events.php @@ -0,0 +1,7 @@ +<?php +if ($vars['events']) { + foreach ($vars['events'] as $entity) { + echo elgg_view_entity($entity); + } + //echo elgg_view_entity_list($vars['events'], $vars['count'], $vars['offset'], $vars['limit'], false, false); +} diff --git a/views/ical/object/event_calendar.php b/views/ical/object/event_calendar.php new file mode 100644 index 000000000..a6ed889e5 --- /dev/null +++ b/views/ical/object/event_calendar.php @@ -0,0 +1,44 @@ +<?php +$event = $vars['entity']; +if ($event->organizer) { + $organizer = "\nORGANIZER;CN={$event->organizer}\n"; +} else { + $organizer = ''; +} + +if ($event->description) { + // make sure that we are using Unix line endings + $description = str_replace("\r\n","\n",$event->description); + $description = str_replace("\r","\n",$description); + + // now convert to icalendar format + $description = str_replace("\n",'\n',$description); + $description = wordwrap($description,75,"\r\n ",TRUE); +} else { + $description = ''; +} +?> +BEGIN:VEVENT +UID:<?php echo elgg_get_site_url().'event_calendar/view/'.$event->guid; ?> + +URL:<?php echo elgg_get_site_url().'event_calendar/view/'.$event->guid; ?> + +DTSTAMP:<?php echo date("Ymd\THis\Z", $event->getTimeUpdated())?> + +CREATED:<?php echo date("Ymd\THis\Z", $event->getTimeCreated())?> + +LAST-MODIFIED:<?php echo date("Ymd\THis\Z", $event->getTimeUpdated()) ?> + +DTSTART:<?php echo date("Ymd\THis\Z", $event->start_date); ?> + +DTEND:<?php echo date("Ymd\THis\Z", $event->real_end_time); ?> + +SUMMARY:<?php echo $event->title; ?> + +DESCRIPTION:<?php echo $description; ?> + +LOCATION:<?php echo $event->venue; ?><?php echo $organizer; ?> + +CATEGORIES:<?php implode(",",$event->tags); ?> + +END:VEVENT diff --git a/views/ical/page/default.php b/views/ical/page/default.php new file mode 100644 index 000000000..b8347c9a0 --- /dev/null +++ b/views/ical/page/default.php @@ -0,0 +1,17 @@ +<?php +/** + * Elgg ICAL output pageshell + * + * @package Elgg + * @subpackage Core + * + */ + +header("Content-Type: text/calendar"); +header("Content-Disposition: attachment; filename=\"calendar.ics\""); +?> +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//Curverider Ltd//NONSGML Elgg <?php echo get_version(true); ?>//EN +<?php echo $vars['body']; ?> +END:VCALENDAR diff --git a/views/ical/page/layouts/default.php b/views/ical/page/layouts/default.php new file mode 100644 index 000000000..57598fa1b --- /dev/null +++ b/views/ical/page/layouts/default.php @@ -0,0 +1,2 @@ +<?php +echo $vars['content'];
\ No newline at end of file diff --git a/views/rss/event_calendar/show_events.php b/views/rss/event_calendar/show_events.php index 0b2fe5b70..add5b75db 100644 --- a/views/rss/event_calendar/show_events.php +++ b/views/rss/event_calendar/show_events.php @@ -9,7 +9,6 @@ * @link http://radagast.biz/ * */ - if ($vars['events']) { echo elgg_view_entity_list($vars['events'], $vars['count'], $vars['offset'], $vars['limit'], false, false); } |