Commit 690df398 authored by Robert Rollins's avatar Robert Rollins

Renamed hook_date_ical_import_calendar_alter to...

Renamed hook_date_ical_import_calendar_alter to hook_date_ical_import_vcalendar_alter, to match the export hook.

Also did some minor refactoring and comment editing.

Date iCal 3.0 is nearing completion! The only major task remaining
is to write the migration code.
parent 73d42500
......@@ -49,8 +49,7 @@ function hook_date_ical_export_html_alter(&$text_fields, $view, $context) {
* Modify an event's raw data.
*
* This hook is invoked after Date iCal has gathered all the data it will use
* to build an event object. Use this hook to set values of iCal fields which
* Date iCal doesn't directly support.
* to build an event object.
*
* @param array $event
* A reference to an associative array containing the event's raw data.
......@@ -91,8 +90,8 @@ function hook_date_ical_export_raw_event_alter(&$event, $view, $context) {
* Alter an iCal representation of an event.
*
* This hook allows you to modify an event as it is added to the iCal calendar.
* If Date iCal doesn't support an iCal property that you need to use, then you
* can add it to the event here.
* If Date iCal doesn't support an iCal property that you want your feed to
* include, you can add it to the event using this hook.
*
* @param object $vevent
* A reference to an iCalcreator vevent which will be exported in this feed.
......@@ -149,7 +148,7 @@ function hook_date_ical_export_post_render_alter(&$rendered_calendar, $view) {
* - 'source' FeedsSource object for this Feed.
* - 'fetcher_result': The FeedsFetcherResult object for this Feed.
*/
function hook_date_ical_import_calendar_alter(&$calendar, $context) {
function hook_date_ical_import_vcalendar_alter(&$calendar, $context) {
}
......
......@@ -39,7 +39,7 @@ class DateiCalFeedsParser extends FeedsParser {
'source' => $source,
'fetcher_result' => $fetcher_result,
);
drupal_alter('date_ical_import_calendar', $calendar, $context);
drupal_alter('date_ical_import_vcalendar', $calendar, $context);
// We've got a vcalendar object created from the feed data. Now we need to
// convert that vcalendar into an array of Feeds-compatible data arrays.
......@@ -47,7 +47,7 @@ class DateiCalFeedsParser extends FeedsParser {
require_once(DRUPAL_ROOT . '/' . drupal_get_path('module', 'date_ical') . '/libraries/ParserVcalendar.inc');
$parser = new ParserVcalendar($calendar, $source, $fetcher_result, $source->getConfigFor($this));
// Using either the stored progress pointer (or 0 if it's not set),
// Using the stored progress pointer (or 0 if it's not set),
// determine which section of the feed to parse, then parse it.
$offset = isset($state->pointer) ? $state->pointer : 0;
$limit = $source->importer->getLimit();
......@@ -56,7 +56,7 @@ class DateiCalFeedsParser extends FeedsParser {
// Report progress.
$state->total = $parser->getTotalComponents();
// We need to add 1 to the index of the last parsed componenent so that
// the subsequent batch starts on the *next* component.
// the subsequent batch starts on the first unparsed component.
$state->pointer = $parser->getLastComponentParsed() + 1;
$state->progress($state->total, $state->pointer);
......
......@@ -333,7 +333,7 @@ class date_ical_plugin_row_ical_entity extends views_plugin_row {
// According to the iCal standard, CREATED and LAST-MODIFIED must be UTC.
// Fortunately, Drupal stores timestamps in the DB as UTC, so we just need
// to tell Date to treat the timestamp as UTC from the start.
// to tell DateObject to treat the timestamp as UTC from the start.
if (isset($entity->created)) {
$event['created'] = new DateObject($entity->created, 'UTC');
}
......
......@@ -138,23 +138,20 @@ class date_ical_plugin_style_ical_feed extends views_plugin_style {
$vcalendar = new vcalendar($config);
$vcalendar->setMethod('PUBLISH');
// If the iCal Calendar Name has been set in the Feed Style options, it's used as the
// title in the iCal feed. If not, the View Title is used. If that is also blank, then
// the Site Name is used.
$cal_name = $this->_get_option('cal_name');
if (empty($cal_name)) {
$view_title = $this->view->get_title();
if (!empty($view_title)) {
$cal_name = $view_title;
// Only include the X-WR-CALNAME property if the user didn't enable
// the "Exclude Calendar Name" option.
if (!$this->_get_option('no_calname')) {
$cal_name = $this->_get_option('cal_name');
if (empty($cal_name)) {
$cal_name = $this->view->get_title();
if (empty($cal_name)) {
$cal_name = variable_get('site_name', 'Drupal');
}
}
else {
$cal_name = variable_get('site_name', 'Drupal');
if (!empty($cal_name)) {
$vcalendar->setProperty('X-WR-CALNAME', $cal_name, array('VALUE' => 'TEXT'));
}
}
// Only include the X-WR-CALNAME property if the user didn't check "Exclude Calendar Name".
if (!$this->_get_option('no_calname')) {
$vcalendar->setProperty('x-wr-calname', $cal_name, array('VALUE' => 'TEXT'));
}
// Now add the VEVENTs.
$timezones = array();
......@@ -167,6 +164,9 @@ class date_ical_plugin_style_ical_feed extends views_plugin_style {
}
$vevent = $vcalendar->newComponent('vevent');
$vevent->setUid($event['uid']);
$vevent->setSummary($event['summary']);
// Get the start date as an array.
$start = $event['start']->toArray();
$start_timezone = $event['start']->getTimezone()->getName();
......@@ -215,8 +215,6 @@ class date_ical_plugin_style_ical_feed extends views_plugin_style {
}
$end['tz'] = $event['end']->getTimezone();
}
$vevent->setProperty('uid', $event['uid']);
$vevent->setProperty('summary', $event['summary']);
// Handle repeating dates from the date_repeat module.
if (!empty($event['rrule']) && module_exists('date_repeat')) {
......@@ -311,10 +309,10 @@ class date_ical_plugin_style_ical_feed extends views_plugin_style {
$vevent->setUrl($event['url'], array('type' => 'URI'));
}
if (!empty($event['location'])) {
$vevent->setProperty('location', $event['location']);
$vevent->setLocation($event['location']);
}
if (!empty($event['description'])) {
$vevent->setProperty('description', $event['description']);
$vevent->setDescription($event['description']);
}
if (!empty($event['last-modified'])) {
$lm = $event['last-modified']->toArray();
......@@ -356,10 +354,10 @@ class date_ical_plugin_style_ical_feed extends views_plugin_style {
drupal_alter('date_ical_export_vcalendar', $vcalendar, $this->view);
$output = $vcalendar->createCalendar();
// iCalcreator escapes all commas and semicolons in the strings that it,
// as the spec demands. However, some calendar clients are buggy and
// don't unescape these characters. Users may choose to unescape them
// here to sidestep those clients' bugs.
// iCalcreator escapes all commas and semicolons in string values, as the
// spec demands. However, some calendar clients are buggy and fail to
// unescape these characters. Users may choose to unescape them here to
// sidestep those clients' bugs.
// NOTE: This results in a non-compliant iCal feed, but it seems like a
// LOT of major clients are bugged this way.
if ($this->_get_option('unescape_punctuation')) {
......@@ -396,7 +394,7 @@ class date_ical_plugin_style_ical_feed extends views_plugin_style {
// need to manually instruct browsers to download a .ics file.
if (!variable_get('clean_url', FALSE)) {
$path_array = explode('/', $this->display->display_options['path']);
$filename = array_pop($path_array);
$filename = end($path_array);
drupal_add_http_header('Content-Disposition', "attachment; filename=\"$filename\"");
}
}
......@@ -430,8 +428,7 @@ class date_ical_plugin_style_ical_feed extends views_plugin_style {
if (strtoupper($key) == 'BYDAY') {
$new_byday = array();
foreach ($value as $day) {
// Fortunately, the weekday values are always 2 characters, so it's easy to
// split off the ordwk part, even though it could be 1 or 2 characters.
// Fortunately, the weekday values are always 2 characters.
$weekday = substr($day, -2);
$ordwk = substr($day, 0, -2);
$new_byday[] = array($ordwk, 'DAY' => $weekday);
......
......@@ -34,15 +34,13 @@ class ParserVcalendar {
* Parses the vcalendar object into an array of event data arrays.
*
* @param int $offset
* This parameter, along with $limit, specfy which section of the feed
* to parse. Useful for batch operation.
* Specifies which section of the feed to start parsing at.
*
* @param int $limit
* This parameter, along with $offset, specfy which section of the feed
* to parse. Useful for batch operation.
* Specifies how many components to parse on this run.
*
* @return array
* An array of parsed event data keyed by the same property keys as
* An array of parsed event data keyed by the same strings as the array
* returned by DateiCalFeedsParser::getiCalMappingSources().
*/
public function parse($offset, $limit) {
......@@ -103,7 +101,7 @@ class ParserVcalendar {
$events[] = $parsed_component;
// The indices of the original $raw_components array are preserved in
// $batch, so using the $ndx value here lets us communicate our progress
// through the full collection of commpenents.
// through the full collection of components.
$this->lastComponentParsed = $ndx;
}
......@@ -166,7 +164,7 @@ class ParserVcalendar {
$dtend = $vcalendar_component->getProperty('DTEND', FALSE, TRUE);
$uid = $vcalendar_component->getProperty('UID');
// DATE-type values are treated as All Day events which can span over
// DATE-type properties are treated as All Day events which can span over
// multiple days.
// The Date module's All Day event handling was never finalized
// (http://drupal.org/node/874322), which requires us to do some some
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment