protected function ActionForm::buildJsFileDisplay in Ubercart 8.4
Shows all possible files in selectable list.
1 call to ActionForm::buildJsFileDisplay()
- ActionForm::buildForm in uc_file/
src/ Form/ ActionForm.php - Form constructor.
File
- uc_file/
src/ Form/ ActionForm.php, line 333
Class
- ActionForm
- Performs file action (upload, delete, hooked in actions).
Namespace
Drupal\uc_file\FormCode
protected function buildJsFileDisplay($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 = $this
->displayArraysEquivalent($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] = ' . Json::encode('<li>' . implode('</li><li>', $no_recursion) . '</li>') . ';', 'inline');
drupal_add_js('uc_file_list[true] = ' . Json::encode('<li>' . implode('</li><li>', $recursion) . '</li>') . ';', 'inline');
return $result;
}