| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
/**
|
| 4 |
* @file
|
| 5 |
* Field handler for Weight module.
|
| 6 |
*/
|
| 7 |
|
| 8 |
class weight_handler_field_sticky extends views_handler_field_numeric {
|
| 9 |
function render($values) {
|
| 10 |
$value = $values->{$this->field_alias};
|
| 11 |
// convert sticky values to corresponding weights.
|
| 12 |
if ($value > 0) {
|
| 13 |
$value = $value == 1 ? 0 : (100 - $value);
|
| 14 |
}
|
| 15 |
else {
|
| 16 |
$value = $value == 0 ? 0 : -($value + 100);
|
| 17 |
}
|
| 18 |
if (!empty($this->options['set_precision'])) {
|
| 19 |
$value = number_format($value, $this->options['precision'], $this->options['decimal'], $this->options['separator']);
|
| 20 |
}
|
| 21 |
else {
|
| 22 |
$remainder = abs($value) - intval(abs($value));
|
| 23 |
$value = number_format($value, 0, '', $this->options['separator']);
|
| 24 |
if ($remainder) {
|
| 25 |
$value .= $this->options['decimal'] . $remainder;
|
| 26 |
}
|
| 27 |
}
|
| 28 |
return check_plain($this->options['prefix'] . $value . $this->options['suffix']);
|
| 29 |
}
|
| 30 |
}
|