function _filefield_source_attach_options in FileField Sources 6
Same name and namespace in other branches
- 7 sources/attach.inc \_filefield_source_attach_options()
1 call to _filefield_source_attach_options()
- filefield_source_attach_process in sources/
attach.inc - A #process callback to extend the filefield_widget element type.
File
- sources/
attach.inc, line 180 - A FileField extension to allow use of files within a server directory.
Code
function _filefield_source_attach_options($path) {
if (!field_file_check_directory($path, FILE_CREATE_DIRECTORY)) {
drupal_set_message(t('Specified file attach path must exist or be writable.'), 'error');
return FALSE;
}
$options = array();
$file_attach = file_scan_directory($path, '.*', array(
'.',
'..',
'CVS',
'.svn',
), 0, TRUE, 'filename', 0, 0);
if (count($file_attach)) {
$options = array(
'' => t('-- Select file --'),
);
foreach ($file_attach as $filename => $fileinfo) {
$filename = basename($filename);
$options[$fileinfo->filename] = preg_replace('/^' . preg_quote($path, '/') . '\\//', '', $fileinfo->filename, 1);
}
}
natcasesort($options);
return $options;
}