You are here

function _views_summarize_get_formatted_summary in Views Summarize 1.1.x

Same name and namespace in other branches
  1. 7.2 views_summarize.module \_views_summarize_get_formatted_summary()
  2. 7 views_summarize.module \_views_summarize_get_formatted_summary()

Gets the summary's formatted result.

Parameters

type $total: The summary to format.

type $options: The options element of the variables array that is passed into the summary theme function.

Return value

array The format settings in an associative array.

4 calls to _views_summarize_get_formatted_summary()
views_summarize_type_average in ./views_summarize.module
Creates the markup for the total value for an average column.
views_summarize_type_average_no_empties in ./views_summarize.module
Creates the markup for the total value for an average column.
views_summarize_type_currency in ./views_summarize.module
Creates the markup for the total value for a currency amount.
views_summarize_type_total in ./views_summarize.module
Creates the markup for the total value for a numeric column.

File

./views_summarize.module, line 442
Defines the functionality and Drupal hooks for this module.

Code

function _views_summarize_get_formatted_summary($total, $options) {
  $format_settings = [
    'scale' => 0,
    'decimal_separator' => NULL,
    'thousand_separator' => NULL,
  ];
  if (!empty($options['views_field_settings']['scale'])) {
    $format_settings['scale'] = $options['views_field_settings']['scale'];
  }
  if (!empty($options['views_field_settings']['decimal_separator'])) {
    $format_settings['decimal_separator'] = $options['views_field_settings']['decimal_separator'];
  }
  if (!empty($options['views_field_settings']['thousand_separator'])) {
    $format_settings['thousand_separator'] = $options['views_field_settings']['thousand_separator'];
  }
  $summary = number_format($total, $format_settings['scale'], $format_settings['decimal_separator'], $format_settings['thousand_separator']);
  return $summary;
}