diff --git a/feeds.info b/feeds.info index 4c34e2e..c9d2a97 100644 --- a/feeds.info +++ b/feeds.info @@ -34,3 +34,4 @@ files[] = views/feeds_views_handler_field_log_message.inc files[] = views/feeds_views_handler_field_severity.inc files[] = views/feeds_views_handler_field_source.inc files[] = views/feeds_views_handler_filter_severity.inc +files[] = plugins/FeedsEntityProcessor.inc diff --git a/feeds.plugins.inc b/feeds.plugins.inc index 3f23cb8..6a58b75 100644 --- a/feeds.plugins.inc +++ b/feeds.plugins.inc @@ -140,6 +140,19 @@ function _feeds_feeds_plugins() { 'path' => $path, ), ); + if (module_exists('entity')) { + $info['FeedsEntityProcessor'] = array( + 'name' => 'Entity processor', + 'description' => 'Create and update entities.', + 'help' => 'Create and update entites from parsed content.', + 'handler' => array( + 'parent' => 'FeedsProcessor', + 'class' => 'FeedsEntityProcessor', + 'file' => 'FeedsEntityProcessor.inc', + 'path' => $path, + ), + ); + } $info['FeedsUserProcessor'] = array( 'name' => 'User processor', 'description' => 'Create users.', diff --git a/feeds_ui/feeds_ui.admin.inc b/feeds_ui/feeds_ui.admin.inc index 0cef587..c3697ed 100644 --- a/feeds_ui/feeds_ui.admin.inc +++ b/feeds_ui/feeds_ui.admin.inc @@ -430,6 +430,7 @@ function feeds_ui_plugin_form($form, &$form_state, $importer, $type) { $form = array(); $form['#importer'] = $importer->id; $form['#plugin_type'] = $type; + $config = $importer->getConfig(); foreach ($plugins as $key => $plugin) { $form['plugin_key'][$key] = array( @@ -438,7 +439,7 @@ function feeds_ui_plugin_form($form, &$form_state, $importer, $type) { '#title' => check_plain($plugin['name']), '#description' => filter_xss(isset($plugin['help']) ? $plugin['help'] : $plugin['description']), '#return_value' => $key, - '#default_value' => ($plugin['handler']['class'] == get_class($importer->$type)) ? $key : '', + '#default_value' => ($key == $config[$type]['plugin_key']) ? $key : '', ); } $form['submit'] = array( diff --git a/plugins/FeedsProcessor.inc b/plugins/FeedsProcessor.inc index c0e1b60..ad648b9 100755 --- a/plugins/FeedsProcessor.inc +++ b/plugins/FeedsProcessor.inc @@ -422,9 +422,8 @@ abstract class FeedsProcessor extends FeedsPlugin { if (!isset($sources[$this->id])) { $sources[$this->id] = feeds_importer($this->id)->parser->getMappingSources(); } - static $targets; - if (!isset($targets[$this->id])) { - $targets[$this->id] = $this->getMappingTargets(); + if (!isset($this->targets)) { + $this->targets = $this->getMappingTargets(); } $parser = feeds_importer($this->id)->parser; if (empty($target_item)) { @@ -467,11 +466,11 @@ abstract class FeedsProcessor extends FeedsPlugin { } // Map the source element's value to the target. - if (isset($targets[$this->id][$mapping['target']]) && - is_array($targets[$this->id][$mapping['target']]) && - isset($targets[$this->id][$mapping['target']]['callback']) && - function_exists($targets[$this->id][$mapping['target']]['callback'])) { - $callback = $targets[$this->id][$mapping['target']]['callback']; + if (isset($this->targets[$mapping['target']]) && + is_array($this->targets[$mapping['target']]) && + isset($this->targets[$mapping['target']]['callback']) && + function_exists($this->targets[$mapping['target']]['callback'])) { + $callback = $this->targets[$mapping['target']]['callback']; $callback($source, $target_item, $mapping['target'], $value, $mapping); } else { @@ -579,7 +578,7 @@ abstract class FeedsProcessor extends FeedsPlugin { * * @ingroup mappingapi */ - public function setTargetElement(FeedsSource $source, $target_item, $target_element, $value) { + public function setTargetElement(FeedsSource $source, $target_item, $target_element, $value, $mapping) { switch ($target_element) { case 'url': case 'guid':