function _autocomplete_filename in Ubercart 5
Implement Drupal autocomplete textfield
@return: Sends string containing javascript array of matched files
1 string reference to '_autocomplete_filename'
- uc_file_menu in uc_file/
uc_file.module - Implementation of hook_menu().
File
- uc_file/
uc_file.module, line 948 - Allows products to be associated with downloadable files.
Code
function _autocomplete_filename() {
// Catch "/" characters that drupal autocomplete doesn't escape
$url = explode('_autocomplete_file/', request_uri());
$string = $url[1];
$matches = array();
$files = db_query("SELECT filename FROM {uc_files} WHERE filename LIKE LOWER('%s')", '%' . $string . '%');
while ($file = db_fetch_object($files)) {
$matches[$file->filename] = $file->filename;
}
print drupal_to_js($matches);
exit;
}