Skip to content
Snippets Groups Projects
Commit b4e6e38a authored by Alex Barth's avatar Alex Barth
Browse files

Clean up basic settings form.

parent 7386e8d8
No related branches found
No related tags found
No related merge requests found
// $Id$
Feeds 7.x 2.0 XXXXXXXXXXXXXXXXXXX
---------------------------------
- Clean up basic settings form.
Feeds 7.x 2.0 Alpha 1, 2010-09-29
--------------------------------
---------------------------------
- #925842 alex_b: Support batching through directories on disk.
- #625196 mstrelan, alex_b: Fix array_merge(), array_intersect_key() warnings.
......
......@@ -26,7 +26,7 @@ function feeds_ui_edit_help() {
In Basic settings, you can <strong>attach an importer configuration to a content type</strong>. This is useful when many imports of a kind should be created, for example in an RSS aggregation scenario. If you don\'t attach a configuration to a content type, you can use it on the !import page.
</li>
<li>
Imports can be <strong>refreshed periodically</strong> - see the minimum refresh period in the Basic settings.
Imports can be <strong>scheduled periodically</strong> - see the periodic import select box in the Basic settings.
</li>
<li>
Processors can have <strong>mappings</strong> in addition to settings. Mappings allow you to define what elements of a data feed should be mapped to what content fields on a granular level. For instance, you can specify that a feed item\'s author should be mapped to a node\'s body.
......@@ -319,7 +319,7 @@ function feeds_ui_edit_page($importer, $active = 'help', $plugin_key = '') {
$items = array();
$items[] = t('Attached to: @type', array('@type' => $importer->config['content_type'] ? node_type_get_name($importer->config['content_type']) : t('[none]')));
if ($importer->config['import_period'] == FEEDS_SCHEDULE_NEVER) {
$import_period = t('never');
$import_period = t('off');
}
elseif ($importer->config['import_period'] == 0) {
$import_period = t('as often as possible');
......@@ -327,7 +327,7 @@ function feeds_ui_edit_page($importer, $active = 'help', $plugin_key = '') {
else {
$import_period = t('every !interval', array('!interval' => format_interval($importer->config['import_period'])));
}
$items[] = t('Refresh: !import_period', array('!import_period' => $import_period));
$items[] = t('Periodic import: !import_period', array('!import_period' => $import_period));
$items[] = $importer->config['import_on_create'] ? t('Import on submission') : t('Do not import on submission');
$info['title'] = t('Basic settings');
......
......@@ -115,7 +115,7 @@ class FeedsUIUserInterfaceTestCase extends FeedsWebTestCase {
// Assert results of change.
$this->assertText('Edit importer: Syndication');
$this->assertText('Attached to: Page');
$this->assertText('Refresh: every 1 hour');
$this->assertText('Periodic import: every 1 hour');
$this->drupalGet('admin/structure/feeds');
$this->assertLink('Page'); // See whether string 'Page' shows up in table.
......
......@@ -142,9 +142,12 @@ abstract class FeedsConfigurable {
/**
* Implements getConfig().
*
* Return configuration array, ensure that all default values are present.
*/
public function getConfig() {
return $this->config;
$defaults = $this->configDefaults();
return $this->config + $defaults;
}
/**
......
......@@ -208,7 +208,7 @@ class FeedsImporter extends FeedsConfigurable {
foreach (array('fetcher', 'parser', 'processor') as $type) {
$this->config[$type]['config'] = $this->$type->getConfig();
}
return $this->config;// Collect information from plugins.
return parent::getConfig();
}
/**
......@@ -239,44 +239,51 @@ class FeedsImporter extends FeedsConfigurable {
* Override parent::configForm().
*/
public function configForm(&$form_state) {
$config = $this->getConfig();
$form = array();
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#description' => t('The name of this configuration.'),
'#default_value' => $this->config['name'],
'#description' => t('A human readable name of this importer.'),
'#default_value' => $config['name'],
'#required' => TRUE,
);
$form['description'] = array(
'#type' => 'textfield',
'#title' => t('Description'),
'#description' => t('A description of this configuration.'),
'#default_value' => $this->config['description'],
'#description' => t('A description of this importer.'),
'#default_value' => $config['description'],
);
$node_types = node_type_get_names();
array_walk($node_types, 'check_plain');
$form['content_type'] = array(
'#type' => 'select',
'#title' => t('Attach to content type'),
'#description' => t('If an importer is attached to a content type, content is imported by creating a node. If the standalone form is selected, content is imported by using the standalone form under http://example.com/import.'),
'#description' => t('If "Use standalone form" is selected a source is imported by using a form under !import_form.
If a content type is selected a source is imported by creating a node of that content type.',
array('!import_form' => l(url('import', array('absolute' => TRUE)), 'import', array('attributes' => array('target' => '_new'))))),
'#options' => array('' => t('Use standalone form')) + $node_types,
'#default_value' => $this->config['content_type'],
'#default_value' => $config['content_type'],
);
$cron_required = ' ' . l(t('Requires cron to be configured.'), 'http://drupal.org/cron', array('attributes' => array('target' => '_new')));
$period = drupal_map_assoc(array(0, 900, 1800, 3600, 10800, 21600, 43200, 86400, 259200, 604800, 2419200), 'format_interval');
$period[FEEDS_SCHEDULE_NEVER] = t('Never');
foreach ($period as &$p) {
$p = t('Every !p', array('!p' => $p));
}
$period[FEEDS_SCHEDULE_NEVER] = t('off');
$period[0] = t('As often as possible');
$form['import_period'] = array(
'#type' => 'select',
'#title' => t('Minimum refresh period'),
'#title' => t('Periodic import'),
'#options' => $period,
'#description' => t('This is the minimum time that must elapse before a feed may be refreshed automatically.'),
'#default_value' => $this->config['import_period'],
'#description' => t('Choose how often a source should be imported periodically.') . $cron_required,
'#default_value' => $config['import_period'],
);
$form['import_on_create'] = array(
'#type' => 'checkbox',
'#title' => t('Import on submission'),
'#description' => t('Check if content should be imported at the moment of feed submission.'),
'#default_value' => $this->config['import_on_create'],
'#description' => t('Check if import should be started at the moment of standalone form or node form submission.'),
'#default_value' => $config['import_on_create'],
);
return $form;
}
......
......@@ -126,7 +126,7 @@ class FeedsSchedulerTestCase extends FeedsWebTestCase {
'import_period' => 0,
);
$this->drupalPost('admin/structure/feeds/edit/syndication/settings', $edit, 'Save');
$this->assertText('Refresh: as often as possible');
$this->assertText('Periodic import: as often as possible');
$this->drupalLogout();
// Hit cron once, this should cause Feeds to reschedule all entries.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment