function filefield_source_reference_autocomplete in FileField Sources 7
Same name and namespace in other branches
- 6 sources/reference.inc \filefield_source_reference_autocomplete()
Menu callback; autocomplete.js callback to return a list of files.
1 string reference to 'filefield_source_reference_autocomplete'
- filefield_source_reference_menu in sources/
reference.inc - Implements hook_menu().
File
- sources/
reference.inc, line 178 - A FileField extension to allow referencing of existing files.
Code
function filefield_source_reference_autocomplete($entity_type, $bundle_name, $field_name, $filename) {
$field = field_info_instance($entity_type, $field_name, $bundle_name);
$items = array();
if (!empty($field)) {
$files = filefield_source_reference_get_files($filename, $field);
foreach ($files as $fid => $file) {
if (filefield_sources_file_access($file->uri)) {
$items[$file->filename . " [fid:{$fid}]"] = theme('filefield_source_reference_autocomplete_item', array(
'file' => $file,
));
}
}
}
drupal_json_output($items);
}