You are here

function theme_uc_file_files_form in Ubercart 5

Implementation of theme_form($form)

File

uc_file/uc_file.module, line 566
Allows products to be associated with downloadable files.

Code

function theme_uc_file_files_form($form) {
  $output = '';

  //Only display files on 1st form step
  if ($form['step']['#value'] == 1) {
    $files = array();
    $args = array(
      'form' => $form,
    );
    $header = tablesort_sql(tapir_get_header('uc_file_files_table', array()));
    $order = empty($header) ? "ORDER BY f.filename ASC" : $header . ", f.filename ASC";
    $count_query = "SELECT COUNT(*) FROM {uc_files}";
    $query = pager_query("SELECT n.nid, f.filename, n.title, fp.model, f.fid, pf.pfid FROM {uc_files} as f LEFT JOIN {uc_file_products} as fp ON (f.fid = fp.fid) LEFT JOIN {uc_product_features} as pf ON (fp.pfid = pf.pfid) LEFT JOIN {node} as n ON (pf.nid = n.nid) " . $order, UC_FILE_PAGER_SIZE, 0, $count_query);
    while ($file = db_fetch_object($query)) {
      $files[] = $file;
    }
    $args['files'] = $files;
    $output .= '<p>' . t('File downloads can be attached to any Ubercart product as a product feature. For security reasons the <a href="!download_url">file downloads directory</a> is separated from the Drupal <a href="!file_url">file system</a>. Here are the list of files (and their associated Ubercart products) that can be used for file downloads.', array(
      '!download_url' => url('admin/store/settings/products/edit/features'),
      '!file_url' => url('admin/settings/file-system'),
    )) . '</p>';
    $output .= drupal_render($form['uc_file_action']);
    $output .= tapir_get_table('uc_file_files_table', $args);
    $output .= theme('pager', NULL, UC_FILE_PAGER_SIZE, 0);
  }

  //Checkboxes already rendered in uc_file_files_table
  foreach ($form as $form_element => $form_data) {
    if (strpos($form_element, 'file_select_') !== FALSE) {
      unset($form[$form_element]);
    }
  }
  $output .= drupal_render($form);
  return $output;
}