uc_attribute.theme.inc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * @file
  4. * Theme functions for the uc_attribute module.
  5. */
  6. /**
  7. * Displays an attribute option with an optional total or adjustment price.
  8. *
  9. * @param $variables
  10. * An associative array containing:
  11. * - option: The option name.
  12. * - price: The price total or adjustment, if any.
  13. *
  14. * @return string
  15. * The HTML output.
  16. *
  17. * @see _uc_attribute_alter_form()
  18. * @ingroup themeable
  19. */
  20. function theme_uc_attribute_option($variables) {
  21. $output = $variables['option'];
  22. if ($variables['price']) {
  23. $output .= ', ' . $variables['price'];
  24. }
  25. return $output;
  26. }
  27. /**
  28. * Displays the attribute selection form elements.
  29. *
  30. * @param $variables
  31. * An associative array containing:
  32. * - form: A render element representing the form.
  33. *
  34. * @see _uc_attribute_alter_form()
  35. * @ingroup themeable
  36. */
  37. function theme_uc_attribute_add_to_cart($variables) {
  38. $form = $variables['form'];
  39. $output = '<div id="' . $form['#id'] . '" class="attributes">';
  40. $stripes = array('even' => 'odd', 'odd' => 'even');
  41. $parity = 'even';
  42. foreach (element_children($form) as $aid) {
  43. $parity = $stripes[$parity];
  44. $classes = array('attribute', 'attribute-' . $aid, $parity);
  45. $output .= '<div class="' . implode(' ', $classes) . '">';
  46. $output .= drupal_render($form[$aid]);
  47. $output .= '</div>';
  48. }
  49. $output .= drupal_render_children($form) . '</div>';
  50. return $output;
  51. }