Commit 87b8fd44 authored by Robert Rollins's avatar Robert Rollins

Added hook_date_ical_html_alter()

parent fe4415f8
<?php
/**
* Alter the HTML of an event's Summary and Description, before it gets converted
* to plaintext for output in an iCal feed.
*
* @param $data
* A reference to an associative array with the following keys and values:
* - 'description': The rendered HTML of the iCal view mode of the entity.
* - 'summary': The title of the entity.
* @param $view
* The view object that is being executed to render the iCal feed.
* @param $context
* An associative array of context, with the following keys and values:
* - 'entity_type': The type of entity being rendered, 'node', 'user' etc.
* - 'entity': The fully loaded entity being rendered.
* - 'language': The language code that indicates which translation of field
* data should be used.
*/
function hook_date_ical_html_alter(&$data, $view, &$context) {
}
/**
* Modify a structured event before it is rendered to iCal format.
*
......@@ -19,7 +40,6 @@
* - 'entity': The fully loaded entity being rendered.
* - 'language': The language code that indicates which translation of field
* data should be used.
*
*/
function hook_date_ical_feed_event_render_alter(&$event, $view, &$context) {
// Simple example adding the location to a rendered event from a simple
......
......@@ -233,11 +233,24 @@ class date_ical_plugin_row_ical_entity extends views_plugin_row {
// Create the rendered display using the display settings from the 'iCal' view mode.
$rendered_array = entity_view($this->entity_type, array($entity), 'ical', $this->language, TRUE);
$item_text = drupal_render($rendered_array);
$data = array(
'description' => drupal_render($rendered_array),
'summary' => entity_label($this->entity_type, $entity)
);
// Allow other modules to alter the HTML of the Summary and Description,
// before it gets converted to iCal-compliant plaintext. This allows users
// to set up a newline between fields, for instance.
$context = array(
'entity' => $entity,
'entity_type' => $this->entity_type,
'language' => $this->language,
);
drupal_alter('date_ical_html', $data, $this->view, $context);
$event = array();
$event['summary'] = trim(drupal_html_to_text(entity_label($this->entity_type, $entity)));
$event['description'] = trim(drupal_html_to_text($item_text));
$event['summary'] = trim(drupal_html_to_text($data['summary']));
$event['description'] = trim(drupal_html_to_text($data['description']));
$event['all_day'] = $all_day;
$event['start'] = $start;
$event['end'] = $end;
......@@ -256,11 +269,6 @@ class date_ical_plugin_row_ical_entity extends views_plugin_row {
$event['last-modified'] = new DateObject($entity->changed, new DateTimeZone('UTC'));
// Allow other modules to alter the structured event object, before it gets converted to an iCal VEVENT.
$context = array(
'entity' => $entity,
'entity_type' => $this->entity_type,
'language' => $this->language,
);
drupal_alter('date_ical_feed_event_render', $event, $this->view, $context);
return $event;
......
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