You are here

public function date_ical_plugin_row_ical_entity::pre_render in Date iCal 7.3

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

Preload the list of entities which will appear in the view.

TODO: When the date is coming in through a relationship, the nid of the view is not the right node to use: we need the related node. Need to sort out how that should be handled.

Overrides views_plugin_row::pre_render

File

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

Class

date_ical_plugin_row_ical_entity
A Views plugin which builds an iCal VEVENT from a single node.

Code

public function pre_render($values) {

  // 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 create only 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];
  }
}