class weight_handler_field_sticky in Weight 6
Same name and namespace in other branches
- 7 weight_handler_field_sticky.inc \weight_handler_field_sticky
@file Field handler for Weight module.
Hierarchy
- class \weight_handler_field_sticky extends \views_handler_field_numeric
Expanded class hierarchy of weight_handler_field_sticky
1 string reference to 'weight_handler_field_sticky'
- weight_views_data in views/
weight.views.inc - Implementation of hook_views_data().
File
- views/
weight_handler_field_sticky.inc, line 7 - Field handler for Weight module.
View source
class weight_handler_field_sticky extends views_handler_field_numeric {
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']);
}
}