You are here

function theme_mvf_field in Measured Value Field 6

Display an value and unit with the given display options.

Parameters

$value: "From" value (raw or formatted).

$value2: "To" value (raw or formatted).

$unit: Id of the unit.

$display_options: The string that provides display options as configured in widget settings.

$separator: The character used as a separator when specified by '+' in display options. Defaults to non-breaking space.

$range_separator: The character used as a range separator when specified by '-' in display options. Defaults to hyphen surrounded by non-breaking spaces.

2 theme calls to theme_mvf_field()
theme_mvf_formatter_generic in ./mvf.module
Display a MVF field (formatted).
theme_mvf_formatter_unformatted in ./mvf.module
Display a MVF field (unformatted).

File

./mvf.module, line 758
Measured Value Field module.

Code

function theme_mvf_field($value, $value2, $unit, $display_options, $separator = " ", $range_separator = " - ") {
  $output = '';
  foreach (explode('|', $display_options) as $option) {
    switch ($option) {
      case 'f':

        // "From" value.
        $output .= $value;
        break;
      case 't':

        // "To" value.
        $output .= $value2;
        break;
      case 's':

        // Unit symbol.
        $unit_symbol = units_get_symbol($unit);
        if (!empty($unit_symbol)) {
          $output .= $unit_symbol;
          break;
        }

      // Fall back to unit short name.
      case 'u':

        // Unit short name.
        $units = units_get_units();
        $unitname = $units[$unit]['shortname'];
        $output .= $unitname;
        break;
      case '+':

        // Separator.
        $output .= $separator;
        break;
      case '-':

        // Range Separator.
        $output .= $range_separator;
        break;
    }
  }
  return $output;
}