summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoremerham2017-12-15 13:37:07 (GMT)
committerjoseph.olstad2017-12-15 13:37:07 (GMT)
commitb1e1b296c3bebc84278725eeb338d9088619eca4 (patch)
tree8e400cde45df6a804f6c8b243afd068521cde380
parent4bf86100217a65705ac3f3f5bbd5d4ed9bf21667 (diff)
Issue #1902586 by willvincent, queenvictoria, aaron, emerham, 30equals: Support recursion into subdirectories for file import
-rw-r--r--modules/media_bulk_upload/includes/media_bulk_upload.admin.inc11
1 files changed, 9 insertions, 2 deletions
diff --git a/modules/media_bulk_upload/includes/media_bulk_upload.admin.inc b/modules/media_bulk_upload/includes/media_bulk_upload.admin.inc
index 4fdd9ad..af755ea 100644
--- a/modules/media_bulk_upload/includes/media_bulk_upload.admin.inc
+++ b/modules/media_bulk_upload/includes/media_bulk_upload.admin.inc
@@ -15,10 +15,16 @@ function media_bulk_upload_import($form, &$form_state) {
$form['directory'] = array(
'#type' => 'textfield',
'#title' => t('Directory'),
- '#description' => t('Enter the absolute directory on the web server to look for files. Subdirectories inside this directory will not be scanned.'),
+ '#description' => t('Enter the absolute directory on the web server to look for files. Subdirectories inside this directory will not be scanned unless the Recurse through subdirectories box is checked.'),
'#required' => TRUE,
);
+ $form['recurse'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Recurse through subdirectories'),
+ '#description' => 'Iterate over the directory looking for files within subfolders that match the pattern.',
+ );
+
$form['to_directory'] = array(
'#type' => 'textfield',
'#title' => t('To Directory'),
@@ -63,6 +69,7 @@ function media_bulk_upload_import_validate($form, &$form_state) {
if ($form_state['values']['op'] != t('Confirm')) {
$directory = $form_state['values']['directory'];
$pattern = $form_state['values']['pattern'];
+ $recurse = $form_state['values']['recurse'];
if (!is_dir($directory)) {
form_set_error('directory', t('The provided directory does not exist.'));
}
@@ -77,7 +84,7 @@ function media_bulk_upload_import_validate($form, &$form_state) {
'\\*' => '.*',
'\\?' => '.?',
));
- $files = file_scan_directory($directory, '/^(' . $pattern_quoted . ')$/', array('recurse' => FALSE));
+ $files = file_scan_directory($directory, '/^(' . $pattern_quoted . ')$/i', array('recurse' => $recurse));
$files = array_keys($files);
if (empty($files)) {
form_set_error('pattern', t('No files were found in %directory matching the regular expression %pattern', array('%directory' => $directory, '%pattern' => $pattern_quoted)));