You are here

function weight_handler_field_sticky::render in Weight 6

Same name and namespace in other branches
  1. 7 weight_handler_field_sticky.inc \weight_handler_field_sticky::render()

File

views/weight_handler_field_sticky.inc, line 8
Field handler for Weight module.

Class

weight_handler_field_sticky
@file Field handler for Weight module.

Code

function render($values) {
  $value = $values->{$this->field_alias};

  // convert sticky values to corresponding weights.
  if ($value > 0) {
    $value = $value == 1 ? 0 : 100 - $value;
  }
  else {
    $value = $value == 0 ? 0 : -($value + 100);
  }
  if (!empty($this->options['set_precision'])) {
    $value = number_format($value, $this->options['precision'], $this->options['decimal'], $this->options['separator']);
  }
  else {
    $remainder = abs($value) - intval(abs($value));
    $value = number_format($value, 0, '', $this->options['separator']);
    if ($remainder) {
      $value .= $this->options['decimal'] . $remainder;
    }
  }
  return check_plain($this->options['prefix'] . $value . $this->options['suffix']);
}