You are here

function regcode_admin_list_getmarkup in Registration codes 6

Return the marked up list for display

1 call to regcode_admin_list_getmarkup()
regcode_admin_list in ./regcode.admin.php
Return the code list page content with(in) the according filter form

File

./regcode.admin.php, line 624
Functions and pages needed for the administration interface for the regcode module.

Code

function regcode_admin_list_getmarkup() {

  // Build a tablesort (automatically modifies the next db_query)
  module_load_include('regcode.api', 'regcode', 'php');
  $fields = regcode_get_fields();
  $header = array();
  $weight = 0;
  foreach ($fields as $field => $value) {
    $weight = ($weight / 10 + 1) * 10;
    $header[] = array(
      'data' => $value['#heading'],
      'field' => $field,
    );
  }
  $header[] = array(
    'data' => t('Actions'),
  );

  // Allow other modules to play with the headings
  foreach (module_implements('regcode_prepareheading') as $module) {
    $hook = $module . '_regcode_prepareheading';
    $hook($header);
  }

  // Query the database
  $sort = tablesort_sql($header);
  $result = regcode_admin_list_getresource();

  // Format the results
  $rows = array();
  while ($row = db_fetch_array($result)) {
    $rows[] = regcode_admin_list_preparerow($row);
  }

  // Output
  if (empty($rows)) {
    $output = '<p>&raquo; ' . t('No codes found.') . '</p>';
  }
  else {
    $output = theme('table', $header, $rows);
    $output .= theme('pager');
  }
  return $output;
}