-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlm_paypal.theme
57 lines (52 loc) · 1.59 KB
/
lm_paypal.theme
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
<?php
/**
* Theme the payment form. This is given 'as is' for themers which would want
* to theme this default form.
*
* @param array $form
* Drupal form
* @return string
* (x)html output
*/
function theme_lm_paypal_payment_form($form) {
return drupal_render($form);
}
/**
* Generates a human readable string from a number and a 3 letter currency code.
*
* If we can find a currency symbol (eg: '$') for the given currency code, use
* that and return a string like "$5.00". Otherwise, use the currency code to
* look up a currency name, and return a string like "5.00 U.S. Dollar".
*
* Note that in case of unknown currency code, the module will output the string
* without modification.
*
* @param array $options
* - float 'amount
* A numeric amount
* - string 'cc'
* A PayPal three letter currency code (eg: USD)
* - boolean 'syms' = TRUE
* Display either "$5" or "5 US Dollar". With TRUE display it with symbol.
* @return
* (x)html output
*/
function theme_lm_paypal_amount($options = array()) {
$options += array(
'cc' => lm_paypal_api_get_currency_default(),
'syms' => TRUE
);
// Get textual representation
$textual = lm_paypal_api_get_currency($options['cc'], $options['syms']);
// Do not display a NULL currency
if (! $textual) {
$textual = $options['cc'];
$options['syms'] = TRUE;
}
if ($options['syms']) {
return t('!symbol !amount', array('!amount' => $options['amount'], '!symbol' => $textual));
}
else {
return t('!amount !currency', array('!amount' => $options['amount'], '!currency' => $textual));
}
}