uc_attribute.theme.inc 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. * @see _uc_attribute_alter_form()
  15. * @ingroup themeable
  16. */
  17. function theme_uc_attribute_option($variables) {
  18. $output = $variables['option'];
  19. if ($variables['price']) {
  20. $output .= ', ' . $variables['price'];
  21. }
  22. return $output;
  23. }
  24. /**
  25. * Displays the attribute selection form elements.
  26. *
  27. * @param $variables
  28. * An associative array containing:
  29. * - form: A render element representing the form.
  30. *
  31. * @see _uc_attribute_alter_form()
  32. * @ingroup themeable
  33. */
  34. function theme_uc_attribute_add_to_cart($variables) {
  35. $form = $variables['form'];
  36. $output = '<div id="' . $form['#id'] . '" class="attributes">';
  37. $stripes = array('even' => 'odd', 'odd' => 'even');
  38. $parity = 'even';
  39. foreach (element_children($form) as $aid) {
  40. $parity = $stripes[$parity];
  41. $classes = array('attribute', 'attribute-' . $aid, $parity);
  42. $output .= '<div class="' . implode(' ', $classes) . '">';
  43. $output .= drupal_render($form[$aid]);
  44. $output .= '</div>';
  45. }
  46. $output .= drupal_render_children($form) . '</div>';
  47. return $output;
  48. }