You are here

function uc_addresses_country_formats_page in Ubercart Addresses 6.2

Same name and namespace in other branches
  1. 7 uc_addresses.admin.inc \uc_addresses_country_formats_page()

Lists all enabled countries were address formats may be set for.

Parameters

int $country_id: (optional) The country to set the address format for. If specified, a different form will be loaded.

Return value

string | array A list of countries, themed in a table. Or a form array if a country ID is specified.

See also

uc_addresses_country_formats_form()

1 string reference to 'uc_addresses_country_formats_page'
uc_addresses_menu in ./uc_addresses.module
Implementation of hook_menu().

File

./uc_addresses.admin.inc, line 153
Admin settings for Ubercart Addresses.

Code

function uc_addresses_country_formats_page($country_id = NULL) {
  if ($country_id) {

    // Return address display form for this country.
    return drupal_get_form('uc_addresses_country_formats_form', $country_id);
  }

  // List all countries.
  $header = array(
    t('Country'),
    t('Status'),
  );
  $rows = array();
  $path = 'admin/store/settings/countries/edit/uc_addresses_formats';
  $countries = array();
  $result = db_query("SELECT country_id, country_name FROM {uc_countries}");
  while ($country = db_fetch_object($result)) {
    $countries[t($country->country_name)] = $country;
  }

  // Sort countries in natural order.
  uksort($countries, 'strnatcasecmp');
  foreach ($countries as $country) {
    $rows[] = array(
      l(t($country->country_name), $path . '/' . $country->country_id),
      variable_get('uc_addresses_address_format_' . $country->country_id, NULL) ? t('Overridden') : t('Ubercart default'),
    );
  }
  return theme('table', $header, $rows);
}