You are here

function currency_currency_exchanger_fixed_rates_overview in Currency 7.2

Displays CurrencyExchangerFixedRates' exchange rate overview.

Return value

string

1 string reference to 'currency_currency_exchanger_fixed_rates_overview'
currency_menu in currency/currency.module
Implements hook_menu().

File

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

Code

function currency_currency_exchanger_fixed_rates_overview() {
  $header = array(
    t('From'),
    t('To'),
    t('Conversion rate'),
    t('Operations'),
  );
  $rows = array();
  $rates = CurrencyExchangerFixedRates::loadAll();
  foreach ($rates as $currency_code_from => $currency_codes_to) {
    $currency_from = currency_load($currency_code_from);
    foreach ($currency_codes_to as $currency_code_to => $rate) {
      $currency_to = currency_load($currency_code_to);
      $operations = theme('links', array(
        'links' => array(
          array(
            'title' => t('edit'),
            'href' => 'admin/config/regional/currency-exchange/fixed/' . $currency_code_from . '/' . $currency_code_to,
          ),
        ),
        'attributes' => array(
          'class' => array(
            'links',
            'inline',
            'operations',
          ),
        ),
      ));
      $rows[] = array(
        check_plain($currency_from
          ->translateTitle()),
        check_plain($currency_to
          ->translateTitle()),
        $currency_to
          ->format($rate),
        $operations,
      );
    }
  }
  if (!$rows) {
    $rows[] = array(
      array(
        'data' => t('There are no exchange rates yet. <a href="@path">Add an exchange rate</a>.', array(
          '@path' => url('admin/config/regional/currency-exchange/fixed/add'),
        )),
        'colspan' => 4,
      ),
    );
  }
  return theme('table', array(
    'header' => $header,
    'rows' => $rows,
  ));
}