function _auditfiles_merge_file_references_get_file_data in Audit Files 7.3
Retrieves information about an individual file from the database.
Parameters
int $file_name: The ID of the file to prepare for display.
Return value
array The row for the table on the report, with the file's information formatted for display.
2 calls to _auditfiles_merge_file_references_get_file_data()
- auditfiles_merge_file_references_form in ./
auditfiles.mergefilereferences.inc - Generates the report.
- _auditfiles_merge_file_references_batch_display_process_files in ./
auditfiles.mergefilereferences.inc - The batch process operation for formatting the files for display on the page.
File
- ./
auditfiles.mergefilereferences.inc, line 943 - Generates a report showing & allowing for merging potential duplicate files.
Code
function _auditfiles_merge_file_references_get_file_data($file_name, $date_format) {
// Get all file IDs for those files whose names match the provided one.
$fid_query = 'SELECT fid
FROM {file_managed}
WHERE filename = :filename';
$fid_results = db_query($fid_query, array(
':filename' => $file_name,
))
->fetchAll();
if (count($fid_results) > 0) {
$fid_header = array(
t('File ID'),
t('URI'),
t('Size (in bytes)'),
t('Date'),
);
$fid_rows = array();
foreach ($fid_results as $fid_result) {
// Get the file object.
$file = file_load($fid_result->fid);
// Add the data to the collective.
$fid_rows[] = array(
$file->fid,
$file->uri,
number_format($file->filesize),
format_date($file->timestamp, $date_format),
);
}
// Theme the table.
$references = theme('table', array(
'header' => $fid_header,
'rows' => $fid_rows,
));
return array(
'filename' => $file_name,
'references' => $references,
);
}
}