From 141a8d449e6035f276bd93f45568fb453f7e0971 Mon Sep 17 00:00:00 2001 From: Alex Barth <alex_b@53995.no-reply.drupal.org> Date: Sun, 3 Oct 2010 15:49:34 +0000 Subject: [PATCH] #930018: Don't show file upload when 'Supply path directly' is selected. --- CHANGELOG.txt | 2 ++ plugins/FeedsFileFetcher.inc | 42 ++++++++++++++++++++------------- tests/feeds_processor_node.test | 3 +-- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 8b77a863..38e5f13a 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,6 +3,8 @@ Feeds 7.x 2.0 XXXXXXXXXXXXXXXXXXX --------------------------------- +- #930018 alex_b: Don't show file upload when 'Supply path directly' is + selected. - #927892 alex_b: Add "Process in background" feature. Allows one-off imports to be processed in the background rather than using Batch API. Useful for very large imports. diff --git a/plugins/FeedsFileFetcher.inc b/plugins/FeedsFileFetcher.inc index a893345d..9a7ab19a 100644 --- a/plugins/FeedsFileFetcher.inc +++ b/plugins/FeedsFileFetcher.inc @@ -101,20 +101,28 @@ class FeedsFileFetcher extends FeedsFetcher { '#type' => 'value', '#value' => empty($source_config['fid']) ? 0 : $source_config['fid'], ); - $form['source'] = array( - '#type' => empty($this->config['direct']) ? 'value' : 'textfield', - '#title' => t('File'), - '#description' => t('Specify a path to a file or a directory starting with @scheme://. Alternatively upload a file below.', array('@scheme' => file_default_scheme())), - '#default_value' => empty($source_config['source']) ? '' : $source_config['source'], - ); - $form['upload'] = array( - '#type' => 'file', - '#title' => empty($this->config['direct']) ? t('File') : NULL, - '#description' => empty($source_config['source']) ? t('Select the file to be imported from your local system.') : t('Select a different file to be imported from your local system.'), - '#theme' => 'feeds_upload', - '#file_info' => empty($source_config['fid']) ? NULL : file_load($source_config['fid']), - '#size' => 10, - ); + if (empty($this->config['direct'])) { + $form['source'] = array( + '#type' => 'value', + '#value' => empty($source_config['source']) ? '' : $source_config['source'], + ); + $form['upload'] = array( + '#type' => 'file', + '#title' => empty($this->config['direct']) ? t('File') : NULL, + '#description' => empty($source_config['source']) ? t('Select a file from your local system.') : t('Select a different file from your local system.'), + '#theme' => 'feeds_upload', + '#file_info' => empty($source_config['fid']) ? NULL : file_load($source_config['fid']), + '#size' => 10, + ); + } + else { + $form['source'] = array( + '#type' => 'textfield', + '#title' => t('File'), + '#description' => t('Specify a path to a file or a directory. Path must start with @scheme://', array('@scheme' => file_default_scheme())), + '#default_value' => empty($source_config['source']) ? '' : $source_config['source'], + ); + } return $form; } @@ -199,8 +207,10 @@ class FeedsFileFetcher extends FeedsFetcher { ); $form['direct'] = array( '#type' =>'checkbox', - '#title' => t('Supply path to file directly'), - '#description' => t('For experts. Lets users specify a path to a file or a directory of files directly. This is useful when the files that need to be imported are already on the server.'), + '#title' => t('Supply path to file or directory directly'), + '#description' => t('For experts. Lets users specify a path to a file <em>or a directory of files</em> directly, + instead of a file upload through the browser. This is useful when the files that need to be imported + are already on the server.'), '#default_value' => $this->config['direct'], ); return $form; diff --git a/tests/feeds_processor_node.test b/tests/feeds_processor_node.test index 68c3a862..e806cbab 100644 --- a/tests/feeds_processor_node.test +++ b/tests/feeds_processor_node.test @@ -95,7 +95,7 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase { $this->drupalGet('node'); $this->assertRaw('<span class="username">Anonymous (not verified)</span>'); $this->assertDevseedFeedContent(); - + // Assert DB status. $count = db_query("SELECT COUNT(*) FROM {node} n INNER JOIN {feeds_node_item} fn ON n.nid = fn.nid")->fetchField(); $this->assertEqual($count, 10, 'Accurate number of items in database.'); @@ -315,7 +315,6 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase { $edit = array( 'allowed_extensions' => 'rss2', - 'direct' => 1, ); $this->drupalPost('admin/structure/feeds/edit/syndication_standalone/settings/FeedsFileFetcher', $edit, 'Save'); -- GitLab