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

#647222 cglusky, jeffschuler: Specify input format for feed items.

parent 5068fa50
No related branches found
No related tags found
No related merge requests found
// $Id$
Feeds 6.x 1.X XXXX
------------------
- #647222 cglusky, jeffschuler: Specify input format for feed items.
Feeds 6.x 1.0 Beta 2, 2010-07-10
--------------------------------
......
......@@ -147,6 +147,7 @@ class FeedsNodeProcessor extends FeedsProcessor {
$type = isset($types['story']) ? 'story' : key($types);
return array(
'content_type' => $type,
'input_format' => FILTER_FORMAT_DEFAULT,
'update_existing' => FEEDS_NODE_SKIP_EXISTING,
'expire' => FEEDS_EXPIRE_NEVER,
'mappings' => array(),
......@@ -167,6 +168,18 @@ class FeedsNodeProcessor extends FeedsProcessor {
'#options' => $types,
'#default_value' => $this->config['content_type'],
);
$format_options = array(FILTER_FORMAT_DEFAULT => t('Default format'));
$formats = filter_formats();
foreach ($formats as $format) {
$format_options[$format->format] = $format->name;
}
$form['input_format'] = array(
'#type' => 'select',
'#title' => t('Input format'),
'#description' => t('Choose the input format of the body field of created nodes.'),
'#options' => $format_options,
'#default_value' => $this->config['input_format'],
);
$author = user_load(array('uid' => $this->config['author']));
$form['author'] = array(
'#type' => 'textfield',
......@@ -318,6 +331,7 @@ class FeedsNodeProcessor extends FeedsProcessor {
if ($populate) {
$node->type = $this->config['content_type'];
$node->changed = FEEDS_REQUEST_TIME;
$node->format = $this->config['input_format'];
$node->feeds_node_item = new stdClass();
$node->feeds_node_item->id = $this->id;
$node->feeds_node_item->imported = FEEDS_REQUEST_TIME;
......
......@@ -136,6 +136,10 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase {
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item}"));
$this->assertEqual($count, 10, 'Accurate number of items in database.');
// Assert default input format on first imported feed node.
$format = db_result(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));
$this->assertEqual($format, FILTER_FORMAT_DEFAULT, 'Using default Input format.');
// Import again.
$this->drupalPost('node/'. $nid .'/import', array(), 'Import');
$this->assertText('There is no new content.');
......@@ -173,9 +177,14 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase {
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item}"));
$this->assertEqual($count, 0, 'Accurate number of items in database.');
// Change author, import again.
// Change author.
$author = $this->drupalCreateUser();
$this->setSettings('syndication', 'FeedsNodeProcessor', array('author' => $author->name));
// Change input format.
$this->setSettings('syndication', 'FeedsNodeProcessor', array('input_format' => FILTER_FORMAT_DEFAULT + 1));
// Import again.
$this->drupalPost('node/'. $nid .'/import', array(), 'Import');
$this->assertText('Created 10 Story nodes.');
......@@ -185,6 +194,10 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase {
$count = db_result(db_query("SELECT COUNT(*) FROM {feeds_node_item} fi JOIN {node} n ON fi.nid = n.nid WHERE n.uid = %d", $author->uid));
$this->assertEqual($count, 10, 'Accurate number of items in database.');
// Assert input format.
$format = db_result(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));
$this->assertEqual($format, FILTER_FORMAT_DEFAULT + 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));
db_query("UPDATE {node} n JOIN {feeds_node_item} fi ON n.nid = fi.nid SET n.uid = 0, fi.hash=''");
......
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