You are here

function _currency_filter_currency_localize_process in Currency 7.2

Implements preg_replace_callback() callback.

1 string reference to '_currency_filter_currency_localize_process'
currency_filter_currency_localize_process in currency/currency.module
Implements hook_filter_info()'s process callback.

File

currency/currency.module, line 653
Provides currency information and allows users to add custom currencies.

Code

function _currency_filter_currency_localize_process(array $matches) {
  $currency_code = $matches[1];
  try {
    $amount = Input::parseAmount($matches[2]);
  } catch (Exception $e) {
    return $matches[0];
  }
  ctools_include('export');
  $currency = currency_load($currency_code);
  if ($currency) {
    return $currency
      ->format($amount);
  }

  // The currency code is invalid, so return the token.
  return $matches[0];
}