function views_handler_field::advanced_render

Same name in other branches
  1. 7.x-3.x handlers/views_handler_field.inc \views_handler_field::advanced_render()

Render a field using advanced settings.

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

File

handlers/views_handler_field.inc, line 803

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);
    }
    else {
        $this->last_render = $value = $this->render($values);
        $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) {
                $this->last_render = $this->render_item($count, $item);
                $this->original_value = $this->last_render;
                $alter = $item + $this->options['alter'];
                $items[] = $this->render_text($alter);
            }
            $value = $this->render_items($items);
        }
        else {
            $value = $this->render_text($this->options['alter']);
        }
        // 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->last_render !== 0 && $this->last_render !== '0' || !empty($this->options['empty_zero'])) {
            $alter = $this->options['alter'];
            $alter['alter_text'] = 1;
            $alter['text'] = $this->options['empty'];
            $this->last_render = $this->render_text($alter);
        }
    }
    return $this->last_render;
}