function uc_country_import_form in Ubercart 7.3
Same name and namespace in other branches
- 5 uc_store/uc_store.module \uc_country_import_form()
- 6.2 uc_store/uc_store.admin.inc \uc_country_import_form()
Imports settings from a country file.
See also
uc_country_import_form_submit()
1 string reference to 'uc_country_import_form'
- uc_store_menu in uc_store/
uc_store.module - Implements hook_menu().
File
- uc_store/
uc_store.countries.inc, line 14 - Store administration forms for country and address handling.
Code
function uc_country_import_form($form, &$form_state) {
$countries = array();
$result = db_query("SELECT * FROM {uc_countries}");
foreach ($result as $country) {
$countries[t($country->country_name)] = $country;
}
uksort($countries, 'strnatcasecmp');
$files = _uc_country_import_list();
$header = array(
t('Country'),
t('Code'),
t('Version'),
t('Operations'),
);
$rows = array();
if (is_array($countries)) {
$link_ops = array(
'query' => array(
'token' => drupal_get_token('uc_country_op_link'),
),
);
foreach ($countries as $country) {
$row = array(
t($country->country_name),
$country->country_iso_code_3,
array(
'data' => abs($country->version),
'align' => 'center',
),
);
$ops = array();
if ($country->version < 0) {
$ops[] = l(t('enable'), 'admin/store/settings/countries/' . $country->country_id . '/enable', $link_ops);
}
else {
$ops[] = l(t('disable'), 'admin/store/settings/countries/' . $country->country_id . '/disable', $link_ops);
}
if ($country->version < $files[$country->country_id]['version'] && $country->version > 0) {
$ops[] = l(t('update'), 'admin/store/settings/countries/' . $country->country_id . '/update/' . $files[$country->country_id]['version'], $link_ops);
}
$ops[] = l(t('remove'), 'admin/store/settings/countries/' . $country->country_id . '/remove');
$row[] = implode(' ', $ops);
$rows[] = $row;
unset($files[$country->country_id]);
}
}
$import_list = array();
foreach ($files as $file) {
$import_list[$file['file']] = $file['file'];
}
if (!empty($import_list)) {
ksort($import_list);
$form['country_import'] = array(
'#title' => t('Import countries'),
'#type' => 'fieldset',
'#collapsed' => TRUE,
'#collapsible' => TRUE,
);
$form['country_import']['text'] = array(
'#markup' => '<p>' . t('To import new country data, select it in the list and click the import button. If you are using a custom or contributed import file, it must be placed in the Ubercart folder uc_store/countries.') . '</p>',
);
$form['country_import']['import_file'] = array(
'#type' => 'select',
'#title' => t('Country'),
'#options' => $import_list,
'#multiple' => TRUE,
'#size' => min(10, count($import_list)),
);
$form['country_import']['actions'] = array(
'#type' => 'actions',
);
$form['country_import']['actions']['import_button'] = array(
'#type' => 'submit',
'#value' => t('Import'),
);
}
$form['country_table'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
);
return $form;
}