You are here

function _uc_file_build_js_file_display in Ubercart 6.2

Same name and namespace in other branches
  1. 7.3 uc_file/uc_file.admin.inc \_uc_file_build_js_file_display()

Shows all possible files in selectable list.

1 call to _uc_file_build_js_file_display()
uc_file_admin_files_form_action in uc_file/uc_file.admin.inc
Performs file action (upload, delete, hooked in actions).

File

uc_file/uc_file.admin.inc, line 505
File administration menu items.

Code

function _uc_file_build_js_file_display($file_ids) {

  // Gather the files if recursion is selected. Get 'em all ready to be punched into
  // the file list.
  $recursion_file_ids = _uc_file_sort_names(_uc_file_get_dir_file_ids($file_ids, TRUE));
  foreach ($recursion_file_ids as $file_id) {
    $file = uc_file_get_by_id($file_id);
    $recursion[] = '<li>' . $file->filename . '</li>';
  }

  // Gather the files if recursion ISN'T selected.
  // Get 'em all ready to be punched into the file list.
  $no_recursion_file_ids = $file_ids;
  foreach ($no_recursion_file_ids as $file_id) {
    $file = uc_file_get_by_id($file_id);
    $no_recursion[] = '<li>' . $file->filename . '</li>';
  }

  // We'll disable the recursion checkbox if they're equal.
  $equivalent = _uc_file_display_arrays_equivalent($recursion_file_ids, $no_recursion_file_ids);

  // The list to show if the recursion checkbox is $key.
  $result[TRUE] = $equivalent ? FALSE : $recursion;
  $result[FALSE] = $no_recursion;

  // Set up some JS to dynamically update the list based on the
  // recursion checkbox state.
  drupal_add_js('uc_file_list[false] = ' . drupal_to_js('<li>' . implode('</li><li>', $no_recursion) . '</li>') . ';', 'inline');
  drupal_add_js('uc_file_list[true] = ' . drupal_to_js('<li>' . implode('</li><li>', $recursion) . '</li>') . ';', 'inline');
  return $result;
}