uc_product_kit.theme.inc 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * @file
  4. * Theme functions for the uc_product_kit module.
  5. */
  6. /**
  7. * Renders the list of kit components on the product kit edit form.
  8. *
  9. * @ingroup themeable
  10. */
  11. function theme_uc_product_kit_items_form($variables) {
  12. $form = &$variables['form'];
  13. $header = array(t('Product'), t('Quantity'), t('List position'), t('Discount'));
  14. $rows = array();
  15. foreach (element_children($form) as $item) {
  16. $row = array(
  17. drupal_render($form[$item]['link']),
  18. drupal_render($form[$item]['qty']),
  19. drupal_render($form[$item]['ordering']),
  20. drupal_render($form[$item]['discount']),
  21. );
  22. $rows[] = array(
  23. 'data' => $row,
  24. 'class' => array('draggable'),
  25. );
  26. }
  27. if (empty($rows)) {
  28. return '';
  29. }
  30. drupal_add_tabledrag('uc-product-kit-item-table', 'order', 'sibling', 'uc-product-kit-item-ordering');
  31. $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'uc-product-kit-item-table')));
  32. if (!empty($form['#description'])) {
  33. $output .= '<div class="description">' . $form['#description'] . "</div>\n";
  34. }
  35. return $output;
  36. }
  37. /**
  38. * Renders a product kit component.
  39. *
  40. * @ingroup themeable
  41. */
  42. function theme_uc_product_kit_list_item($variables) {
  43. $product = $variables['product'];
  44. $node = node_load($product->nid);
  45. if (node_access('view', $node)) {
  46. $title = l($product->title, 'node/' . $product->nid);
  47. }
  48. else {
  49. $title = check_plain($product->title);
  50. }
  51. return theme('uc_qty', array('qty' => $product->qty)) . ' ' . $title;
  52. }
  53. /**
  54. * Wraps the "Add to Cart" form in a <div>.
  55. *
  56. * @ingroup themeable
  57. */
  58. function theme_uc_product_kit_add_to_cart($variables) {
  59. $form = $variables['form'];
  60. $output = '<div class="add-to-cart" title="' . t('Click to add to cart.') . '">';
  61. $output .= drupal_render($form);
  62. $output .= '</div>';
  63. return $output;
  64. }