/[drupal]/contributions/modules/weight/weight_handler_field_sticky.inc
ViewVC logotype

Contents of /contributions/modules/weight/weight_handler_field_sticky.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Thu Nov 13 18:35:39 2008 UTC (12 months, 1 week ago) by nancyw
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
Changes since 1.1: +13 -8 lines
File MIME type: text/x-php
Fix Coder finds
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 }

  ViewVC Help
Powered by ViewVC 1.1.2