You are here

function uc_file_files_table in Ubercart 5

Table builder for file products admin

1 string reference to 'uc_file_files_table'
theme_uc_file_files_form in uc_file/uc_file.module
Implementation of theme_form($form)

File

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

Code

function uc_file_files_table($op, $args = array()) {
  switch ($op) {
    case 'fields':
      $fields = array();
      $fields[] = array(
        'name' => 'select',
        'title' => t(''),
        'weight' => 0,
        'enabled' => TRUE,
      );
      $fields[] = array(
        'name' => 'filename',
        'title' => t('File'),
        'weight' => 1,
        'enabled' => TRUE,
        'attributes' => array(
          'field' => 'f.filename',
        ),
      );
      $fields[] = array(
        'name' => 'product',
        'title' => t('Product'),
        'weight' => 2,
        'enabled' => TRUE,
        'attributes' => array(
          'field' => 'n.title',
        ),
      );
      $fields[] = array(
        'name' => 'model',
        'title' => t('Model/SKU'),
        'weight' => 3,
        'enabled' => TRUE,
        'attributes' => array(
          'field' => 'fp.model',
        ),
      );
      return $fields;
    case 'data':
      $data = array();
      $files = _group_filenames($args['files']);
      foreach ($files as $file) {
        $data['select'][] = drupal_render($args['form']['file_select_' . $file->fid]);
        $filename = is_dir(variable_get('uc_file_base_dir', NULL) . '/' . $file->filename) ? '<strong>' . $file->filename . '</strong>' : $file->filename;
        $data['filename'][] = $filename == $last_filename ? '' : $filename;
        if ($filename == $last_filename && !empty($data['#attributes'])) {
          $data['#attributes'][count($data['#attributes']) - 1] = array(
            'class' => 'group',
          );
        }
        $last_filename = empty($last_filename) || $filename != $last_filename ? $filename : $last_filename;
        $data['product'][] = !empty($file->title) ? l($file->title, 'node/' . $file->nid) : '';
        $data['model'][] = !empty($file->model) ? $file->model : '';
        $data['#attributes'][] = array();
      }
      return $data;
    case 'attributes':
      return array(
        'class' => 'file-table',
      );
  }
}