function format_number_get_options in Format Number API 7
Same name and namespace in other branches
- 6 format_number.module \format_number_get_options()
Get the site/user defined thousands separator and decimal point characters.
Parameters
string $name: The name of the option to retrieve (optional). Available options:
- 'thousands_sep' A one character string (it could be empty).
- 'decimal_point' A one character string.
Return value
mixed If name is not specified, an array with all options is returned. If name does not exist, NULL is returned. If name exists, its value is returned.
4 calls to format_number_get_options()
- format_number in ./
format_number.module - Format a number with (site default or user defined) thousands separator and decimal point.
- format_number_add_js in ./
format_number.module - Expose a javascript version of the Format Number API.
- format_number_numericfield_process in ./
format_number.module - Process an individual numeric form element.
- parse_formatted_number in ./
format_number.module - Parse a formatted number.
File
- ./
format_number.module, line 130 - This module provides a method to configure number formats (site default and user defined) with configurable decimal point and thousand separators. It also exposes several functions that can be used by other contributed or custom modules to display…
Code
function format_number_get_options($name = NULL) {
static $format_options;
global $user;
if (!isset($format_options)) {
$format_options = array(
'thousands_sep' => variable_get('format_number_thousands_sep', ','),
'decimal_point' => variable_get('format_number_decimal_point', '.'),
);
if (variable_get('format_number_user_configurable', 0) && $user->uid) {
if (isset($user->data['thousands_sep']) && drupal_strlen($user->data['thousands_sep'])) {
$format_options['thousands_sep'] = $user->data['thousands_sep'];
}
if (isset($user->data['decimal_point']) && drupal_strlen($user->data['decimal_point'])) {
$format_options['decimal_point'] = $user->data['decimal_point'];
}
}
}
if (isset($name)) {
return isset($format_options[$name]) ? $format_options[$name] : NULL;
}
return $format_options;
}