You are here

function views_php_handler_field::render in Views PHP 6

Same name and namespace in other branches
  1. 7.2 plugins/views/views_php_handler_field.inc \views_php_handler_field::render()
  2. 7 plugins/views/views_php_handler_field.inc \views_php_handler_field::render()

Implements views_handler_field#render().

File

plugins/views/views_php_handler_field.inc, line 230

Class

views_php_handler_field
A handler to provide a field that is constructed by the administrator using PHP.

Code

function render($values) {

  // Ecexute output PHP code.
  if (!empty($this->options['php_output']) && isset($this->php_output_lambda_function)) {
    $normalized_row = new stdClass();
    foreach ($this->view->display_handler
      ->get_handlers('field') as $field => $handler) {
      $normalized_row->{$field} = isset($values->{$handler->field_alias}) ? $values->{$handler->field_alias} : NULL;
    }

    // Add base field if found.
    if (!empty($this->view->base_field) && isset($row->{$this->view->base_field})) {
      $normalized_row->{$this->view->base_field} = $row->{$this->view->base_field};
    }
    $function = $this->php_output_lambda_function;
    ob_start();
    $function($this->view, $this, $this->php_static_variable, $normalized_row, $values, isset($values->{$this->field_alias}) ? $values->{$this->field_alias} : NULL);
    $value = ob_get_clean();
  }
  else {
    $value = check_plain($values->{$this->field_alias});
  }
  return $value;
}