function videoftp_options in Video 6.4
Same name and namespace in other branches
- 6.5 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 361 - videoftp widget hooks and callbacks.
Code
function videoftp_options($field) {
$ftp_path = file_directory_path() . '/' . $field['widget']['ftp_path'];
$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;
}