=== modified file 'uc_store/includes/uc_price.inc' --- uc_store/includes/uc_price.inc 2009-04-12 02:11:38 +0000 +++ uc_store/includes/uc_price.inc 2009-04-11 07:53:24 +0000 @@ -16,19 +16,50 @@ * if it is not already set with the value being the current user object. * @param $options * An associative array containing options that will be passed through to - * any alteration/formatting/theming functions implemented. - * @param $revision - * A string describing the 'revision' of the price to return. Currently - * accepted values are: - * - 'original' => 'The original price', - * - 'altered' => 'Price after passing through the alterer(s)', - * - 'formatted' => 'Price after passing through the formatter', - * - 'themed' => 'Price after passing through the theme layer'. (default) + * any alteration/formatting/theming functions implemented. A list of accepted + * options follows. + * + * 'cache': + * Default: TRUE + * If set FALSE, this price won't be cached. + * + * 'sign': + * Default: variable_get('uc_currency_sign', '$') + * The sign to use when formatting this price. + * + * 'sign_after': + * Default: variable_get('uc_sign_after_amount', FALSE) + * If set to TRUE, the sign will come after the price. + * + * 'prec': + * Default: variable_get('uc_currency_prec', 2) + * Precision to round the price to. + * + * 'dec': + * Default: variable_get('uc_currency_dec', '.') + * Decimal separator. + * + * 'thou': + * Default: variable_get('uc_currency_thou', ',') + * Thousand separator. + * + * 'label': + * Default: TRUE + * If set to TRUE, the + * + * 'revision': + * Default: 'themed' + * A string describing the revision of the price to return. Currently + * accepted values are: + * - 'original' => 'The original price', + * - 'altered' => 'Price after passing through the alterer(s)', + * - 'formatted' => 'Price after passing through the formatter', + * - 'themed' => 'Price after passing through the theme layer'. (default) * * This function handles price alteration, formatting, theming, and caching. * */ -function uc_price($price_info, $context, $options = array(), $revision = NULL) { +function uc_price($price_info, $context, $options = array()) { global $user; $values = array(); @@ -40,21 +71,30 @@ function uc_price($price_info, $context, ); } - // Initialize the options array. + // Initialize the options and context. $options += array( 'cache' => variable_get('uc_price_caching', TRUE), ); + + $context += array( + 'revision' => 'themed' + ); // Clamp to allowed revisions. - switch ($revision) { - case 'original': - case 'altered': - case 'formatted': - case 'themed': - break; + if (isset($context['revision'])) { + switch ($context['revision']) { + case 'original': + case 'altered': + case 'formatted': + case 'themed': + break; - default: - $revision = 'themed'; + default: + $context['revision'] = 'themed'; + } + } + else { + $context['revision'] = 'themed'; } // Get all the active handlers. @@ -114,7 +154,7 @@ function uc_price($price_info, $context, } // Return the requested revision. - return $values[$revision]; + return $values[$context['revision']]; } /**