1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Administrative callbacks for the Commerce UI module.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
/**
|
10 |
|
|
* Builds the currency settings form.
|
11 |
|
|
*/
|
12 |
|
|
function commerce_currency_settings_form($form, &$form_state) {
|
13 |
|
|
// Build a currency options list from all defined currencies.
|
14 |
|
|
$options = array();
|
15 |
|
|
|
16 |
|
|
foreach (commerce_currencies(FALSE, TRUE) as $currency_code => $currency) {
|
17 |
|
|
$options[$currency_code] = t('@code - !name', array('@code' => $currency['code'], '@symbol' => $currency['symbol'], '!name' => $currency['name']));
|
18 |
|
|
|
19 |
|
|
if (!empty($currency['symbol'])) {
|
20 |
|
|
$options[$currency_code] .= ' - ' . check_plain($currency['symbol']);
|
21 |
|
|
}
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
$form['commerce_default_currency'] = array(
|
25 |
|
|
'#type' => 'select',
|
26 |
|
|
'#title' => t('Default store currency'),
|
27 |
|
|
'#description' => t('The default store currency will be used as the default for all price fields.'),
|
28 |
|
|
'#options' => $options,
|
29 |
|
|
'#default_value' => commerce_default_currency(),
|
30 |
|
|
);
|
31 |
|
|
|
32 |
|
|
// Place the enabled currencies checkboxes in a fieldset so the full list
|
33 |
|
|
// doesn't spam the administrator when viewing the page.
|
34 |
|
|
$form['enabled_currencies'] = array(
|
35 |
|
|
'#type' => 'fieldset',
|
36 |
|
|
'#title' => t('Enabled currencies'),
|
37 |
|
|
'#description' => t('Only enabled currencies will be visible to users when entering prices. The default currency will always be enabled.'),
|
38 |
|
|
'#collapsible' => TRUE,
|
39 |
|
|
'#collapsed' => TRUE,
|
40 |
|
|
);
|
41 |
|
|
|
42 |
|
|
$form['enabled_currencies']['commerce_enabled_currencies'] = array(
|
43 |
|
|
'#type' => 'checkboxes',
|
44 |
|
|
'#options' => $options,
|
45 |
|
|
'#default_value' => variable_get('commerce_enabled_currencies', array('USD' => 'USD')),
|
46 |
|
|
);
|
47 |
|
|
|
48 |
|
|
$form['#validate'][] = 'commerce_currency_settings_form_validate';
|
49 |
|
|
|
50 |
|
|
return system_settings_form($form);
|
51 |
|
|
}
|
52 |
|
|
|
53 |
|
|
/**
|
54 |
|
|
* Form validate handler for the currency settings form.
|
55 |
|
|
*/
|
56 |
|
|
function commerce_currency_settings_form_validate($form, &$form_state) {
|
57 |
|
|
// Ensure the default currency is always enabled.
|
58 |
|
|
$default = $form_state['values']['commerce_default_currency'];
|
59 |
|
|
$form_state['values']['commerce_enabled_currencies'][$default] = $default;
|
60 |
|
|
} |