Commit 32126161 authored by Robert Rollins's avatar Robert Rollins

Fixed up loads of issues reported by www.PAReview.sh

parent 1e130962
...@@ -23,10 +23,11 @@ Date iCal has several required dependencies, and an optional one: ...@@ -23,10 +23,11 @@ Date iCal has several required dependencies, and an optional one:
- The Feeds module is optional, but it's needed to enable import of iCal feeds - The Feeds module is optional, but it's needed to enable import of iCal feeds
from other sites. from other sites.
To install the iCalcreator library, download it from http://github.com/iCalcreator/iCalcreator To install the iCalcreator library, download it from the project's github:
using either git clone or the "Download Zip" button. Inside you'll find the file http://github.com/iCalcreator/iCalcreator
iCalcreator.class.php. Copy that file to a folder in your Drupal site named Using either git clone or the "Download Zip" button, you'll find the file
sites/all/libraries/iCalcreator. iCalcreator.class.php inside. Copy that file to a folder in your Drupal site
named sites/all/libraries/iCalcreator.
Or, if you have drush, install iCalcreator by running this command from your Or, if you have drush, install iCalcreator by running this command from your
site's root directory: site's root directory:
...@@ -50,10 +51,10 @@ the iCal Fields plugin is a bit more versatile. ...@@ -50,10 +51,10 @@ the iCal Fields plugin is a bit more versatile.
HOW TO EXPORT AN ICAL FEED USING THE iCal Entities PLUGIN HOW TO EXPORT AN ICAL FEED USING THE iCal Entities PLUGIN
1. Go to the Manage Display page for the content type you want to export in an 1. Go to the Manage Display page for the content type you want to export in an
iCal feed. On the "Default" tab, check the box for "iCal" in the section iCal feed. On the "Default" tab, check the box for "iCal" in the section
titled "Use custom display settings for the following view modes", then click titled "Use custom display settings for the following view modes", then
Save. click Save.
2. Click the new "iCal" tab that now appears in the upper-right corner of the 2. Click the new "iCal" tab that now appears in the upper-right corner of the
Manage Display page for this content type. Manage Display page for this content type.
3. Set up the iCal view mode to contain whatever should be exported as the 3. Set up the iCal view mode to contain whatever should be exported as the
...@@ -63,10 +64,10 @@ HOW TO EXPORT AN ICAL FEED USING THE iCal Entities PLUGIN ...@@ -63,10 +64,10 @@ HOW TO EXPORT AN ICAL FEED USING THE iCal Entities PLUGIN
site's iCal feeds. site's iCal feeds.
5. Create a new View that displays the entities that you want to include in the 5. Create a new View that displays the entities that you want to include in the
iCal feed. iCal feed.
6. Add a "Feed" to the view. Change the Format to 'iCal Feed'. When you click 6. Add a "Feed" to the view. Change the Format to 'iCal Feed'. When you click
Apply from that dialog, you'll be given the option to name the calendar. This Apply from that dialog, you'll be given the option to name the calendar,
name will appear in your users' calendar clients as the calendar's title. which will appear in your users' calendar clients as the calendar's title.
7. Change the Show setting to 'iCal Entity' (rather than 'Content' or 'Fields'). 7. Change the Show setting to 'iCal Entity'.
8. In the settings for iCal Entity, select the date field that should be used 8. In the settings for iCal Entity, select the date field that should be used
as the event date for the iCal feed. Make sure that you choose a field that as the event date for the iCal feed. Make sure that you choose a field that
is a part of every entity that your View displays. Otherwise, the entities is a part of every entity that your View displays. Otherwise, the entities
...@@ -95,10 +96,10 @@ HOW TO EXPORT AN ICAL FEED USING THE iCal Entities PLUGIN ...@@ -95,10 +96,10 @@ HOW TO EXPORT AN ICAL FEED USING THE iCal Entities PLUGIN
HOW TO EXPORT AN ICAL FEED USING THE iCal Fields PLUGIN HOW TO EXPORT AN ICAL FEED USING THE iCal Fields PLUGIN
1-6.These steps are the same as above. 1-6.These steps are the same as above.
7. Add views fields for each piece of information that you want to populate your 7. Add views fields for each piece of information that you want to populate
iCal feed with. A Date field is required, and fields that will act as the your iCal feed with. A Date field is required, and fields that will act as
Title and Description of the events are reccomended. You can also include a the Title and Description of the events are reccomended. You can also
Location field. include a Location field.
8. Back in the FORMAT section, change the Show setting to 'iCal Fields'. 8. Back in the FORMAT section, change the Show setting to 'iCal Fields'.
9. In the settings for iCal Fields, choose which views fields you want to use 9. In the settings for iCal Fields, choose which views fields you want to use
for the Date, Title, Description, and Location. for the Date, Title, Description, and Location.
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
* - 'summary': The title field string * - 'summary': The title field string
* - 'location': The location field string. * - 'location': The location field string.
* @param object $view * @param object $view
* The view object that is being executed to render the iCal feed. * The view object that is being executed to render the iCal feed.
* @param array $context * @param array $context
* Depending on whether this event is being constructed using the Fields or * Depending on whether this event is being constructed using the Fields or
* Entity plugins, this context array will have different keys and values. * Entity plugins, this context array will have different keys and values.
...@@ -96,7 +96,7 @@ function hook_date_ical_export_raw_event_alter(&$event, $view, $context) { ...@@ -96,7 +96,7 @@ function hook_date_ical_export_raw_event_alter(&$event, $view, $context) {
* @param object $vevent * @param object $vevent
* A reference to an iCalcreator vevent which will be exported in this feed. * A reference to an iCalcreator vevent which will be exported in this feed.
* @param object $view * @param object $view
* The view object that is being executed to render the iCal feed. * The view object that is being executed to render the iCal feed.
* @param object $event_array * @param object $event_array
* The array representation of the event that's been rendered to the $vevent. * The array representation of the event that's been rendered to the $vevent.
*/ */
...@@ -113,7 +113,7 @@ function hook_date_ical_export_vevent_alter(&$vevent, $view, $event_array) { ...@@ -113,7 +113,7 @@ function hook_date_ical_export_vevent_alter(&$vevent, $view, $event_array) {
* @param object $vcalendar * @param object $vcalendar
* A reference to the iCalcreator vcalendar object representing this feed. * A reference to the iCalcreator vcalendar object representing this feed.
* @param object $view * @param object $view
* The view object that is being executed to render the iCal feed. * The view object that is being executed to render the iCal feed.
*/ */
function hook_date_ical_export_vcalendar_alter(&$vcalendar, $view) { function hook_date_ical_export_vcalendar_alter(&$vcalendar, $view) {
...@@ -128,7 +128,7 @@ function hook_date_ical_export_vcalendar_alter(&$vcalendar, $view) { ...@@ -128,7 +128,7 @@ function hook_date_ical_export_vcalendar_alter(&$vcalendar, $view) {
* @param string $rendered_calendar * @param string $rendered_calendar
* A reference to the string containing the rendered the iCal feed. * A reference to the string containing the rendered the iCal feed.
* @param object $view * @param object $view
* The view that is being executed to render this iCal feed. * The view that is being executed to render this iCal feed.
*/ */
function hook_date_ical_export_post_render_alter(&$rendered_calendar, $view) { function hook_date_ical_export_post_render_alter(&$rendered_calendar, $view) {
...@@ -149,7 +149,7 @@ function hook_date_ical_export_post_render_alter(&$rendered_calendar, $view) { ...@@ -149,7 +149,7 @@ function hook_date_ical_export_post_render_alter(&$rendered_calendar, $view) {
* - 'fetcher_result': The FeedsFetcherResult object for this Feed. * - 'fetcher_result': The FeedsFetcherResult object for this Feed.
*/ */
function hook_date_ical_import_vcalendar_alter(&$calendar, $context) { function hook_date_ical_import_vcalendar_alter(&$calendar, $context) {
} }
/** /**
...@@ -165,14 +165,15 @@ function hook_date_ical_import_vcalendar_alter(&$calendar, $context) { ...@@ -165,14 +165,15 @@ function hook_date_ical_import_vcalendar_alter(&$calendar, $context) {
* - 'fetcher_result': The FeedsFetcherResult object for this Feed. * - 'fetcher_result': The FeedsFetcherResult object for this Feed.
*/ */
function hook_date_ical_import_component_alter(&$component, $context) { function hook_date_ical_import_component_alter(&$component, $context) {
// Example of what might be done with this alter hook // Example of what might be done with this alter hook.
if ($component->objName == 'vevent') { if ($component->objName == 'vevent') {
// Do something for vevents ... // Do something for vevents...
} }
else if ($component->objName == 'valarm') { elseif ($component->objName == 'valarm') {
// Do something different for valarms ... // Do something different for valarms...
} }
} }
/** /**
* Alter the timezone string from an imported iCal Feed. * Alter the timezone string from an imported iCal Feed.
* *
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* Install, update and uninstall functions for the date_ical module. * Install, update and uninstall functions for the date_ical module.
* *
*/ */
/** /**
* Implements hook_requirements(). * Implements hook_requirements().
*/ */
...@@ -41,7 +42,7 @@ function date_ical_requirements($phase) { ...@@ -41,7 +42,7 @@ function date_ical_requirements($phase) {
} }
/** /**
* Implementation of hook_enable(). * Implements of hook_enable().
*/ */
function date_ical_enable() { function date_ical_enable() {
cache_clear_all('plugins:feeds:plugins', 'cache'); cache_clear_all('plugins:feeds:plugins', 'cache');
...@@ -53,6 +54,7 @@ function date_ical_enable() { ...@@ -53,6 +54,7 @@ function date_ical_enable() {
/** /**
* Migrates all iCal feed importers for from Date iCal 2.x to 3.0. * Migrates all iCal feed importers for from Date iCal 2.x to 3.0.
*
* <br> * <br>
* PLEASE NOTE: If any of your importers are defined by Features, you'll need * PLEASE NOTE: If any of your importers are defined by Features, you'll need
* to update their feature(s) to match. * to update their feature(s) to match.
...@@ -96,7 +98,7 @@ function date_ical_update_7300() { ...@@ -96,7 +98,7 @@ function date_ical_update_7300() {
// parser plugin being missing. We corrected that warning above, so we // parser plugin being missing. We corrected that warning above, so we
// should clear it out to avoid potential confusion. // should clear it out to avoid potential confusion.
$messages = drupal_get_messages('warning'); $messages = drupal_get_messages('warning');
foreach($messages['warning'] as $warning) { foreach ($messages['warning'] as $warning) {
// Calling drupal_get_messages() removed *every* warning from the // Calling drupal_get_messages() removed *every* warning from the
// message queue, so we need to re-issue any warnings that aren't // message queue, so we need to re-issue any warnings that aren't
// about missing Feeds plugins. // about missing Feeds plugins.
......
...@@ -18,7 +18,7 @@ define('DATE_ICAL_VERSION', '3.0-dev'); ...@@ -18,7 +18,7 @@ define('DATE_ICAL_VERSION', '3.0-dev');
class DateIcalException extends Exception {} class DateIcalException extends Exception {}
/** /**
* Exception for when the date field for a row in the ical_fields row plugin is blank. * Exception used by iCal Fields for when a date field is blank.
*/ */
class BlankDateFieldException extends DateIcalException {} class BlankDateFieldException extends DateIcalException {}
...@@ -76,7 +76,8 @@ function date_ical_theme($existing, $type, $theme, $path) { ...@@ -76,7 +76,8 @@ function date_ical_theme($existing, $type, $theme, $path) {
} }
/** /**
* The theme for the ical icon. * Theme function for the ical icon used by attached iCal feed.
*
* Available variables are: * Available variables are:
* $variables['tooltip'] - The tooltip to be used for the ican feed icon. * $variables['tooltip'] - The tooltip to be used for the ican feed icon.
* $variables['url'] - The url to the actual iCal feed. * $variables['url'] - The url to the actual iCal feed.
...@@ -98,18 +99,16 @@ function theme_date_ical_icon($variables) { ...@@ -98,18 +99,16 @@ function theme_date_ical_icon($variables) {
} }
/** /**
* Implements hook_preprocess_HOOK() for nodes. * Implements hook_preprocess_HOOK().
* *
* Hide extraneous information when rendering the iCal view mode of a node. * Hides the page elements which don't belong in an iCal DESCRIPTION element.
* The display of the body and other fields is controlled by the Manage
* Display settings for the nodes' iCal view mode.
*/ */
function date_ical_preprocess_node(&$variables) { function date_ical_preprocess_node(&$variables) {
if (isset($variables['view_mode']) && $variables['view_mode'] == 'ical') { if (isset($variables['view_mode']) && $variables['view_mode'] == 'ical') {
// We hide the page elements we won't want to see. // Trick the default node template into not displaying the page title, by
// The display of the body and other fields will be controlled // telling it that this *is* a page.
// by the Manage Display settings for the iCal view mode.
// Trick the default node template into not displaying the page title by
// telling it this is a page.
$variables['page'] = TRUE; $variables['page'] = TRUE;
$variables['title_prefix'] = ''; $variables['title_prefix'] = '';
$variables['title_suffix'] = ''; $variables['title_suffix'] = '';
...@@ -130,7 +129,8 @@ function date_ical_preprocess_node(&$variables) { ...@@ -130,7 +129,8 @@ function date_ical_preprocess_node(&$variables) {
/** /**
* Implements hook_entity_info_alter(). * Implements hook_entity_info_alter().
* *
* Add an 'iCal' view mode for entities, which will be used by the Views style plugin. * Adds an 'iCal' view mode for entities, which is used by the iCal Entity
* View plugin.
*/ */
function date_ical_entity_info_alter(&$entity_info) { function date_ical_entity_info_alter(&$entity_info) {
foreach ($entity_info as $entity_type => $info) { foreach ($entity_info as $entity_type => $info) {
...@@ -181,9 +181,9 @@ function date_ical_ctools_plugin_api($owner, $api) { ...@@ -181,9 +181,9 @@ function date_ical_ctools_plugin_api($owner, $api) {
/** /**
* Implements hook_feeds_processor_targets_alter(). * Implements hook_feeds_processor_targets_alter().
* *
* Adds the "Field Name: Repeat Rule" target to Date Repeat Fields. * Adds the "Field Name: Repeat Rule" target to Date Repeat fields.
* *
* @see FeedsNodeProcessor::getMappingTargets(). * @see FeedsNodeProcessor::getMappingTargets()
*/ */
function date_ical_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) { function date_ical_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
foreach (field_info_instances($entity_type, $bundle_name) as $name => $instance) { foreach (field_info_instances($entity_type, $bundle_name) as $name => $instance) {
...@@ -201,6 +201,7 @@ function date_ical_feeds_processor_targets_alter(&$targets, $entity_type, $bundl ...@@ -201,6 +201,7 @@ function date_ical_feeds_processor_targets_alter(&$targets, $entity_type, $bundl
/** /**
* Reformats the provided text to be compliant with the iCal spec. * Reformats the provided text to be compliant with the iCal spec.
*
* If the text contains HTML tags, those tags will be stripped (with <p> tags * If the text contains HTML tags, those tags will be stripped (with <p> tags
* converted to "\n\n" and link tags converted to footnotes), and uneeded * converted to "\n\n" and link tags converted to footnotes), and uneeded
* whitespace will be cleaned up. * whitespace will be cleaned up.
...@@ -209,11 +210,11 @@ function date_ical_feeds_processor_targets_alter(&$targets, $entity_type, $bundl ...@@ -209,11 +210,11 @@ function date_ical_feeds_processor_targets_alter(&$targets, $entity_type, $bundl
* The text to be sanitized. * The text to be sanitized.
*/ */
function date_ical_sanitize_text($text = '') { function date_ical_sanitize_text($text = '') {
// Use Drupal's built-in HTML to Text converter, which does a mostly adequate // Use Drupal's built-in HTML to Text converter, which does a mostly
// job of making the text iCal-compliant. // adequate job of making the text iCal-compliant.
$text = trim(drupal_html_to_text($text)); $text = trim(drupal_html_to_text($text));
// Replace instances of more than one space with exactly one space. This // Replace instances of more than one space with exactly one space. This
// cleans up the whitespace mess that gets left behind by drupal_html_to_text(). // cleans up the whitespace mess that drupal_html_to_text() leaves behind.
$text = preg_replace("/ +/", " ", $text); $text = preg_replace("/ +/", " ", $text);
// The call to drupal_html_to_text() above converted <p> to \n\n, and also // The call to drupal_html_to_text() above converted <p> to \n\n, and also
// shoved a \n into the string every 80 characters. We don't want those // shoved a \n into the string every 80 characters. We don't want those
...@@ -227,14 +228,14 @@ function date_ical_sanitize_text($text = '') { ...@@ -227,14 +228,14 @@ function date_ical_sanitize_text($text = '') {
/** /**
* Callback specified in date_ical_feeds_processor_targets_alter() for RRULEs. * Callback specified in date_ical_feeds_processor_targets_alter() for RRULEs.
* *
* @param $source * @param object $source
* The FeedsSource object. * The FeedsSource object.
* @param $entity * @param object $entity
* The node that's being built from the iCal element that's being parsed. * The node that's being built from the iCal element that's being parsed.
* @param $target * @param string $target
* The machine name of the field into which this RRULE shall be parsed, * The machine name of the field into which this RRULE shall be parsed,
* with ":rrule" appended to the end. * with ":rrule" appended to the end.
* @param $feed_element * @param string $feed_element
* The RRULE string (with optional EXDATEs and RDATEs separated by \n). * The RRULE string (with optional EXDATEs and RDATEs separated by \n).
*/ */
function date_ical_feeds_set_rrule($source, $entity, $target, $feed_element) { function date_ical_feeds_set_rrule($source, $entity, $target, $feed_element) {
...@@ -247,7 +248,8 @@ function date_ical_feeds_set_rrule($source, $entity, $target, $feed_element) { ...@@ -247,7 +248,8 @@ function date_ical_feeds_set_rrule($source, $entity, $target, $feed_element) {
module_load_include('inc', 'date_api', 'date_api_ical'); module_load_include('inc', 'date_api', 'date_api_ical');
$info = field_info_field($field_name); $info = field_info_field($field_name);
foreach ($entity->{$field_name} as $lang => $field_array) { foreach ($entity->{$field_name} as $lang => $field_array) {
// Add the multiple date values that Date Repeat Field uses to represent recurring dates. // Add the multiple date values that Date Repeat Field uses to represent
// recurring dates.
$values = date_repeat_build_dates($feed_element, NULL, $info, $field_array[0]); $values = date_repeat_build_dates($feed_element, NULL, $info, $field_array[0]);
foreach ($values as $key => $value) { foreach ($values as $key => $value) {
$entity->{$field_name}[$lang][$key] = $value; $entity->{$field_name}[$lang][$key] = $value;
...@@ -256,7 +258,7 @@ function date_ical_feeds_set_rrule($source, $entity, $target, $feed_element) { ...@@ -256,7 +258,7 @@ function date_ical_feeds_set_rrule($source, $entity, $target, $feed_element) {
} }
/** /**
* Identify all potential fields that could populate the optional LOCATION component of iCal output. * Identify all potential fields which could be used as an iCal LOCATION.
*/ */
function date_ical_get_location_fields($base = 'node', $reset = FALSE) { function date_ical_get_location_fields($base = 'node', $reset = FALSE) {
static $fields = array(); static $fields = array();
...@@ -276,15 +278,15 @@ function date_ical_get_location_fields($base = 'node', $reset = FALSE) { ...@@ -276,15 +278,15 @@ function date_ical_get_location_fields($base = 'node', $reset = FALSE) {
} }
/** /**
* Identify all potential LOCATION fields. * Internal helper function for date_ical_get_location_fields().
* This is a cut down version of _date_views_fields() from date_views_fields.inc *
* in date_views module. * This is a cut down version of _date_views_fields() from
* date_views_fields.inc in date_views module.
*
* @return
* array with fieldname, type, and table.
* *
* @return * @see date_views_date_views_fields()
* array with fieldname, type, and table.
* @see
* date_views_date_views_fields(), which implements hook_date_views_fields()
* for the core date fields.
*/ */
function _date_ical_get_location_fields($base = 'node') { function _date_ical_get_location_fields($base = 'node') {
// Make sure $base is never empty. // Make sure $base is never empty.
...@@ -307,7 +309,14 @@ function _date_ical_get_location_fields($base = 'node') { ...@@ -307,7 +309,14 @@ function _date_ical_get_location_fields($base = 'node') {
// Skip unsupported field types and fields that weren't defined through // Skip unsupported field types and fields that weren't defined through
// the Field module. // the Field module.
$info = field_info_field($field_name); $info = field_info_field($field_name);
if (!$info || !in_array($info['type'], array('text', 'text_long', 'text_with_summary', 'node_reference', 'addressfield'))) { $supported_location_fields = array(
'text',
'text_long',
'text_with_summary',
'node_reference',
'addressfield',
);
if (!$info || !in_array($info['type'], $supported_location_fields)) {
continue; continue;
} }
...@@ -333,7 +342,7 @@ function _date_ical_get_location_fields($base = 'node') { ...@@ -333,7 +342,7 @@ function _date_ical_get_location_fields($base = 'node') {
/** /**
* Identify all potential fields that could populate the custom SUMMARY field * Identify all potential fields which could be used as an iCal SUMMARY.
*/ */
function date_ical_get_summary_fields($base = 'node', $reset = FALSE) { function date_ical_get_summary_fields($base = 'node', $reset = FALSE) {
static $fields = array(); static $fields = array();
...@@ -353,15 +362,15 @@ function date_ical_get_summary_fields($base = 'node', $reset = FALSE) { ...@@ -353,15 +362,15 @@ function date_ical_get_summary_fields($base = 'node', $reset = FALSE) {
} }
/** /**
* Identify all potential SUMMARY fields. * Internal helper function for date_ical_get_summary_fields().
* This is a cut down version of _date_views_fields() from date_views_fields.inc *
* in date_views module. * This is a cut down version of _date_views_fields() from
* date_views_fields.inc in date_views module.
*
* @return
* Array with fieldname, type, and table.
* *
* @return * @see date_views_date_views_fields()
* array with fieldname, type, and table.
* @see
* date_views_date_views_fields(), which implements hook_date_views_fields()
* for the core date fields.
*/ */
function _date_ical_get_summary_fields($base = 'node') { function _date_ical_get_summary_fields($base = 'node') {
// Make sure $base is never empty. // Make sure $base is never empty.
...@@ -384,7 +393,14 @@ function _date_ical_get_summary_fields($base = 'node') { ...@@ -384,7 +393,14 @@ function _date_ical_get_summary_fields($base = 'node') {
// Skip unsupported field types and fields that weren't defined through // Skip unsupported field types and fields that weren't defined through
// the Field module. // the Field module.
$info = field_info_field($field_name); $info = field_info_field($field_name);
if (!$info || !in_array($info['type'], array('text', 'text_long', 'text_with_summary', 'node_reference', 'taxonomy_term_reference'))) { $supported_summary_fields = array(
'text',
'text_long',
'text_with_summary',
'node_reference',
'taxonomy_term_reference',
);
if (!$info || !in_array($info['type'], $supported_summary_fields)) {
continue; continue;
} }
...@@ -407,3 +423,38 @@ function _date_ical_get_summary_fields($base = 'node') { ...@@ -407,3 +423,38 @@ function _date_ical_get_summary_fields($base = 'node') {
cache_set($cid, $fields, 'cache_views'); cache_set($cid, $fields, 'cache_views');
return $fields; return $fields;
} }
/**
* Convert 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 )
*/
function _date_ical_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) == 'UNTIL') {
// iCalcreator expects the 'timestamp' to be array key for UNTIL
$value['timestamp'] = strtotime($value['datetime']);
}
if (strtoupper($key) == 'BYDAY') {
$new_byday = array();
foreach ($value as $day) {
// Fortunately, the weekday values are always 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;
}
<?php <?php
/** /**
* @file * @file
* DateiCalFeedsParser is Date iCal's Feeds parser plugin. * DateiCalFeedsParser is Date iCal's Feeds parser plugin.
*/ */
class DateiCalFeedsParser extends FeedsParser { class DateiCalFeedsParser extends FeedsParser {
...@@ -44,7 +43,7 @@ class DateiCalFeedsParser extends FeedsParser { ...@@ -44,7 +43,7 @@ class DateiCalFeedsParser extends FeedsParser {
// We've got a vcalendar object created from the feed data. Now we need to // 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. // convert that vcalendar into an array of Feeds-compatible data arrays.
// ParserVcalendar->parse() does that. // ParserVcalendar->parse() does that.
require_once(DRUPAL_ROOT . '/' . drupal_get_path('module', 'date_ical') . '/libraries/ParserVcalendar.inc'); require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'date_ical') . '/libraries/ParserVcalendar.inc';
$parser = new ParserVcalendar($calendar, $source, $fetcher_result, $source->getConfigFor($this)); $parser = new ParserVcalendar($calendar, $source, $fetcher_result, $source->getConfigFor($this));
// Using the stored progress pointer (or 0 if it's not set), // Using the stored progress pointer (or 0 if it's not set),
...@@ -103,8 +102,6 @@ class DateiCalFeedsParser extends FeedsParser { ...@@ -103,8 +102,6 @@ class DateiCalFeedsParser extends FeedsParser {
/** /**
* Creates the list of mapping sources offered by DateiCalFeedsParser. * Creates the list of mapping sources offered by DateiCalFeedsParser.
*
* @return array
*/ */
public static function getiCalMappingSources() { public static function getiCalMappingSources() {
$sources = array(); $sources = array();
......
...@@ -6,25 +6,30 @@ ...@@ -6,25 +6,30 @@
*/ */
/** /**
* Plugin which creates a view on the resulting object * A Views plugin which builds an iCal VEVENT from a single node.
* and formats it as an iCal VEVENT.
*/ */
class date_ical_plugin_row_ical_entity extends views_plugin_row { class date_ical_plugin_row_ical_entity extends views_plugin_row {
// Basic properties that let the row style follow relationships. // Basic properties that let the row style follow relationships.
var $base_table = 'node'; protected $base_table = 'node';
var $base_field = 'nid'; protected $base_field = 'nid';
// Stores the nodes loaded with pre_render. // Stores the nodes loaded with pre_render.
var $entities = array(); protected $entities = array();
function init(&$view, &$display, $options = NULL) { /**
* Initialize the row plugin.
*/
public function init(&$view, &$display, $options = NULL) {
parent::init($view, $display, $options); parent::init($view, $display, $options);
$this->base_table = $view->base_table; $this->base_table = $view->base_table;
$this->base_field = $view->base_field; $this->base_field = $view->base_field;
} }
function option_definition() { /**
* Set up the options for the row plugin.
*/
public function option_definition() {
$options = parent::option_definition(); $options = parent::option_definition();
$options['date_field'] = array('default' => array()); $options['date_field'] = array('default' => array());
$options['summary_field'] = array('default' => array()); $options['summary_field'] = array('default' => array());
...@@ -33,17 +38,18 @@ class date_ical_plugin_row_ical_entity extends views_plugin_row { ...@@ -33,17 +38,18 @@ class date_ical_plugin_row_ical_entity extends views_plugin_row {
} }
/** /**
* Provide a form for setting options. * Build the form for setting the row plugin's options.
*/ */
function options_form(&$form, &$form_state) { public function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state); parent::options_form($form, $form_state);
// Build the select dropdown for the date field that the user wants to use // Build the select dropdown for the Date field that the user wants to use
// to populate the date fields in VEVENTs. // to populate the date properties in VEVENTs.
$data = date_views_fields($this->base_table); $data = date_views_fields($this->base_table);
$options = array(); $options = array();