You are here

function date_ical_plugin_row_ical_entity::pre_render in Date iCal 7.2

Same name and namespace in other branches
  1. 7.3 includes/date_ical_plugin_row_ical_entity.inc \date_ical_plugin_row_ical_entity::pre_render()

Allow the style to do stuff before each row is rendered.

Parameters

array $result: The full array of results from the query.

Overrides views_plugin_row::pre_render

File

includes/date_ical_plugin_row_ical_entity.inc, line 104
Contains the iCal row style plugin.

Class

date_ical_plugin_row_ical_entity
Plugin which creates a view on the resulting object and formats it as an iCal VEVENT.

Code

function pre_render($values) {

  // @TODO When the date is coming in through a relationship, the nid
  // of the view is not the right node to use, then we need the related node.
  // Need to sort out how that should be handled.
  // Preload each entity used in this view from the cache.
  // Provides all the entity values relatively cheaply, and we don't
  // need to do it repeatedly for the same entity if there are
  // multiple results for one entity.
  $ids = array();
  foreach ($values as $row) {

    // Use the $id as the key so we don't create more than one value per entity.
    $id = $row->{$this->field_alias};

    // Node revisions need special loading.
    if ($this->view->base_table == 'node_revision') {
      $this->entities[$id] = node_load(NULL, $id);
    }
    else {
      $ids[$id] = $id;
    }
  }
  $base_tables = date_views_base_tables();
  $this->entity_type = $base_tables[$this->view->base_table];
  if (!empty($ids)) {
    $this->entities = entity_load($this->entity_type, $ids);
  }

  // Get the language for this view.
  $this->language = $this->display->handler
    ->get_option('field_language');
  $substitutions = views_views_query_substitutions($this->view);
  if (array_key_exists($this->language, $substitutions)) {
    $this->language = $substitutions[$this->language];
  }
}