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

Upgrade use of filter_fallback_format().

parent ca4162c8
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,9 @@ define('FEEDS_NODE_SKIP_EXISTING', 0);
define('FEEDS_NODE_REPLACE_EXISTING', 1);
define('FEEDS_NODE_UPDATE_EXISTING', 2);
// "Use the present default format"
define('FEEDS_NODE_DEFAULT_FORMAT', -1);
/**
* Creates nodes from feed items.
*/
......@@ -145,7 +148,7 @@ class FeedsNodeProcessor extends FeedsProcessor {
$type = isset($types['story']) ? 'story' : key($types);
return array(
'content_type' => $type,
'input_format' => FILTER_FORMAT_DEFAULT,
'input_format' => FEEDS_NODE_DEFAULT_FORMAT,
'update_existing' => FEEDS_SKIP_EXISTING,
'expire' => FEEDS_EXPIRE_NEVER,
'mappings' => array(),
......@@ -167,10 +170,10 @@ class FeedsNodeProcessor extends FeedsProcessor {
'#options' => $types,
'#default_value' => $this->config['content_type'],
);
$format_options = array(FILTER_FORMAT_DEFAULT => t('Default format'));
$format_options = array(FEEDS_NODE_DEFAULT_FORMAT => t('Default format'));
$formats = filter_formats();
foreach ($formats as $format) {
$format_options[$format->format] = $format->name;
$format_options[$format->format] = check_plain($format->name);
}
$form['input_format'] = array(
'#type' => 'select',
......@@ -352,7 +355,7 @@ class FeedsNodeProcessor extends FeedsProcessor {
if ($populate) {
$node->type = $this->config['content_type'];
$node->changed = REQUEST_TIME;
$node->format = $this->config['input_format'];
$node->format = ($this->config['input_format'] == FEEDS_NODE_DEFAULT_FORMAT) ? filter_fallback_format() : $this->config['input_format'];
$node->feeds_node_item = new stdClass();
$node->feeds_node_item->id = $this->id;
$node->feeds_node_item->imported = REQUEST_TIME;
......
......@@ -138,7 +138,7 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase {
// Assert default input format on first imported feed node.
$format = db_query_range("SELECT nr.format FROM {feeds_node_item} fi JOIN {node} n ON fi.nid = n.nid JOIN {node_revisions} nr ON n.vid = nr.vid", 0, 1)->fetchField();
$this->assertEqual($format, FILTER_FORMAT_DEFAULT, 'Using default Input format.');
$this->assertEqual($format, filter_fallback_format(), 'Using default Input format.');
// Import again.
$this->drupalPost('node/'. $nid .'/import', array(), 'Import');
......@@ -201,7 +201,7 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase {
$this->setSettings('syndication', 'FeedsNodeProcessor', array('author' => $author->name));
// Change input format.
$this->setSettings('syndication', 'FeedsNodeProcessor', array('input_format' => FILTER_FORMAT_DEFAULT + 1));
$this->setSettings('syndication', 'FeedsNodeProcessor', array('input_format' => filter_fallback_format() + 1));
// Import again.
$this->drupalPost('node/'. $nid .'/import', array(), 'Import');
......@@ -215,7 +215,7 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase {
// Assert input format.
$format = db_query_range("SELECT nr.format FROM {feeds_node_item} fi JOIN {node} n ON fi.nid = n.nid JOIN {node_revisions} nr ON n.vid = nr.vid", 0, 1)->fetchField();
$this->assertEqual($format, FILTER_FORMAT_DEFAULT + 1, 'Set non-default Input format.');
$this->assertEqual($format, filter_fallback_format() + 1, 'Set non-default Input format.');
// Set to update existing, remove authorship of above nodes and import again.
$this->setSettings('syndication', 'FeedsNodeProcessor', array('update_existing' => 2));
......
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