Commit cf6e11e3 authored by Robert Rollins's avatar Robert Rollins

Initial commit of 7.x-2.x branch

parent a5a5d3d3
......@@ -130,7 +130,7 @@ class DateIcalDateModuleParser extends DateIcalFeedsParser {
* Load the Date API.
*/
static public function loadLibrary() {
include_once(drupal_get_path('module', 'date_api') .'/date_api_ical.inc');
include_once(drupal_get_path('module', 'date_api') . '/date_api_ical.inc');
}
}
......
......@@ -129,7 +129,9 @@ class date_ical_plugin_style_ical_feed extends views_plugin_style {
if (!empty($row['rrule']) && module_exists('date_repeat')) {
// Split the rrule into the actual rule, exceptions and additions.
list($rrule, $exceptions, $additions) = date_repeat_split_rrule($row['rrule']);
// Add the rrule itself.
// Add the rrule itself. We need to massage the data a bit, since iCalcreator expects RRULEs to be
// in a different format than the Date API gives them to us.
$rrule = self::convert_rrule_for_icalcreator($rrule);
$vevent->setRrule($rrule);
// Process exceptions if there are any.
if (!empty($exceptions)) {
......@@ -240,4 +242,37 @@ class date_ical_plugin_style_ical_feed extends views_plugin_style {
return $output;
}
/**
* This function converts an rrule array to the iCalcreator format.
*
* iCalcreator expects the BYDAY element to be an array like this:
* (array) ( [([plus] ordwk / minus ordwk)], "DAY" => weekday )
*
* But the way that the Date API gives it to us is like this:
* (array) ( [([plus] ordwk / minus ordwk)]weekday )
*/
public static function convert_rrule_for_icalcreator($rrule) {
$new_rrule = array();
foreach ($rrule as $key => $value) {
if (strtoupper($key) == 'DATA') {
// iCalcreator doesn't expect the 'DATA' key that the Date API gives us.
continue;
}
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.
$weekday = substr($day, -2);
$ordwk = substr($day, 0, -2);
$new_byday[] = array($ordwk, 'DAY' => $weekday);
}
$value = $new_byday;
}
$new_rrule[$key] = $value;
}
return $new_rrule;
}
}
......@@ -10,7 +10,7 @@
*/
class DateIcalFeedsParserTestCase extends FeedsMapperTestCase {
public function absolutePath() {
return $this->absolute() . '/'. drupal_get_path('module', 'date_ical');
return $this->absolute() . '/' . drupal_get_path('module', 'date_ical');
}
/**
......
......@@ -19,19 +19,19 @@ abstract class DateIcalFeedsParserDateTestCase extends DateIcalFeedsParserTestCa
function testBasic() {
// Create content type for feed items.
$fields = array(
'pidt_date' => array (
'pidt_date' => array(
'type' => 'date',
'settings' => array(
'field[settings][enddate_get]' => 1,
),
),
'pidt_datetime' => array (
'pidt_datetime' => array(
'type' => 'datetime',
'settings' => array(
'field[settings][enddate_get]' => 1,
),
),
'pidt_datestamp' => array (
'pidt_datestamp' => array(
'type' => 'datestamp',
'settings' => array(
'field[settings][enddate_get]' => 1,
......@@ -89,12 +89,12 @@ abstract class DateIcalFeedsParserDateTestCase extends DateIcalFeedsParserTestCa
*/
public function testTimezones() {
// set users timezone
$this->drupalPost('user/' .$this->admin_user->uid .'/edit', array('timezone' => 'Africa/Bangui'), t('Save'));
$this->drupalPost("user/{$this->admin_user->uid}/edit", array('timezone' => 'Africa/Bangui'), t('Save'));
// Create content type for feed items.
$fields = array(
// Pacific/Apia
'pidt_site' => array (
'pidt_site' => array(
'type' => 'date',
'settings' => array(
'field[settings][enddate_get]' => 1,
......@@ -102,7 +102,7 @@ abstract class DateIcalFeedsParserDateTestCase extends DateIcalFeedsParserTestCa
),
),
// in field
'pidt_date' => array (
'pidt_date' => array(
'type' => 'date',
'settings' => array(
'field[settings][enddate_get]' => 1,
......@@ -110,7 +110,7 @@ abstract class DateIcalFeedsParserDateTestCase extends DateIcalFeedsParserTestCa
),
),
// Africa/Bangui (same user entering and viewing)
'pidt_user' => array (
'pidt_user' => array(
'type' => 'date',
'settings' => array(
'field[settings][enddate_get]' => 1,
......@@ -118,7 +118,7 @@ abstract class DateIcalFeedsParserDateTestCase extends DateIcalFeedsParserTestCa
),
),
// utc
'pidt_utc' => array (
'pidt_utc' => array(
'type' => 'date',
'settings' => array(
'field[settings][enddate_get]' => 1,
......@@ -126,7 +126,7 @@ abstract class DateIcalFeedsParserDateTestCase extends DateIcalFeedsParserTestCa
),
),
// none
'pidt_none' => array (
'pidt_none' => array(
'type' => 'date',
'settings' => array(
'field[settings][enddate_get]' => 1,
......
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