--- FeedsNodeProcessor - Copy.inc Thu Nov 26 09:02:16 2009 +++ FeedsNodeProcessor.inc Tue Dec 01 15:43:56 2009 @@ -37,35 +37,16 @@ class FeedsNodeProcessor extends FeedsPr $node->nid = $nid; $node->vid = db_result(db_query('SELECT vid FROM {node} WHERE nid = %d', $nid)); } - - if (module_exists('taxonomy')){ - //Find out what term(s) the parent node uses - - //$terms = db_query('SELECT tid FROM {term_node} WHERE nid = %d AND vid=%d', $source->feed_nid,$src_vid); - //taxonomy_node_get_terms only works if we have VID set, so set it in the source. - $source->vid = db_result(db_query('SELECT vid FROM {node} WHERE nid = %d', $source->feed_nid)); - $terms = taxonomy_node_get_terms($source); - - foreach ($terms as $tid => $term) { - $vid = $term->vid; - $vocabulary = taxonomy_vocabulary_load($vid); - if ($vocabulary->multiple) { - if (!(isset($item_node->taxonomy[$vid]) && is_array($item_node->taxonomy[$vid]))) { - $node->taxonomy[$vid] = array(); - } - if (!in_array($tid, $node->taxonomy[$vid])) { - $node->taxonomy[$vid][$tid] = $tid; - } - } - else { - if (!$node->taxonomy[$vid]) { - $node->taxonomy[$vid] = $tid; - } - } - } - } - - // Save the node. + + if ($this->config['taxonomy_inheritance'] && module_exists('taxonomy')){ + //Find out what term(s) the parent node uses + //Use node_load to get the parent information (see http://api.drupal.org/api/function/node_load/6). + $feed_node = node_load($source->feed_nid); + //Set node to use the same taxonomy term(s) as it's parent + $node->taxonomy = $feed_node->taxonomy; + } + + // Save the node. node_save($node); if ($nid) { @@ -174,6 +155,7 @@ class FeedsNodeProcessor extends FeedsPr return array( 'content_type' => $type, // @todo: provide default content type feed_item. 'update_existing' => 0, + 'taxonomy_inheritance' => 0, 'expire' => FEEDS_EXPIRE_NEVER, 'mappings' => array(), ); @@ -198,6 +180,12 @@ class FeedsNodeProcessor extends FeedsPr '#description' => t('Check if existing items should be updated from the feed.'), '#default_value' => $this->config['update_existing'], ); + $form['taxonomy_inheritance'] = array( + '#type' => 'checkbox', + '#title' => t('Taxonomy Inheritance'), + '#description' => t('Nodes inherit taxonomy terms from Feed Node.'), + '#default_value' => $this->config['taxonomy_inheritance'], + ); $period = drupal_map_assoc(array(FEEDS_EXPIRE_NEVER, 3600, 10800, 21600, 43200, 86400, 259200, 604800, 604800 * 4, 604800 * 12, 604800 * 24, 31536000), 'feeds_format_expire'); $form['expire'] = array( '#type' => 'select', @@ -309,7 +297,7 @@ class FeedsNodeProcessor extends FeedsPr $files = drupal_system_listing('.*\.inc$', $path, 'name', 0); foreach ($files as $file) { if (strstr($file->filename, '/mappers/')) { - require_once("./$file->filename"); + require_once("./$file->filename"); } } // Rebuild cache.