You are here

function _uc_file_sort_names in Ubercart 8.4

Same name and namespace in other branches
  1. 6.2 uc_file/uc_file.module \_uc_file_sort_names()
  2. 7.3 uc_file/uc_file.module \_uc_file_sort_names()

Takes a list of file ids and sort the list by the associated filenames.

Parameters

$fids array: The array of file ids.

Return value

array The sorted array of file ids.

4 calls to _uc_file_sort_names()
ActionForm::buildForm in uc_file/src/Form/ActionForm.php
Form constructor.
ActionForm::buildJsFileDisplay in uc_file/src/Form/ActionForm.php
Shows all possible files in selectable list.
FileDeleteForm::buildForm in uc_file/src/Form/FileDeleteForm.php
Form constructor.
FileDeleteForm::buildJsFileDisplay in uc_file/src/Form/FileDeleteForm.php
Shows all possible files in selectable list.

File

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

Code

function _uc_file_sort_names(array $fids) {
  $result = $aggregate = [];
  foreach ($fids as $fid) {
    $file = uc_file_get_by_id($fid);
    $aggregate[] = [
      'filename' => $file->filename,
      'fid' => $file->fid,
    ];
  }
  usort($aggregate, '_uc_file_sort_by_name');
  foreach ($aggregate as $file) {
    $result[] = $file['fid'];
  }
  return $result;
}