You are here

function term_reference_plugin_style::render in Taxonomy Term Reference Filter by Views 7.2

Render the display in this style.

Overrides views_plugin_style::render

File

views/term_reference_plugin_style.inc, line 36
Handler for entityreference_plugin_style.

Class

term_reference_plugin_style
@file Handler for entityreference_plugin_style.

Code

function render() {
  $options = $this->display->handler
    ->get_option('term_reference_options');

  // Play nice with Views UI 'preview' : if the view is not executed through
  // EntityReference_SelectionHandler_Views::getReferencableEntities(), just
  // display the HTML.
  if (empty($options)) {
    return parent::render();
  }

  // Group the rows according to the grouping field, if specified.
  $sets = $this
    ->render_grouping($this->view->result, $this->options['grouping']);

  // Grab the alias of the 'id' field added by entityreference_plugin_display.
  $id_field_alias = $this->display->handler->id_field_alias;

  // @todo We don't display grouping info for now. Could be useful for select
  // widget, though.
  $results = array();
  $this->view->row_index = 0;
  foreach ($sets as $records) {
    foreach ($records as $values) {

      // Sanitize html, remove line breaks and extra whitespace.
      $results[$values->{$id_field_alias}] = filter_xss_admin(preg_replace('/\\s\\s+/', ' ', str_replace("\n", '', $this->row_plugin
        ->render($values))));
      $this->view->row_index++;
    }
  }
  unset($this->view->row_index);
  return $results;
}