uc_usps.theme.inc 1007 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * @file
  4. * Theme functions for the uc_usps module.
  5. */
  6. /**
  7. * Theme function to format the USPS service name and rate amount line-item
  8. * shown to the customer.
  9. *
  10. * @param $variables
  11. * Associative array containing information needed to theme a quote.
  12. * Contains two keys:
  13. * - service: The USPS service name.
  14. * - packages: Package information.
  15. *
  16. * @ingroup themeable
  17. */
  18. function theme_uc_usps_option_label($variables) {
  19. $service = $variables['service'];
  20. $packages = $variables['packages'];
  21. // Start with USPS logo.
  22. $output = theme('image', array(
  23. 'path' => drupal_get_path('module', 'uc_usps') . '/uc_usps_logo.gif',
  24. 'alt' => t('U.S.P.S.'),
  25. 'attributes' => array('class' => 'usps-logo')
  26. ));
  27. // Add USPS service name, removing any 'U.S.P.S.' prefix.
  28. $output .= preg_replace('/^U\.S\.P\.S\./', '', $service);
  29. // Add package information
  30. $output .= ' (' . format_plural(count($packages), '1 package', '@count packages') . ')';
  31. return $output;
  32. }