-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathamount.api.php
More file actions
75 lines (72 loc) · 2.11 KB
/
Copy pathamount.api.php
File metadata and controls
75 lines (72 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/**
* @defgroup amount_api_hooks Amount API Hooks
* @{
* Functions to modify or add groups of units definitions to the allowed set of
* units.
*
* There is one hook provided which allows external modules to modify the list
* of allowed units:
* - hook_amount_mapping_alter()
* @}
*/
/**
* @addtogroup amount_api_hooks
* @{
*/
/**
* Alter the mappings used to create the master list of units codes.
*
* This hook is used to add or change mapping groups which are used to generate
* the master list of units codes available.
*
* This hook is invoked when the list of available units codes is requested.
*
* @param &$mapping
* The $mapping associative array is passed by reference and can be modified.
*
* Amount defines a single group of units, and then uses its own mapping alter
* hook to define more -- as an example.
*
* New units mappings are added to the mapping associative array or existing
* elements can be altered (though this is not recommended).
*
* Mappings are defined within groups (type) pointing to arrays of allowed
* codes.
*
* Each code points to an array of the symbol associated with the code and
* an array of allowed multipliers.
*
**/
function amount_amount_mapping_alter( &$mapping ) {
$mappingstoadd = array(
'CUR' => array(
'USD' => array('$' => array()),
'GBP' => array('£' => array()),
'EUR' => array('€' => array()),
'AUD' => array('$' => array())
),
'LEN' => array(
'SI' => array('m' => array('k', '', 'c', 'm', 'u', 'n')),
'in' => array('"' => array()),
'ft' => array("'" => array()),
'mi' => array('mi' => array())
),
'MAS' => array(
'lb' => array('#' => array()),
'SI' => array('g' => array('M', 'k', '', 'm'))
),
'VOL' => array(
'SI' => array('l' => array('k', '', 'm')),
'GAL' => array('gal' => array())
),
'CMP' => array(
'BYT' => array('B' => array('', 'K', 'M', 'G', 'T', 'P')),
'XFR' => array('bps' => array('', 'K', 'M'))
),
'TIM' => array(
'sec' => array('s' => array('', 'm'))
),
);
$mapping += $mappingstoadd;
}