Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
drupal.org
date_ical
Commits
cf6e11e3
Commit
cf6e11e3
authored
Jan 11, 2013
by
Robert Rollins
Browse files
Initial commit of 7.x-2.x branch
parent
a5a5d3d3
Changes
4
Hide whitespace changes
Inline
Side-by-side
includes/DateIcalDateModuleParser.inc
View file @
cf6e11e3
...
...
@@ -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'
);
}
}
...
...
includes/date_ical_plugin_style_ical_feed.inc
View file @
cf6e11e3
...
...
@@ -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
;
}
}
tests/date_ical_parser.test
View file @
cf6e11e3
...
...
@@ -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'
);
}
/**
...
...
tests/date_ical_parser_date.test
View file @
cf6e11e3
...
...
@@ -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
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment