diff --git a/feeds.module b/feeds.module index ec6f42d6eae7d9ec72a68f68d9c8b11135be4a11..5870e50c7545c03754ce938202ff4d7210bd3788 100644 --- a/feeds.module +++ b/feeds.module @@ -43,6 +43,11 @@ function feeds_feeds_plugin() { 'file' => drupal_get_path('module', 'feeds') .'/plugins/FeedsHttpFetcher.inc', 'parent' => 'FeedsFetcher', ), + 'FeedsFileFetcher' => array( + 'name' => t('File fetcher'), + 'file' => drupal_get_path('module', 'feeds') .'/plugins/FeedsFileFetcher.inc', + 'parent' => 'FeedsFetcher', + ), 'FeedsCSVParser' => array( 'name' => t('CSV parser'), 'file' => drupal_get_path('module', 'feeds') .'/plugins/FeedsCSVParser.inc', diff --git a/feeds_ui/feeds_ui.admin.inc b/feeds_ui/feeds_ui.admin.inc index b0b576f5b5e087c78e62e3da7877d491b57e4a1f..6bf95efa1d9ba036475d648f2409420f58edb7af 100644 --- a/feeds_ui/feeds_ui.admin.inc +++ b/feeds_ui/feeds_ui.admin.inc @@ -64,6 +64,7 @@ function feeds_ui_build_create_form(&$form_state) { ); } else { + // @todo: present plugin form first. feeds_include('feed'); $feed = feeds_get_feed($form_state['storage']['id']); $form['settings'] = array( diff --git a/includes/feed.inc b/includes/feed.inc index bd3c8923ac718fbf78746678267fa97aec0d92bf..45fdfea2fd374ff70c9a94aa0e9f501303b46002 100644 --- a/includes/feed.inc +++ b/includes/feed.inc @@ -56,25 +56,15 @@ class Feed extends FeedsConfigurable { '#options' => array('' => t('None')) + node_get_types('names'), '#default_value' => $this->config['content_type'], ); - $form['source'] = array( - '#type' => 'textfield', - '#title' => t('URL'), - '#description' => t('Enter the URL for this feed @todo: delegate this form to plugin, hide if content type is picked.'), - '#default_value' => $config['source']['id'], - ); - $form['update'] = array( - '#type' => 'radios', - '#title' => t('Update existing'), - '#options' => array(1 => t('Yes'), 0 => t('No')), - '#default_value' => $this->config['update'], - ); - $period = drupal_map_assoc(array(1, 900, 1800, 3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 3628800, 4838400, 7257600, 15724800, 31536000), 'format_interval'); + $form['source'] = $this->fetcher->sourceForm($form_state); + $period = drupal_map_assoc(array(1, 900, 1800, 3600, 10800, 21600, 43200, 86400, 259200, 604800, 2419200), 'format_interval'); $period[FEEDAPI_CRON_NEVER_REFRESH] = t('Do not refresh periodically'); $period[1] = t('As often as possible'); $form['refresh_period'] = array( '#type' => 'select', '#title' => t('Minimum refresh period'), '#options' => $period, + '#description' => t('This is the minimum time that must elapse before a feed may be refreshed automatically.'), '#default_value' => $this->config['refresh_period'], ); return $form; @@ -327,6 +317,29 @@ class FeedsConfigurable { * plugin type. See hook_feeds_plugin(). */ class FeedsFetcher extends FeedsConfigurable { + + /** + * Source form. + */ + public function sourceForm(&$form_state) { + $form = array(); + $form['source'] = array( + '#type' => 'textfield', + '#title' => t('URL'), + '#description' => t('Enter the URL for this feed.'), + '#default_value' => $this->config['source'], + ); + return $form; + } + + /** + * Fetch content from a source and return it. + * + * Stub method. Every class that extends FeedsFetcher must implement this method. + * + * @param $source + * Source value as entered by user through sourceForm(). + */ public function fetch($source) { return NULL; } diff --git a/plugins/FeedsFileFetcher.inc b/plugins/FeedsFileFetcher.inc new file mode 100644 index 0000000000000000000000000000000000000000..4d7e0bef1b1fc1dba8a387a0334fc6093ebb46dd --- /dev/null +++ b/plugins/FeedsFileFetcher.inc @@ -0,0 +1,33 @@ +<?php +// $Id$ +/** + * @file + * Home of the FeedsFileFetcher. + */ + +/** + * Fetches data via HTTP. + */ +class FeedsFileFetcher extends FeedsFetcher { + + /** + * Source form. + */ + public function sourceForm(&$form_state) { + $form = array(); + $form['source'] = array( + '#type' => 'file', + '#title' => t('File'), + '#description' => t('Upload a file.'), + '#default_value' => $this->config['source'], + ); + return $form; + } + + /** + * Fetch a local resource. + */ + public function fetch($source) { + // @todo + } +} \ No newline at end of file