You are here

function uc_addresses_country_formats_page in Ubercart Addresses 7

Same name and namespace in other branches
  1. 6.2 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
Implements hook_menu().

File

./uc_addresses.admin.inc, line 98
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/uc_addresses_formats';
  $countries = array();
  $result = db_query("SELECT country_id, country_name FROM {uc_countries}");
  foreach ($result as $country) {
    $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', array(
    'header' => $header,
    'rows' => $rows,
  ));
}