=== modified file 'payment/uc_payment/uc_payment.admin.inc' --- payment/uc_payment/uc_payment.admin.inc 2009-04-18 01:03:01 +0000 +++ payment/uc_payment/uc_payment.admin.inc 2009-04-18 01:05:58 +0000 @@ -425,8 +425,16 @@ drupal_goto('admin/store/orders/'. $order->order_id .'/payments'); } + $context = array( + 'revision' => 'formatted', + 'location' => 'payment-delete', + 'subject' => array( + 'payment' => $payment, + ), + ); + $desc = ''. t('Payment information:') .' ' - . t('@method payment of @amount received on @date.', array('@method' => $payment->method, '@amount' => uc_currency_format($payment->amount), '@date' => format_date($payment->received, 'short'))); + . t('@method payment of @amount received on @date.', array('@method' => $payment->method, '@amount' => uc_price($payment->amount, $context), '@date' => format_date($payment->received, 'short'))); $form['order_id'] = array( '#type' => 'value', === modified file 'payment/uc_payment/uc_payment.ca.inc' --- payment/uc_payment/uc_payment.ca.inc 2009-01-09 18:46:09 +0000 +++ payment/uc_payment/uc_payment.ca.inc 2009-04-18 01:05:58 +0000 @@ -176,7 +176,11 @@ } function uc_payment_condition_order_balance_form($form_state, $settings = array()) { - $zero = array('!zero' => uc_currency_format(0)); + $context = array( + 'revision' => 'formatted', + 'location' => 'zero-balance', + ); + $zero = array('!zero' => uc_price(0, $context)); $options = array( 'less' => t('Balance is less than !zero.', $zero), 'less_equal' => t('Balance is less than or equal to !zero.', $zero), === modified file 'payment/uc_payment/uc_payment.module' --- payment/uc_payment/uc_payment.module 2009-04-13 14:34:21 +0000 +++ payment/uc_payment/uc_payment.module 2009-04-18 01:05:58 +0000 @@ -141,7 +141,12 @@ if (empty($values['order-payment-method'])) { $values['order-payment-method'] = _payment_method_data($order->payment_method, 'name'); } - $values['order-payment-balance'] = uc_currency_format(uc_payment_balance($order)); + + $context = array( + 'revision' => 'formatted', + 'location' => 'payment-balance-token', + ); + $values['order-payment-balance'] = uc_price(uc_payment_balance($order), $context); break; } @@ -576,7 +581,11 @@ if (variable_get('uc_payment_logging', TRUE)) { global $user; - $log_message = t('@method payment for @amount entered by @user.', array('@method' => $method_name, '@amount' => uc_currency_format($amount), '@user' => uc_get_initials($user->uid))); + $context = array( + 'revision' => 'formatted', + 'location' => 'payment-log', + ); + $log_message = t('@method payment for @amount entered by @user.', array('@method' => $method_name, '@amount' => uc_price($amount, $context), '@user' => uc_get_initials($user->uid))); uc_order_log_changes($order_id, array($log_message)); } @@ -597,7 +606,14 @@ if (variable_get('uc_payment_logging', TRUE)) { global $user; $payment = uc_payment_load($receipt_id); - $log_message = t('@method payment for @amount deleted by @user.', array('@method' => $payment->method, '@amount' => uc_currency_format($payment->amount), '@user' => uc_get_initials($user->uid))); + $context = array( + 'revision' => 'formatted', + 'location' => 'payment-delete-log', + 'subject' => array( + 'payment' => $payment, + ), + ); + $log_message = t('@method payment for @amount deleted by @user.', array('@method' => $payment->method, '@amount' => uc_price($payment->amount, $context), '@user' => uc_get_initials($user->uid))); uc_order_log_changes($payment->order_id, array($log_message)); } === modified file 'shipping/uc_flatrate/uc_flatrate.module' --- shipping/uc_flatrate/uc_flatrate.module 2009-04-13 14:34:57 +0000 +++ shipping/uc_flatrate/uc_flatrate.module 2009-04-18 01:05:58 +0000 @@ -207,7 +207,7 @@ $method = explode('_', $method['id']); $mid = $method[1]; $context = array( - 'revision' => 'formatted', + 'revision' => 'altered', 'location' => 'shipping-flatrate-method-json', ); @@ -217,17 +217,30 @@ $rate = $method->base_rate; foreach ($products as $product) { + $context['subject']['order_product'] = $product; if (empty($product->flatrate) || is_null($product->flatrate[$mid])) { + $price_info = array( + 'price' => $method->product_rate, + 'qty' => $product->qty, + ); // Add the method's default product rate. - $rate += $method->product_rate * $product->qty; + $rate += uc_price($price_info, $context); } else { + $price_info = array( + 'price' => $product->flatrate[$mid], + 'qty' => $product->qty, + ); // Add the product-specific rate. - $rate += $product->flatrate[$mid] * $product->qty; + $rate += uc_price($price_info, $context); } } - $quotes[] = array('rate' => $rate, 'format' => uc_price($rate, $context), 'option_label' => check_plain($method->label)); + unset($context['subject']['order_product']); + $altered = uc_price($rate, $context); + $context['revision'] = 'formatted'; + $formatted = uc_price($rate, $context); + $quotes[] = array('rate' => $altered, 'format' => $formatted, 'option_label' => check_plain($method->label)); } return $quotes; === modified file 'shipping/uc_quote/uc_quote.module' --- shipping/uc_quote/uc_quote.module 2009-04-13 14:34:57 +0000 +++ shipping/uc_quote/uc_quote.module 2009-04-18 01:05:58 +0000 @@ -401,8 +401,8 @@ ob_end_clean(); //drupal_set_message('
'. print_r($quote_data, TRUE) .'
'); if ($messages && variable_get('uc_quote_log_errors', FALSE)) { - watchdog('quote', $messages, WATCHDOG_WARNING); - watchdog('quote', '
'. print_r($quote_data, TRUE) .'
', WATCHDOG_WARNING); + watchdog('quote', $messages, NULL, WATCHDOG_WARNING); + watchdog('quote', '
'. print_r($quote_data, TRUE) .'
', NULL, WATCHDOG_WARNING); } return $quote_data; } === modified file 'shipping/uc_shipping/uc_shipping.admin.inc' --- shipping/uc_shipping/uc_shipping.admin.inc 2009-04-13 14:34:57 +0000 +++ shipping/uc_shipping/uc_shipping.admin.inc 2009-04-18 01:05:58 +0000 @@ -590,7 +590,10 @@ $context = array( 'revision' => 'formatted', 'location' => 'shipping-order-view', - 'subject' => array('shipment' => $shipment), + 'subject' => array( + 'shipment' => $shipment, + 'field' => 'cost', + ), ); $rows[] = array(t('Cost:'), uc_price($shipment->cost, $context)); $output .= theme('table', array(), $rows, array('style' => 'width:auto')); === modified file 'shipping/uc_shipping/uc_shipping.module' --- shipping/uc_shipping/uc_shipping.module 2009-04-13 14:34:57 +0000 +++ shipping/uc_shipping/uc_shipping.module 2009-04-18 01:05:58 +0000 @@ -237,9 +237,11 @@ $rows[] = array(t('Dimensions:'), t('!l x !w x !h', array('!l' => uc_length_format($package->length), '!w' => uc_length_format($package->width), '!h' => uc_length_format($package->height)))); } $context = array( - 'revision' => 'formatted', 'location' => 'shipping-package-view', - 'subject' => array('package' => $package), + 'subject' => array( + 'package' => $package, + 'field' => 'value', + ), ); $rows[] = array(t('Insured value:'), uc_price($package->value, $context)); if ($package->tracking_number) { === modified file 'shipping/uc_ups/uc_ups.admin.inc' --- shipping/uc_ups/uc_ups.admin.inc 2009-04-13 14:34:57 +0000 +++ shipping/uc_ups/uc_ups.admin.inc 2009-04-18 01:05:58 +0000 @@ -209,7 +209,10 @@ $context = array( 'revision' => 'formatted', 'location' => 'shipping-ups-confirm', - 'subject' => array('ups_info' => $_SESSION['ups']), + 'subject' => array( + 'ups_info' => $_SESSION['ups'], + 'field' => 'amount', + ), ); $output .= ''. check_plain($_SESSION['ups']['rate']['type']) .': '. uc_price($_SESSION['ups']['rate']['amount'], $context) .' ('. check_plain($_SESSION['ups']['rate']['currency']) .')
'; $ship_date = $_SESSION['ups']['ship_date']; === modified file 'shipping/uc_ups/uc_ups.module' --- shipping/uc_ups/uc_ups.module 2009-04-13 14:34:57 +0000 +++ shipping/uc_ups/uc_ups.module 2009-04-18 01:05:58 +0000 @@ -835,12 +835,14 @@ } uasort($quotes, 'uc_quote_price_sort'); $context = array( - 'revision' => 'formatted', 'location' => 'shipping-quote', ); foreach ($quotes as $key => $quote) { if (isset($quote['rate'])) { $context['subject']['quote'] = $quote; + $context['revision'] = 'altered'; + $quotes[$key]['rate'] = uc_price($quote['rate'], $context); + $context['revision'] = 'formatted'; $quotes[$key]['format'] = uc_price($quote['rate'], $context); $quotes[$key]['option_label'] = theme('uc_ups_option_label', $method['ups']['quote']['accessorials'][$key]); } === modified file 'shipping/uc_usps/uc_usps.module' --- shipping/uc_usps/uc_usps.module 2009-04-13 14:34:57 +0000 +++ shipping/uc_usps/uc_usps.module 2009-04-18 01:05:58 +0000 @@ -400,12 +400,14 @@ } } $context = array( - 'revision' => 'formatted', 'location' => 'shipping-usps-quote', ); foreach ($services as $key => $quote) { if (isset($quote['rate'])) { $context['subject']['quote'] = $quote; + $context['revision'] = 'altered'; + $services[$key]['rate'] = uc_price($quote['rate'], $context); + $context['revision'] = 'formatted'; $services[$key]['format'] = uc_price($quote['rate'], $context); $services[$key]['option_label'] = $quote['label']; } === modified file 'shipping/uc_weightquote/uc_weightquote.module' --- shipping/uc_weightquote/uc_weightquote.module 2009-04-13 14:34:57 +0000 +++ shipping/uc_weightquote/uc_weightquote.module 2009-04-18 01:05:58 +0000 @@ -173,23 +173,34 @@ * A JSON object containing the shipping quote for the order. */ function uc_weightquote_quote($products, $details) { - $rate = 0; - foreach ($products as $product) { - $node = node_load($product->nid); - $rate += $node->weightquote * $product->qty * $product->weight * uc_weight_conversion($node->weight_units, variable_get('uc_weight_unit', 'lb')); - } - $rate += variable_get('uc_weightquote_base_rate', 0); - $method = uc_weightquote_shipping_method(); $context = array( - 'revision' => 'formatted', + 'revision' => 'altered', 'location' => 'shipping-weightquote-quote', 'subject' => array( 'method' => $method, ), ); - $quotes[] = array('rate' => $rate, 'format' => uc_price($rate, $context), 'option_label' => $method['weightquote']['quote']['accessorials'][0]); + + $rate = 0; + foreach ($products as $product) { + $node = node_load($product->nid); + $context['subject']['order_product'] = $product; + $price_info = array( + 'price' => $node->weightquote, + 'qty' => $product->qty, + ); + $rate += uc_price($price_info, $context) * $product->weight * uc_weight_conversion($node->weight_units, variable_get('uc_weight_unit', 'lb')); + } + $rate += variable_get('uc_weightquote_base_rate', 0); + + unset($context['subject']['order_product']); + $altered = uc_price($rate, $context); + $context['revision'] = 'formatted'; + $formatted = uc_price($rate, $context); + + $quotes[] = array('rate' => $altered, 'format' => $formatted, 'option_label' => $method['weightquote']['quote']['accessorials'][0]); return $quotes; } === modified file 'uc_attribute/uc_attribute.admin.inc' --- uc_attribute/uc_attribute.admin.inc 2009-04-16 21:09:18 +0000 +++ uc_attribute/uc_attribute.admin.inc 2009-04-18 01:05:58 +0000 @@ -454,9 +454,17 @@ if ($view == 'overview') { $form['#tree'] = TRUE; + $context = array( + 'revision' => 'formatted', + 'location' => 'attribute-form-default-option', + ); if (count($attributes) > 0) { foreach ($attributes as $attribute) { $option = $attribute->options[$attribute->default_option]; + $context['subject'] = array( + 'attribute' => $attribute, + 'option' => $option, + ); $form['attributes'][$attribute->aid] = array( 'remove' => array( @@ -467,7 +475,7 @@ '#value' => check_plain($attribute->name), ), 'option' => array( - '#value' => $option ? (check_plain($option->name) .' ('. uc_currency_format($option->price) .')' ) : t('n/a'), + '#value' => $option ? (check_plain($option->name) .' ('. uc_price($option->price, $context) .')' ) : t('n/a'), ), 'required' => array( '#type' => 'checkbox', === modified file 'uc_cart/uc_cart.admin.inc' --- uc_cart/uc_cart.admin.inc 2009-02-18 15:29:36 +0000 +++ uc_cart/uc_cart.admin.inc 2009-04-18 01:05:58 +0000 @@ -50,11 +50,16 @@ '#size' => 32, '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='), ); + + $context = array( + 'revision' => 'formatted', + 'location' => 'minimum-subtotal-summary' + ); $form['general']['uc_minimum_subtotal'] = array( '#type' => 'textfield', '#title' => t('Minimum order subtotal'), '#description' => t('Optionally specify a minimum allowed subtotal for a cart to proceed to checkout.'), - '#summary' => t('The minimum subtotal is @subtotal', array('@subtotal' => uc_currency_format(variable_get('uc_minimum_subtotal', 0)))), + '#summary' => t('The minimum subtotal is @subtotal', array('@subtotal' => uc_price(variable_get('uc_minimum_subtotal', 0), $context))), '#default_value' => variable_get('uc_minimum_subtotal', 0), '#size' => 16, '#field_prefix' => variable_get('uc_sign_after_amount', FALSE) ? '' : variable_get('uc_currency_sign', '$'), === modified file 'uc_cart/uc_cart.module' --- uc_cart/uc_cart.module 2009-04-13 14:34:21 +0000 +++ uc_cart/uc_cart.module 2009-04-18 01:05:58 +0000 @@ -666,6 +666,10 @@ // Loop through each item. foreach ($items as $item) { + $context['subject'] = array( + 'cart_item' => $item, + 'field' => 'price', + ); // Add the basic row with quantity, title, and price. $output .= ''. $item['qty'] .'' .''. $item['title'] .'' @@ -705,7 +709,7 @@ */ function theme_uc_cart_block_summary($item_count, $item_text, $total, $summary_links) { $context = array( - 'revision' => 'formatted', + 'revision' => 'formatted-original', 'location' => 'cart-block-total', ); // Build the basic table with the number of items in the cart and total. @@ -865,6 +869,10 @@ '#tree' => TRUE, ); + $context = array( + 'revision' => 'formatted-original', + 'location' => 'cart-subtotal', + ); $i = 0; foreach ($items as $item) { $display_item = module_invoke($item->module, 'cart_display', $item); @@ -884,9 +892,6 @@ ); } - $context = array( - 'location' => 'cart-subtotal', - ); $form['items'][$i]['total'] = array( '#value' => uc_price($display_item['#total'], $context), '#theme' => 'uc_cart_view_price', @@ -1045,7 +1050,7 @@ } $context = array( - 'revision' => 'formatted', + 'revision' => 'formatted-original', 'location' => 'cart-table-subtotal', ); $table[] = array( === modified file 'uc_cart/uc_cart.pages.inc' --- uc_cart/uc_cart.pages.inc 2009-04-13 14:34:21 +0000 +++ uc_cart/uc_cart.pages.inc 2009-04-18 01:05:58 +0000 @@ -57,7 +57,12 @@ drupal_goto('cart'); } - if (($min = variable_get('uc_minimum_subtotal', 0)) > 0) { + $context = array( + 'revision' => 'altered', + 'location' => 'minimum-subtotal', + ); + + if (($min = uc_price(variable_get('uc_minimum_subtotal', 0), $context)) > 0) { $subtotal = 0; $items = uc_cart_get_contents(); if (is_array($items) && count($items) > 0) { @@ -69,7 +74,11 @@ } } if ($subtotal < $min) { - drupal_set_message(variable_get('uc_minimum_subtotal_text', t('The minimum order subtotal for checkout is !min.', array('!min' => uc_currency_format($min)))), 'error'); + $context = array( + 'revision' => 'formatted-original', + 'location' => 'minimum-subtotal-message', + ); + drupal_set_message(variable_get('uc_minimum_subtotal_text', t('The minimum order subtotal for checkout is !min.', array('!min' => uc_price($min, $context)))), 'error'); drupal_goto('cart'); } } === modified file 'uc_cart/uc_cart_checkout_pane.inc' --- uc_cart/uc_cart_checkout_pane.inc 2009-04-13 14:34:21 +0000 +++ uc_cart/uc_cart_checkout_pane.inc 2009-04-18 01:05:58 +0000 @@ -596,7 +596,7 @@ // Remove node from context to prevent the price from being altered. unset($context['subject']); - $context['revision'] = 'themed'; + $context['revision'] = 'themed-original'; $rows[] = array( array('data' => t('@qtyx', array('@qty' => $item->qty)), 'class' => 'qty'), array('data' => $description, 'class' => 'products'), @@ -607,7 +607,7 @@ // Add the subtotal as the final row. if ($show_subtotal) { $context = array( - 'revision' => 'formatted', + 'revision' => 'formatted-original', 'location' => 'cart-checkout-subtotal', ); $rows[] = array( === modified file 'uc_catalog/uc_catalog.module' --- uc_catalog/uc_catalog.module 2009-02-16 19:25:34 +0000 +++ uc_catalog/uc_catalog.module 2009-04-18 01:05:58 +0000 @@ -686,8 +686,12 @@ function theme_uc_catalog_product_grid($products) { $product_table = '
'; $count = 0; + $context = array( + 'location' => 'catalog-grid-product', + ); foreach ($products as $nid) { $product = node_load($nid); + $context['subject'] = array('node' => $product); if ($count == 0) { $product_table .= ""; @@ -713,7 +717,7 @@ } $product_table .= ''. $imagelink .''; if (variable_get('uc_catalog_grid_display_sell_price', TRUE)) { - $product_table .= ''. uc_currency_format($product->sell_price) .''; + $product_table .= ''. uc_price($product->sell_price, $context) .''; } if (variable_get('uc_catalog_grid_display_add_to_cart', TRUE)) { if (variable_get('uc_catalog_grid_display_attributes', TRUE)) { === modified file 'uc_order/uc_order.admin.inc' --- uc_order/uc_order.admin.inc 2009-04-13 14:34:21 +0000 +++ uc_order/uc_order.admin.inc 2009-04-18 01:05:58 +0000 @@ -452,6 +452,7 @@ } $context = array( + 'revision' => 'themed-original', 'location' => 'orders-admin', 'subject' => array( 'field' => 'order_total', @@ -954,9 +955,13 @@ ); $result = pager_query("SELECT o.order_id, o.created, os.title, SUM(op.qty) AS products, o.order_total AS total FROM {uc_orders} AS o LEFT JOIN {uc_order_statuses} AS os ON o.order_status = os.order_status_id LEFT JOIN {uc_order_products} AS op ON o.order_id = op.order_id WHERE o.uid = %d AND o.order_status IN ". uc_order_status_list('general', TRUE) ." GROUP BY o.order_id, o.created, os.title, o.order_total". tablesort_sql($header), 20, 0, "SELECT COUNT(*) FROM {uc_orders} WHERE uid = %d AND order_status NOT IN ". uc_order_status_list('specific', TRUE), $user->uid); - + $context = array( + 'revision' => 'themed-original', + 'location' => 'order-history', + ); // Build a table based on the customer's orders. while ($order = db_fetch_object($result)) { + $context['subject'] = array('order' => $order); $link = l($order->order_id, 'user/'. $user->uid .'/order/'. $order->order_id); if (user_access('view all orders')) { $link .= ''. uc_order_actions($order, TRUE) .''; @@ -966,7 +971,7 @@ array('data' => $link, 'nowrap' => 'nowrap'), array('data' => $order->title), array('data' => (!is_null($order->products) ? $order->products : 0), 'align' => 'center'), - array('data' => uc_currency_format($order->total, TRUE), 'align' => 'right'), + array('data' => uc_price($order->total, $context), 'align' => 'right'), ); } === modified file 'uc_order/uc_order.module' --- uc_order/uc_order.module 2009-04-13 14:34:21 +0000 +++ uc_order/uc_order.module 2009-04-18 01:05:58 +0000 @@ -386,7 +386,7 @@ } $values['order-subtotal'] = $subtotal; $context = array( - 'revision' => 'formatted', + 'revision' => 'formatted-original', 'location' => 'order-total-token', 'subject' => array( 'order' => $order, === modified file 'uc_order/uc_order.order_pane.inc' --- uc_order/uc_order.order_pane.inc 2009-04-13 14:34:21 +0000 +++ uc_order/uc_order.order_pane.inc 2009-04-18 01:05:58 +0000 @@ -767,6 +767,7 @@ $context['subject'] = array( 'order_product' => $product, + 'field' => 'cost', ); if (user_access('administer products')) { $data['cost'] = array( @@ -775,6 +776,7 @@ ); } + $context['subject']['field'] = 'price'; $price_info = array( 'price' => $product->price, 'qty' => $product->qty, @@ -881,6 +883,7 @@ $context['subject'] = array( 'order_product' => $product, + 'field' => 'cost', ); if (user_access('administer products')) { $data['cost'] = array( @@ -889,6 +892,7 @@ ); } + $context['subject']['field'] = 'price'; $price_info = array( 'price' => $product->price, 'qty' => $product->qty, === modified file 'uc_product/views/uc_product_handler_field_price.inc' --- uc_product/views/uc_product_handler_field_price.inc 2008-10-14 20:54:22 +0000 +++ uc_product/views/uc_product_handler_field_price.inc 2009-04-18 01:05:58 +0000 @@ -11,6 +11,20 @@ */ class uc_product_handler_field_price extends views_handler_field { function render($values) { - return uc_currency_format($values->{$this->field_alias}); + $context = array( + 'location' => 'views-price-handler', + 'class' => $this->field, + 'subject' => array( + 'node' => $values, + 'field' => $this->real_field, + ), + ); + $table_alias_len = strlen($this->table_alias); + foreach ($values as $key => $value) { + if (substr($key, 0, $table_alias_len) == $this->table_alias) { + $values->{substr($key, $table_alias_len + 1)} = $value; + } + } + return uc_price($values->{$this->field_alias}, $context); } } === modified file 'uc_product_kit/uc_product_kit.install' --- uc_product_kit/uc_product_kit.install 2009-03-13 15:49:49 +0000 +++ uc_product_kit/uc_product_kit.install 2009-04-18 01:05:58 +0000 @@ -183,10 +183,19 @@ function uc_product_kit_update_6002() { $ret = array(); + // Update moved to 6003 to fix flawed beta5 installations. + // See http://drupal.org/node/400720. + + return $ret; +} + +function uc_product_kit_update_6003() { + $ret = array(); + if (!db_column_exists('uc_product_kits', 'synchronized')) { db_add_field($ret, 'uc_product_kits', 'synchronized', array('type' => 'int', 'size', 'tiny', 'not null' => TRUE, 'default' => 0)); $ret[] = update_sql("UPDATE {uc_product_kits} SET synchronized = 1 WHERE discount < 0"); - + switch ($GLOBALS['db_type']) { case 'mysql': case 'mysqli': === modified file 'uc_product_kit/uc_product_kit.module' --- uc_product_kit/uc_product_kit.module 2009-04-02 20:53:12 +0000 +++ uc_product_kit/uc_product_kit.module 2009-04-18 01:05:58 +0000 @@ -431,6 +431,10 @@ $total = 0; $base_total = 0; $form['base']['items'] = array('#tree' => TRUE, '#weight' => 1); + $context = array( + 'revision' => 'formatted', + 'location' => 'product-kit-form-item-discount', + ); if (isset($node->products)) { foreach ($node->products as $i => $product) { $form['base']['items'][$i] = array('#type' => 'fieldset', @@ -448,11 +452,14 @@ '#title' => t('List position'), '#default_value' => isset($product->ordering) ? $product->ordering : 0, ); - $item = node_load($i); + $context['subject'] = array( + 'node' => $product, + 'field' => 'sell_price', + ); $form['base']['items'][$i]['discount'] = array('#type' => 'textfield', '#title' => t('Discount'), '#description' => t('Enter a positive or negative value to raise or lower the item price by that amount. This change is applied to each %product in the kit.', array('%product' => $product->title)), - '#field_prefix' => t('@price + ', array('@price' => uc_currency_format($product->sell_price))), + '#field_prefix' => t('@price + ', array('@price' => uc_price($product->sell_price, $context))), '#default_value' => isset($product->discount) ? number_format($product->discount, 3, '.', '') : 0, '#size' => 5, ); @@ -472,11 +479,15 @@ $form['base']['items'][$i]['discount']['#default_value'] = number_format($discount, 3, '.', ''); } } + $context = array( + 'revision' => 'formatted-original', + 'location' => 'product-kit-form-total', + ); $form['base']['kit_total'] = array( '#type' => 'textfield', '#title' => t('Total price'), '#default_value' => $node->synchronized ? '' : $total, - '#description' => t('If this field is set, the discounts of the individual products will be recalculated to equal this value. Currently, the total sell price is %price.', array('%price' => uc_currency_format($total))), + '#description' => t('If this field is set, the discounts of the individual products will be recalculated to equal this value. Currently, the total sell price is %price.', array('%price' => uc_price($total, $context))), '#weight' => 0, '#size' => 20, '#maxlength' => 35, @@ -531,13 +542,25 @@ 'add_to_cart' => 10, )); + $context = array( + 'location' => 'product-kit-view', + 'class' => array( + 'product-kit', + ), + 'subject' => array( + 'node' => $node, + ), + ); + if (module_exists('imagecache') && ($field = variable_get('uc_image_product_kit', '')) && isset($node->$field) && file_exists($node->{$field}[0]['filepath'])) { $node->content['image'] = array('#value' => theme('uc_product_image', $node->$field), '#access' => $enabled['image'], '#weight' => $weight['image'], ); } - $node->content['display_price'] = array('#value' => theme('uc_product_price', $node->sell_price, 'display-price', TRUE), + $context['class'][1] = 'display'; + $context['subject']['field'] = 'sell_price'; + $node->content['display_price'] = array('#value' => uc_price($node->sell_price, $context), '#access' => $enabled['display_price'], '#weight' => $weight['display_price'], ); @@ -547,11 +570,17 @@ '#weight' => $weight['model'], ); $node->content['body']['#weight'] = 1; - $node->content['list_price'] = array('#value' => theme('uc_product_price', $node->list_price, 'list-price'), + + $context['class'][1] = 'list'; + $context['subject']['field'] = 'list_price'; + $node->content['list_price'] = array('#value' => uc_price($node->list_price, $context), '#access' => $enabled['list_price'], '#weight' => $weight['list_price'], ); - $node->content['cost'] = array('#value' => theme('uc_product_price', $node->cost, 'cost'), + + $context['class'][1] = 'cost'; + $context['subject']['field'] = 'cost'; + $node->content['cost'] = array('#value' => uc_price($node->cost, $context), '#access' => $enabled['cost'] && user_access('administer products'), '#weight' => $weight['cost'], ); @@ -560,7 +589,9 @@ $node->content['#attributes'] = array('style' => 'display: inline'); } - $node->content['sell_price'] = array('#value' => theme('uc_product_price', $node->sell_price, 'sell-price', $teaser), + $context['class'][1] = 'sell'; + $context['subject']['field'] = 'sell_price'; + $node->content['sell_price'] = array('#value' => uc_price($node->sell_price, $context, array('label' => !$teaser)), '#access' => $enabled['sell_price'], '#weight' => $weight['sell_price'], ); === modified file 'uc_reports/uc_reports.admin.inc' --- uc_reports/uc_reports.admin.inc 2009-03-16 13:41:39 +0000 +++ uc_reports/uc_reports.admin.inc 2009-04-18 01:05:58 +0000 @@ -71,6 +71,11 @@ break; } + $context = array( + 'revision' => 'formatted-original', + 'location' => 'customer-report', + ); + $customers = pager_query($sql . tablesort_sql($header), $page_size, 0, $sql_count); while ($customer = db_fetch_array($customers)) { @@ -80,8 +85,8 @@ $customer_name = $customer['name']; $orders = (!empty($customer['orders']) ? $customer['orders'] : 0); $products = (!empty($customer['products']) ? $customer['products'] : 0); - $total_revenue = uc_currency_format($customer['total']); - $average_revenue = uc_currency_format($customer['average']); + $total_revenue = uc_price($customer['total'], $context); + $average_revenue = uc_price($customer['average'], $context); $rows[] = array( array('data' => $customer_number), array('data' => $name, 'nowrap' => 'nowrap'), @@ -173,15 +178,20 @@ $sql_count = "SELECT COUNT(n.nid) FROM $sql_tables WHERE $sql_conditions"; + $context = array( + 'revision' => 'formatted-original', + 'location' => 'products-report', + ); + $products = pager_query("SELECT $sql_vars FROM $sql_tables WHERE $sql_conditions GROUP BY n.nid, n.title" . tablesort_sql($header), $page_size, 0, $sql_count); while ($product = db_fetch_array($products)) { $product_cell = l($product['title'], 'node/'. ($product['nid'])); $product_csv = $product['title']; $sold_cell = (empty($product['sold'])) ? 0 : $product['sold']; $sold_csv = $sold_cell; - $revenue_cell = uc_currency_format((empty($product['revenue'])) ? 0 : $product['revenue']); + $revenue_cell = uc_price((empty($product['revenue'])) ? 0 : $product['revenue'], $context); $revenue_csv = $revenue_cell; - $gross_cell = uc_currency_format((empty($product['gross'])) ? 0 : $product['gross']); + $gross_cell = uc_price((empty($product['gross'])) ? 0 : $product['gross'], $context); $gross_csv = $gross_cell; $row = array( @@ -206,6 +216,7 @@ $csv_rows[] = $csv_row; if (module_exists('uc_attribute')) { + $context['location'] = 'product-attribute-report'; // Get the SKUs from this product. $models = _uc_reports_product_get_skus($product['nid']); // Add the product breakdown rows @@ -217,10 +228,14 @@ $product_csv = " $model"; $breakdown_sold = ((!empty($sold)) ? $sold : 0); $sold_csv = ((!empty($sold)) ? $sold : 0); - $breakdown_revenue = (uc_currency_format((!empty($revenue)) ? $revenue : 0)); - $revenue_csv = (uc_currency_format((!empty($revenue)) ? $revenue : 0)); - $breakdown_gross = (uc_currency_format((!empty($gross)) ? $gross : 0)); - $gross_csv = (uc_currency_format((!empty($gross)) ? $gross : 0)); + + $context['revision'] = 'themed'; + $breakdown_revenue = uc_price((!empty($revenue)) ? $revenue : 0, $context); + $breakdown_gross = uc_price((!empty($gross)) ? $gross : 0, $context); + + $context['revision'] = 'formatted'; + $revenue_csv = uc_price((!empty($revenue)) ? $revenue : 0, $context); + $gross_csv = uc_price((!empty($gross)) ? $gross : 0, $context); $row = array( 'data' => array( @@ -398,11 +413,16 @@ // Calculate and add today's sales summary to the report table. $today = _uc_reports_get_sales($today_start); + $context = array( + 'revision' => 'themed-original', + 'location' => 'sales-report-summary', + ); + $rows[] = array( l(t('Today, !date', array('!date' => format_date($today_start, 'custom', $format, 0))), 'admin/store/orders/search/results/0/0/0/0/0/0/'. $today_start .'/'. $today_end), $today['total'], - uc_currency_format($today['income']), - uc_currency_format($today['average']), + uc_price($today['income'], $context), + uc_price($today['average'], $context), ); // Calculate and add yesterday's sales summary to the report table. @@ -411,8 +431,8 @@ $rows[] = array( l(t('Yesterday, !date', array('!date' => format_date($today_start - 86400, 'custom', $format, 0))), 'admin/store/orders/search/results/0/0/0/0/0/0/'. ($today_start - 86400) .'/'. ($today_end - 86400)), $yesterday['total'], - uc_currency_format($yesterday['income']), - uc_currency_format($yesterday['average']), + uc_price($yesterday['income'], $context), + uc_price($yesterday['average'], $context), ); // Get the sales report for the month. @@ -423,8 +443,8 @@ $rows[] = array( l(t('Month-to-date, @month', array('@month' => $month_title)), 'admin/store/orders/search/results/0/0/0/0/0/0/'. $month_start .'/'. $month_end), $month['total'], - uc_currency_format($month['income']), - uc_currency_format($month['average']), + uc_price($month['income'], $context), + uc_price($month['average'], $context), ); // Calculate the daily averages for the month. @@ -442,7 +462,7 @@ $rows[] = array( t('Daily average for @month', array('@month' => $month_title)), $daily_orders, - uc_currency_format($daily_revenue), + uc_price($daily_revenue, $context), '', ); @@ -453,7 +473,7 @@ $rows[] = array( t('Projected totals for @date', array('@date' => $month_title)), round($month['total'] + ($daily_orders * $remaining_days), 2), - uc_currency_format(round($month['income'] + ($daily_revenue * $remaining_days), 2)), + uc_price(round($month['income'] + ($daily_revenue * $remaining_days), 2), $context), '', ); @@ -464,7 +484,7 @@ $header = array(array('data' => t('Statistics'), 'width' => '50%'), ''); $rows = array( - array(array('data' => t('Grand total sales')), array('data' => uc_currency_format(db_result(db_query("SELECT SUM(order_total) FROM {uc_orders} WHERE order_status IN $order_statuses"))))), + array(array('data' => t('Grand total sales')), array('data' => uc_price(db_result(db_query("SELECT SUM(order_total) FROM {uc_orders} WHERE order_status IN $order_statuses")))), $context), array(array('data' => t('Customers total')), array('data' => db_result(db_query("SELECT COUNT(DISTINCT uid) FROM {uc_orders} WHERE order_status IN $order_statuses")))), array(array('data' => t('New customers today')), array('data' => db_result(db_query("SELECT COUNT(DISTINCT uid) FROM {uc_orders} WHERE order_status IN $order_statuses AND %d >= created AND created >= %d", $today_end, $today_start)))), array(array('data' => t('Online customers')), array('data' => db_result(db_query("SELECT COUNT(DISTINCT s.uid) FROM {sessions} as s LEFT JOIN {uc_orders} as o ON s.uid = o.uid WHERE s.uid > 0 AND o.order_status IN $order_statuses")))), @@ -527,6 +547,11 @@ // Build the header to the CSV export. $csv_rows = array(array(t('Month'), t('Number of orders'), t('Total revenue'), t('Average order'))); + $context = array( + 'revision' => 'formatted-original', + 'location' => 'sales-year-report', + ); + // For each month of the year... for ($i = 1; $i <= 12; $i++) { // Calculate the start and end timestamps for the month in local time. @@ -548,16 +573,16 @@ $rows[] = array( l(gmdate('M Y', $month_start), 'admin/store/orders/search/results/0/0/0/0/0/0/'. $month_start .'/'. $month_end), $month_sales['total'], - uc_currency_format($month_sales['income']), - uc_currency_format($month_average), + uc_price($month_sales['income'], $context), + uc_price($month_average, $context), ); // Add the data to the CSV export. $csv_rows[] = array( gmdate('M Y', $month_start), $month_sales['total'], - uc_currency_format($month_sales['income']), - uc_currency_format($month_average), + uc_price($month_sales['income'], $context), + uc_price($month_average, $context), ); } @@ -580,16 +605,16 @@ $rows[] = array( l(t('Total @year', array('@year' => $year)), 'admin/store/orders/search/results/0/0/0/0/0/0/'. $year_start .'/'. $year_end), $year_sales['total'], - uc_currency_format($year_sales['income']), - uc_currency_format($year_average), + uc_price($year_sales['income'], $context), + uc_price($year_average, $context), ); // Add the total data to the CSV export. $csv_rows[] = array( t('Total @year', array('@year' => $year)), $year_sales['total'], - uc_currency_format($year_sales['income']), - uc_currency_format($year_average), + uc_price($year_sales['income'], $context), + uc_price($year_average, $context), ); // Cache the CSV export. @@ -672,6 +697,11 @@ // Grab the subreports based on the date range and the report breakdown. $subreports = _uc_reports_subreport_intervals($args['start_date'], $args['end_date'], $args['length']); + $context = array( + 'revision' => 'formatted-original', + 'location' => 'sales-custom-report', + ); + // Loop through the subreports and build the report table. foreach ($subreports as $subreport) { $product_data = ''; @@ -722,7 +752,7 @@ array('data' => $date, 'nowrap' => 'nowrap'), empty($order_data) ? '0' : $order_data, empty($product_data) ? '0' : $product_data, - uc_currency_format($revenue_count), + uc_price($revenue_count, $context), ); // Add the data to the CSV export. @@ -730,7 +760,7 @@ $date, empty($order_csv) ? '0' : $order_csv, empty($product_csv) ? '0' : $product_csv, - uc_currency_format($revenue_count), + uc_price($revenue_count, $context), ); } @@ -744,7 +774,7 @@ t('Total'), $order_total, $product_total, - uc_currency_format($revenue_total), + uc_price($revenue_total, $context), ); // Add the total data to the CSV export. @@ -752,7 +782,7 @@ t('Total'), $order_total, $product_total, - uc_currency_format($revenue_total), + uc_price($revenue_total, $context), ); // Cache the CSV export. === modified file 'uc_store/includes/uc_price.inc' --- uc_store/includes/uc_price.inc 2009-04-18 01:03:01 +0000 +++ uc_store/includes/uc_price.inc 2009-04-18 01:05:58 +0000 @@ -283,7 +283,7 @@ * display settings. */ function uc_store_price_handler_format($price, $options) { - $output = ''; + $output = '~'; // If the value is less than the minimum precision, zero it. if ($options['prec'] > 0 && abs($price) < 1 / pow(10, $options['prec'])) { === modified file 'uc_store/uc_store.admin.inc' --- uc_store/uc_store.admin.inc 2009-04-12 02:11:38 +0000 +++ uc_store/uc_store.admin.inc 2009-04-18 01:05:58 +0000 @@ -695,11 +695,16 @@ '#maxlength' => 3, '#size' => 5, ); + + $context = array( + 'revision' => 'formatted-original', + 'location' => 'currency-format-form', + ); $form['currency']['example'] = array( '#type' => 'textfield', '#title' => t('Current format'), - '#value' => uc_currency_format(1000.1234), - '#summary' => t('Currency format: @format', array('@format' => uc_currency_format(1000.1234))), + '#value' => uc_price(1000.1234, $context), + '#summary' => t('Currency format: @format', array('@format' => uc_price(1000.1234, $context))), '#disabled' => TRUE, '#size' => 10, ); @@ -898,6 +903,10 @@ $header = array(t('View'), t('Order ID'), t('Date'), t('Billing name'), t('Shipping name'), t('Items'), t('Total')); + $context = array( + 'revision' => 'themed-original', + 'location' => 'customer-orders', + ); $totals = array('orders' => 0, 'items' => 0, 'total' => 0); while ($order = db_fetch_object($result)) { $icons = l(uc_store_get_icon('file:order_view'), @@ -926,6 +935,7 @@ $totals['items'] += $item_count['COUNT(*)']; $totals['total'] += $order->order_total; + $context['subject'] = array('order' => $order); $rows[] = array( 'data' => array( array('data' => $icons), @@ -934,7 +944,7 @@ array('data' => check_plain($bname)), array('data' => check_plain($sname)), array('data' => $item_count['COUNT(*)']), - array('data' => uc_currency_format($order->order_total), 'nowrap' => 'nowrap')), + array('data' => uc_price($order->order_total, $context), 'nowrap' => 'nowrap')), 'id' => 'order-'. $order->order_id, ); } @@ -946,12 +956,16 @@ drupal_add_js(drupal_get_path('module', 'uc_store') .'/uc_store.js'); + $context = array( + 'revision' => 'formatted-original', + 'location' => 'customer-orders-total', + ); $output = '

'. l(t('Create an order for this customer.'), 'admin/store/orders/create/'. $uid) .'

'; $output .= '

'. t('!totals_orders orders shown match that account with !totals_items items purchased and !totals_total spent:', array('!totals_orders' => $totals['orders'], '!totals_items' => $totals['items'], - '!totals_total' => uc_currency_format($totals['total']))) .'

' + '!totals_total' => uc_price($totals['total'], $context))) .'

' . theme('table', $header, $rows, array('width' => '100%', 'class' => 'uc-cust-orders-table')) .'
'. theme_pager(NULL, 50); === modified file 'uc_store/uc_store.module' --- uc_store/uc_store.module 2009-04-15 17:50:23 +0000 +++ uc_store/uc_store.module 2009-04-18 01:05:58 +0000 @@ -568,7 +568,7 @@ } $context['class'][] = 'uc-price'; // Class the element. - $output = ''; + $output = '
'; // Prefix(es). if ($options['label'] && isset($options['prefixes'])) { $output .= implode('', $options['prefixes']); @@ -579,7 +579,7 @@ if ($options['label'] && isset($options['suffixes'])) { $output .= implode('', $options['suffixes']); } - $output .= ''; + $output .= '
'; return $output; } @@ -768,8 +768,12 @@ function uc_store_js_util($func) { switch ($func) { case 'currency_format': + $context = array( + 'revision' => 'formatted-original', + 'location' => 'js-util-currency-format', + ); $amount = is_numeric($_POST['amount']) ? $_POST['amount'] : 0; - $output = uc_currency_format($amount); + $output = uc_price($amount, $context); break; case 'zone_select': $country_id = intval($_POST['country_id']) > 0 ? intval($_POST['country_id']) : uc_store_default_country(); === modified file 'uc_tax_report/uc_tax_report.module' --- uc_tax_report/uc_tax_report.module 2009-02-27 15:32:25 +0000 +++ uc_tax_report/uc_tax_report.module 2009-04-18 01:05:58 +0000 @@ -120,13 +120,17 @@ $amount = 0; $star_legend = ''; + $context = array( + 'revision' => 'formatted-original', + 'location' => 'tax-report', + ); foreach($totals as $line) { $row = array( $line['name'], $line['jurisdiction'], number_format($line['rate'] * 100, 3) . '%', - uc_currency_format($line['taxable_amount']), - uc_currency_format($line['amount']), + uc_price($line['taxable_amount'], $context), + uc_price($line['amount'], $context), ); $rows[] = $row; $csv_rows[] = $row; @@ -140,7 +144,7 @@ '*', '*', '*', - uc_currency_format($line['amount']), + uc_price($line['amount'], $context), ); $rows[] = $row; $csv_rows[] = $row; @@ -154,8 +158,8 @@ t('Total'), '', '', - uc_currency_format($taxable_amount), - uc_currency_format($amount), + uc_price($taxable_amount, $context), + uc_price($amount, $context), ); $rows[] = $row; $csv_rows[] = $row; === modified file 'uc_taxes/uc_taxes.module' --- uc_taxes/uc_taxes.module 2009-03-11 13:18:12 +0000 +++ uc_taxes/uc_taxes.module 2009-04-18 01:05:58 +0000 @@ -145,6 +145,13 @@ $changes = array(); $line_items = uc_line_item_tax('load', $arg1); //$arg1->line_items = uc_order_load_line_items($arg1, TRUE); + $context = array( + 'revision' => 'formatted', + 'location' => 'tax-changes-log', + 'subject' => array( + 'order' => $arg1, + ), + ); if (is_array($arg1->line_items)) { //drupal_set_message('
'. var_export($arg1->line_items, TRUE) .'
'); foreach ($arg1->line_items as $i => $line) { @@ -153,9 +160,10 @@ foreach ($line_items as $id => $new_line) { if ($new_line['title'] == $line['title']) { if ($new_line['amount'] != $line['amount']) { + $context['subject']['line_item'] = $new_line; uc_order_update_line_item($line['line_item_id'], $new_line['title'], $new_line['amount'], $new_line['data']); $arg1->line_items[$i]['amount'] = $new_line['amount']; - $changes[] = t('Changed %title to %amount.', array('%amount' => uc_currency_format($new_line['amount']), '%title' => $new_line['title'])); + $changes[] = t('Changed %title to %amount.', array('%amount' => uc_price($new_line['amount'], $context), '%title' => $new_line['title'])); } unset($line_items[$id]); $delete = FALSE; @@ -175,7 +183,8 @@ uc_order_line_item_add($arg1->order_id, $line['id'], $line['title'], $line['amount'], $line['weight'], $line['data']); $line['type'] = 'tax'; $arg1->line_items[] = $line; - $changes[] = t('Added %amount for %title.', array('%amount' => uc_currency_format($line['amount']), '%title' => $line['title'])); + $context['subject']['line_item'] = $line; + $changes[] = t('Added %amount for %title.', array('%amount' => uc_price($line['amount'], $context), '%title' => $line['title'])); } } if (count($changes)) {