? text_formats.patch Index: feeds.api.php =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feeds/feeds.api.php,v retrieving revision 1.17.2.2 diff -u -p -r1.17.2.2 feeds.api.php --- feeds.api.php 25 Oct 2010 23:59:31 -0000 1.17.2.2 +++ feeds.api.php 27 Oct 2010 16:42:33 -0000 @@ -205,6 +205,8 @@ function hook_feeds_processor_targets_al /** * Example callback specified in hook_feeds_processor_targets_alter(). * + * @param $source + * Field mapper source settings. * @param $entity * An entity object, for instance a node object. * @param $target @@ -213,7 +215,7 @@ function hook_feeds_processor_targets_al * The value to populate the target with. * */ -function my_module_set_target($entity, $target, $value) { +function my_module_set_target($source, $entity, $target, $value) { $entity->$target['und'][0]['value'] = $value; } Index: mappers/field.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feeds/mappers/field.inc,v retrieving revision 1.1.2.4 diff -u -p -r1.1.2.4 field.inc --- mappers/field.inc 26 Oct 2010 00:01:33 -0000 1.1.2.4 +++ mappers/field.inc 27 Oct 2010 16:42:33 -0000 @@ -36,7 +36,7 @@ function field_feeds_processor_targets_a $callback = 'field_feeds_set_target_numeric'; } if (in_array($info['type'], $string_types)) { - $callback = 'field_feeds_set_target'; + $callback = 'field_feeds_set_target_text'; } if (isset($callback)) { $targets[$name] = array( @@ -53,12 +53,16 @@ function field_feeds_processor_targets_a * * Ensure that $value is a numeric to avoid database errors. */ -function field_feeds_set_target_numeric($entity, $target, $value) { +function field_feeds_set_target_numeric($source, $entity, $target, $value) { if (is_numeric($value)) { - field_feeds_set_target($entity, $target, $value); + field_feeds_set_target($source, $entity, $target, $value, FALSE); } } +function field_feeds_set_target_text($source, $entity, $target, $value) { + field_feeds_set_target($source, $entity, $target, $value, TRUE); +} + /** * Callback for mapping. Here is where the actual mapping happens. * @@ -66,11 +70,17 @@ function field_feeds_set_target_numeric( * user has decided to map to and $value contains the value of the feed item * element the user has picked as a source. */ -function field_feeds_set_target($entity, $target, $value) { +function field_feeds_set_target($source, $entity, $target, $value, $input_format = FALSE) { // Handle non-multiple value fields. if (!is_array($value)) { $value = array($value); } + + if ($input_format) { + if (isset($source->importer->processor->config['input_format'])) { + $format = $source->importer->processor->config['input_format']; + } + } $info = field_info_field($target); @@ -81,6 +91,9 @@ function field_feeds_set_target($entity, if (!is_array($v) && !is_object($v)) { $field['und'][$i]['value'] = $v; } + if ($input_format) { + $field['und'][$i]['format'] = $format; + } if ($info['cardinality'] == 1) { break; } Index: mappers/file.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feeds/mappers/file.inc,v retrieving revision 1.1.2.2 diff -u -p -r1.1.2.2 file.inc --- mappers/file.inc 7 Oct 2010 01:26:03 -0000 1.1.2.2 +++ mappers/file.inc 27 Oct 2010 16:42:33 -0000 @@ -37,7 +37,7 @@ function file_feeds_processor_targets_al * user has decided to map to and $value contains the value of the feed item * element the user has picked as a source. */ -function file_feeds_set_target($entity, $target, $value) { +function file_feeds_set_target($source, $entity, $target, $value) { if (empty($value)) { return; } Index: mappers/taxonomy.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feeds/mappers/taxonomy.inc,v retrieving revision 1.13.2.1 diff -u -p -r1.13.2.1 taxonomy.inc --- mappers/taxonomy.inc 29 Sep 2010 23:56:10 -0000 1.13.2.1 +++ mappers/taxonomy.inc 27 Oct 2010 16:42:33 -0000 @@ -62,7 +62,7 @@ function taxonomy_feeds_processor_target * * @todo Do not create new terms for non-autotag fields. */ -function taxonomy_feeds_set_target($entity, $target, $terms) { +function taxonomy_feeds_set_target($source, $entity, $target, $terms) { if (empty($terms)) { return; } Index: plugins/FeedsNodeProcessor.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feeds/plugins/FeedsNodeProcessor.inc,v retrieving revision 1.69.2.14 diff -u -p -r1.69.2.14 FeedsNodeProcessor.inc --- plugins/FeedsNodeProcessor.inc 22 Oct 2010 18:36:03 -0000 1.69.2.14 +++ plugins/FeedsNodeProcessor.inc 27 Oct 2010 16:42:33 -0000 @@ -6,9 +6,6 @@ * Class definition of FeedsNodeProcessor. */ -// "Use the present default format" -define('FEEDS_NODE_DEFAULT_FORMAT', -1); - /** * Creates nodes from feed items. */ @@ -36,7 +33,6 @@ class FeedsNodeProcessor extends FeedsPr $node = new stdClass(); $node->type = $this->config['content_type']; $node->changed = REQUEST_TIME; - $node->format = ($this->config['input_format'] == FEEDS_NODE_DEFAULT_FORMAT) ? filter_fallback_format() : $this->config['input_format']; $node->created = REQUEST_TIME; node_object_prepare($node); // Populate properties that are set by node_object_prepare(). @@ -125,7 +121,6 @@ class FeedsNodeProcessor extends FeedsPr $type = isset($types['article']) ? 'article' : key($types); return array( 'content_type' => $type, - 'input_format' => FEEDS_NODE_DEFAULT_FORMAT, 'expire' => FEEDS_EXPIRE_NEVER, 'author' => 0, ) + parent::configDefaults(); @@ -145,19 +140,6 @@ class FeedsNodeProcessor extends FeedsPr '#options' => $types, '#default_value' => $this->config['content_type'], ); - $format_options = array(FEEDS_NODE_DEFAULT_FORMAT => t('Default format')); - global $user; - $formats = filter_formats($user); - foreach ($formats as $format) { - $format_options[$format->format] = check_plain($format->name); - } - $form['input_format'] = array( - '#type' => 'select', - '#title' => t('Input format'), - '#description' => t('Select the input format for the body field of the nodes to be created.'), - '#options' => $format_options, - '#default_value' => $this->config['input_format'], - ); $author = user_load($this->config['author']); $form['author'] = array( '#type' => 'textfield', @@ -207,7 +189,7 @@ class FeedsNodeProcessor extends FeedsPr /** * Override setTargetElement to operate on a target item that is a node. */ - public function setTargetElement($target_node, $target_element, $value) { + public function setTargetElement(FeedsSource $source, $target_node, $target_element, $value) { switch ($target_element) { case 'created': $target_node->created = feeds_to_unixtime($value, REQUEST_TIME); @@ -224,7 +206,7 @@ class FeedsNodeProcessor extends FeedsPr } break; default: - parent::setTargetElement($target_node, $target_element, $value); + parent::setTargetElement($source, $target_node, $target_element, $value); break; } } Index: plugins/FeedsProcessor.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feeds/plugins/FeedsProcessor.inc,v retrieving revision 1.20.2.7 diff -u -p -r1.20.2.7 FeedsProcessor.inc --- plugins/FeedsProcessor.inc 26 Oct 2010 03:05:58 -0000 1.20.2.7 +++ plugins/FeedsProcessor.inc 27 Oct 2010 16:42:33 -0000 @@ -384,10 +384,10 @@ abstract class FeedsProcessor extends Fe isset($targets[$this->id][$mapping['target']]['callback']) && function_exists($targets[$this->id][$mapping['target']]['callback'])) { $callback = $targets[$this->id][$mapping['target']]['callback']; - $callback($target_item, $mapping['target'], $value); + $callback($source, $target_item, $mapping['target'], $value); } else { - $this->setTargetElement($target_item, $mapping['target'], $value); + $this->setTargetElement($source, $target_item, $mapping['target'], $value); } } return $target_item; @@ -408,6 +408,7 @@ abstract class FeedsProcessor extends Fe return array( 'mappings' => array(), 'update_existing' => FEEDS_SKIP_EXISTING, + 'input_format' => NULL ); } @@ -429,6 +430,19 @@ abstract class FeedsProcessor extends Fe ), '#default_value' => $this->config['update_existing'], ); + global $user; + $formats = filter_formats($user); + foreach ($formats as $format) { + $format_options[$format->format] = check_plain($format->name); + } + $form['input_format'] = array( + '#type' => 'select', + '#title' => t('Text format'), + '#description' => t('Select the input format for the body field of the nodes to be created.'), + '#options' => $format_options, + '#default_value' => $this->config['input_format'], + '#required' => TRUE, + ); return $form; } @@ -469,7 +483,7 @@ abstract class FeedsProcessor extends Fe * * @ingroup mappingapi */ - public function setTargetElement($target_item, $target_element, $value) { + public function setTargetElement(FeedsSource $source, $target_item, $target_element, $value) { switch ($target_element) { case 'url': case 'guid': Index: plugins/FeedsUserProcessor.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/feeds/plugins/FeedsUserProcessor.inc,v retrieving revision 1.22.2.8 diff -u -p -r1.22.2.8 FeedsUserProcessor.inc --- plugins/FeedsUserProcessor.inc 22 Oct 2010 18:36:03 -0000 1.22.2.8 +++ plugins/FeedsUserProcessor.inc 27 Oct 2010 16:42:33 -0000 @@ -126,13 +126,13 @@ class FeedsUserProcessor extends FeedsPr /** * Override setTargetElement to operate on a target item that is a node. */ - public function setTargetElement($target_user, $target_element, $value) { + public function setTargetElement(FeedsSource $source, $target_user, $target_element, $value) { switch ($target_element) { case 'created': $target_user->created = feeds_to_unixtime($value, REQUEST_TIME); break; default: - parent::setTargetElement($target_user, $target_element, $value); + parent::setTargetElement($source, $target_user, $target_element, $value); break; } }