You are here

function theme_money_conversion_dialog in Money field 6

Display a CCK Money field with currency conversion dialog.

Appends a "Click here to convert!" icon to formatted money fields. When the user clicks on the icon, a jQuery UI dialog pops up with a small form that uses Ajax to provide online currency converions using the Currency API.

1 string reference to 'theme_money_conversion_dialog'
money_conversion_dialog_theme in modules/money_conversion_dialog/money_conversion_dialog.module
Implementation of hook_theme().

File

modules/money_conversion_dialog/money_conversion_dialog.module, line 134
Provides a 'Click to convert!' addon for Money CCK fields.

Code

function theme_money_conversion_dialog($element) {

  // Use the default money formatter.
  $output = theme('money_formatter_default', $element);
  if (empty($output)) {
    return $output;
  }

  // Check user permission to use money conversion dialog.
  if (!user_access('use money conversion dialog')) {
    return $output;
  }

  // Add javascript/stylesheet components.
  money_conversion_dialog_add_js();

  // Prepare field settings. See money_conversion_dialog_ajax_callback()
  $field = content_fields($element['#field_name'], $element['#type_name']);
  $settings = implode('|', array(
    $element['#item']['amount'],
    isset($field['decimals']) ? (int) $field['decimals'] : 0,
    str_replace('|', ':', $field['widget']['currency_display_mode']),
    $element['#item']['currency'],
  ));
  return '<span class="money-item [' . $settings . ']">' . $output . '</span>';
}