1 views_handler_field.inc views_handler_field::advanced_render($values)

Render a field using advanced settings.

This renders a field normally, then decides if render-as-link and text-replacement rendering is necessary.

File

core/modules/views/handlers/views_handler_field.inc, line 1083
@todo.

Class

views_handler_field
Base field handler that has no options and renders an unformatted field.

Code

function advanced_render($values) {
  if ($this->allow_advanced_render() && method_exists($this, 'render_item')) {
    $raw_items = $this->get_items($values);
    // If there are no items, set the original value to NULL.
    if (empty($raw_items)) {
      $this->original_value = NULL;
    }
  }
  else {
    $value = $this->render($values);
    if (is_array($value)) {
      $value = backdrop_render($value);
    }
    $this->last_render = $value;
    $this->original_value = $value;
  }

  if ($this->allow_advanced_render()) {
    $tokens = NULL;
    if (method_exists($this, 'render_item')) {
      $items = array();
      foreach ($raw_items as $count => $item) {
        $value = $this->render_item($count, $item);
        if (is_array($value)) {
          $value = backdrop_render($value);
        }
        $this->last_render = $value;
        $this->original_value = $this->last_render;

        $alter = $item + $this->options['alter'];
        $alter['phase'] = VIEWS_HANDLER_RENDER_TEXT_PHASE_SINGLE_ITEM;
        $items[] = $this->render_text($alter);
      }

      $value = $this->render_items($items);
    }
    else {
      $alter = array('phase' => VIEWS_HANDLER_RENDER_TEXT_PHASE_COMPLETELY) + $this->options['alter'];
      $value = $this->render_text($alter);
    }

    if (is_array($value)) {
      $value = backdrop_render($value);
    }
    // This happens here so that render_as_link can get the unaltered value of
    // this field as a token rather than the altered value.
    $this->last_render = $value;
  }

  if (empty($this->last_render)) {
    if ($this->is_value_empty($this->last_render, $this->options['empty_zero'], FALSE)) {
      $alter = $this->options['alter'];
      $alter['alter_text'] = 1;
      $alter['text'] = $this->options['empty'];
      $alter['phase'] = VIEWS_HANDLER_RENDER_TEXT_PHASE_EMPTY;
      $this->last_render = $this->render_text($alter);
    }
  }

  return $this->last_render;
}