You are here

function views_calc_field_handler::render in Views Calc 7

Same name and namespace in other branches
  1. 6.3 views_calc_field_handler.inc \views_calc_field_handler::render()
  2. 6 views_calc_field_handler.inc \views_calc_field_handler::render()

Use the requested format function to render the raw alias value.

Overrides views_handler_field::render

File

./views_calc_field_handler.inc, line 78
Copied from the basic 'node' field handler.

Class

views_calc_field_handler
Field handler to provide simple renderer that allows linking to a node.

Code

function render($values) {
  $field_alias = "cid{$this->definition['cid']}";
  $value = $values->{$field_alias};
  $formats = _views_calc_format_options();
  $format = $formats[$this->definition['format']];
  $tmp = explode(':', $format);
  $function = trim($tmp[0]);
  $vars = count($tmp) == 2 ? $tmp[1] : '';
  if ($function == 'custom') {
    $tmp = explode(':', $this->definition['custom']);
    $function = trim($tmp[0]);
    $vars = count($tmp) == 2 ? $tmp[1] : '';
  }
  if (empty($function) || $function == 'none') {
    $function = 'check_plain';
  }
  $raw = $function($value, $vars);

  // This needs to be set for the $this->render_link() to work. It would
  // have been set in the query, if we hadn't bypassed the normal query.
  // TODO there may be a better way to do this.
  $this->aliases['nid'] = 'nid';
  return $this
    ->render_link($raw, $values);
}