function theme_tapir_table in Ubercart 7.3
Same name and namespace in other branches
- 6.2 uc_store/includes/tapir.inc \theme_tapir_table()
Themes form data into a table for display.
Parameters
$form: The array of form information needing to be rendered into the table.
Return value
string The table output rendered in HTML.
1 theme call to theme_tapir_table()
- uc_store_element_info in uc_store/uc_store.module 
- Implements hook_element_info().
File
- uc_store/includes/ tapir.inc, line 72 
- Contains the TAPIr code rolled into Ubercart core from Drupal contrib.
Code
function theme_tapir_table($variables) {
  $element = $variables['element'];
  $header = array();
  $rows = array();
  // First sort the columns by weight.
  uasort($element['#columns'], 'uc_weight_sort');
  // Loop through the columns and create the header array.
  foreach ($element['#columns'] as $col_id => $col_data) {
    // Add the cell if available.
    if (!isset($col_data['access']) || $col_data['access'] !== FALSE) {
      $header[] = $col_data['cell'];
    }
  }
  // Loop through the row data and create rows with the data in the right order.
  foreach ($element['#rows'] as $data) {
    $attributes = array();
    $row = array();
    // Loop through each column in the header.
    foreach ($element['#columns'] as $col_id => $col_data) {
      // If this row defines cell data for the current column...
      if ((!isset($col_data['access']) || $col_data['access'] !== FALSE) && isset($data[$col_id])) {
        $cell = array();
        if (isset($data[$col_id]['#cell_attributes']) && is_array($data[$col_id]['#cell_attributes'])) {
          foreach ($data[$col_id]['#cell_attributes'] as $property => $value) {
            if ($property == 'colspan' && $value == 'full') {
              // Extend full-width cells to the number of columns actually
              // displayed.
              $value = count($header);
            }
            $cell[$property] = $value;
          }
          $cell['data'] = drupal_render($data[$col_id]);
        }
        else {
          $cell = drupal_render($data[$col_id]);
        }
        // Add it to the row array.
        $row[] = $cell;
      }
    }
    // Merge the row data into a single row array along with the attributes.
    if (isset($data['#attributes'])) {
      $row = array_merge(array(
        'data' => $row,
      ), (array) $data['#attributes']);
    }
    // Add the current row to the table rows array.
    $rows[] = $row;
  }
  // Return the rendered table.
  $options = array(
    'header' => $header,
    'rows' => $rows,
  );
  if (isset($element['#attributes'])) {
    $options['attributes'] = (array) $element['#attributes'];
  }
  if (isset($element['#title'])) {
    $options['caption'] = $element['#title'];
  }
  return theme('table', $options) . drupal_render_children($element);
}