You are here

function _asset_file_localfile_options in Asset 5.2

Same name and namespace in other branches
  1. 6 asset.types.inc \_asset_file_localfile_options()

Related topics

1 call to _asset_file_localfile_options()
asset_file_form in ./asset.types.inc
Implementation of hook_asset_type('form') for file asset type

File

./asset.types.inc, line 72
This file is included by asset_asset_type() and includes all the file and directory specific functions

Code

function _asset_file_localfile_options($ext = FALSE) {
  if ($dir = variable_get('asset_ftp_dir', '')) {
    $options = array(
      '#' => t('-- Select a file --'),
    );
    $regex = $ext ? '.*\\.' . $ext : '.*';
    foreach (file_scan_directory($dir, $regex) as $file) {
      $path = str_replace($dir, '', $file->filename);
      $options[$path] = $path;
    }
    asort($options);
  }
  else {
    $options = FALSE;
  }
  return $options;
}