function uc_country_import_form in Ubercart 6.2
Same name and namespace in other branches
- 5 uc_store/uc_store.module \uc_country_import_form()
- 7.3 uc_store/uc_store.countries.inc \uc_country_import_form()
Import 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.admin.inc, line 367 - Store administration menu items.
Code
function uc_country_import_form() {
$result = db_query("SELECT * FROM {uc_countries}");
while ($country = db_fetch_object($result)) {
$countries[t($country->country_name)] = $country;
}
uksort($countries, 'strnatcasecmp');
$files = _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 (is_array($import_list)) {
ksort($import_list);
}
if (is_array($import_list)) {
$options = $import_list;
}
else {
$options = array(
t('-None available-'),
);
}
$form['country_import'] = array(
'#title' => t('Country importer'),
'#type' => 'fieldset',
'#collapsed' => FALSE,
'#collapsible' => FALSE,
'#summary callback' => '_uc_country_summarize',
);
$form['country_import']['text'] = array(
'#value' => '<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' => $options,
'#disabled' => !is_array($import_list),
'#multiple' => is_array($import_list),
'#size' => min(10, count($options)),
);
$form['country_import']['import_button'] = array(
'#type' => 'submit',
'#value' => t('Import'),
'#disabled' => !is_array($import_list),
);
$form['country_table'] = array(
'#value' => theme('table', $header, $rows),
);
return $form;
}