uc_store.theme.inc 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. /**
  3. * @file
  4. * Theme functions for the uc_store module.
  5. */
  6. /**
  7. * Displays a price in the standard format and with consistent markup.
  8. *
  9. * @param $variables
  10. * An associative array containing:
  11. * - price: A numerical price value.
  12. * - suffixes: An array of suffixes to be attached to this price.
  13. *
  14. * @ingroup themeable
  15. */
  16. function theme_uc_price($variables) {
  17. $output = '<span class="uc-price">' . uc_currency_format($variables['price']) . '</span>';
  18. if (!empty($variables['suffixes'])) {
  19. $output .= '<span class="price-suffixes">' . implode(' ', $variables['suffixes']) . '</span>';
  20. }
  21. return $output;
  22. }
  23. /**
  24. * Displays "Quantity" abbreviated as "Qty".
  25. *
  26. * @ingroup themeable
  27. */
  28. function theme_uc_qty_label() {
  29. return '<abbr title="' . t('Quantity') . '">' . t('Qty') . '</abbr>';
  30. }
  31. /**
  32. * Displays a quantity.
  33. *
  34. * @param $variables
  35. * An associative array containing:
  36. * - qty: The quantity to display.
  37. *
  38. * @ingroup themeable
  39. */
  40. function theme_uc_qty($variables) {
  41. return $variables['qty'] . ' ×';
  42. }
  43. /**
  44. * Displays a username in the standard format and with consistent markup.
  45. *
  46. * @param $variables
  47. * An associative array containing:
  48. * - uid: A user ID value.
  49. *
  50. * @ingroup themeable
  51. */
  52. function theme_uc_uid($variables) {
  53. if ($variables['uid']) {
  54. return theme('username', array('account' => user_load($variables['uid'])));
  55. }
  56. else {
  57. return '-';
  58. }
  59. }
  60. /**
  61. * Wraps the footer in a div so it can be re-styled.
  62. *
  63. * @param $variables
  64. * An associative array containing:
  65. * - message: String containing footer text.
  66. *
  67. * @ingroup themeable
  68. */
  69. function theme_uc_store_footer($variables) {
  70. return '<div id="store-footer">' . $variables['message'] . '</div>';
  71. }
  72. /**
  73. * Themes a pane sorting form into a table.
  74. *
  75. * @param $variables
  76. * An associative array containing:
  77. * - form: A render element representing the form.
  78. *
  79. * @ingroup themeable
  80. */
  81. function theme_uc_pane_sort_table($variables) {
  82. $form = $variables['form'];
  83. $prefix = $form['#pane_prefix'];
  84. $attributes = array();
  85. if (isset($form['#draggable'])) {
  86. $attributes['id'] = $form['#draggable'] . '-table';
  87. drupal_add_tabledrag($form['#draggable'] . '-table', 'order', 'sibling', $form['#draggable']);
  88. }
  89. $header = array(t('Pane'), t('List position'));
  90. foreach (element_children($form) as $pane_id) {
  91. $rows[] = array(
  92. 'data' => array(
  93. drupal_render($form[$pane_id][$prefix . '_' . $pane_id . '_enabled']),
  94. drupal_render($form[$pane_id][$prefix . '_' . $pane_id . '_weight']),
  95. ),
  96. 'class' => array('draggable'),
  97. );
  98. }
  99. return theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => $attributes)) . '<br />';
  100. }