function videoftp_options in Video 6.5
Same name and namespace in other branches
- 6.4 types/videoftp/videoftp_widget.inc \videoftp_options()
1 call to videoftp_options()
- videoftp_widget_process in types/
videoftp/ videoftp_widget.inc - Process an individual element.
File
- types/
videoftp/ videoftp_widget.inc, line 362 - videoftp widget hooks and callbacks.
Code
function videoftp_options($field) {
$ftp_path = file_directory_path() . '/' . $field['widget']['ftp_path'];
if (!is_dir($ftp_path)) {
return array();
}
$video_files = scandir($ftp_path);
if (empty($video_files)) {
return array();
}
$max_filesize = NULL;
if (!empty($field['widget']['max_filesize_per_file'])) {
$max_filesize = parse_size($field['widget']['max_filesize_per_file']);
}
$extensions = explode(' ', $field['widget']['file_extensions']);
$options = array();
foreach ($video_files as $file) {
if ($file == '.' || $file == '..') {
continue;
}
if ($max_filesize != NULL) {
$fullpath = $ftp_path . '/' . $file;
$filesize = filesize($fullpath);
if ($filesize > $max_filesize) {
continue;
}
}
$ext = pathinfo($file);
if (!in_array($ext['extension'], $extensions)) {
continue;
}
// Add the file to the options array for selection
$options[$file] = $file;
}
return $options;
}