--- comment.inc +++ comment.inc @@ -0,0 +1,51 @@ + t('Comments'), + 'description' => t('Whether comments are allowed on this node: 0 = no, 1 = read only, 2 = read/write.'), + 'callback' => 'comment_feeds_get_source', + ); + } +} + +/** + * Callback, returns specific comment settings of the parent feed node. + */ +function comment_feeds_get_source(FeedsImportBatch $batch, $key) { + if ($node = $batch->feedNode()) { + return $node->comment; + } +} + +/** + * Implements hook_feeds_node_processor_targets_alter(). + */ +function comment_feeds_node_processor_targets_alter(&$targets, $content_type) { + $targets['comment'] = array( + 'name' => t('Comments'), + 'callback' => 'comment_feeds_set_target', + 'description' => t('Whether comments are allowed on this node: 0 = no, 1 = read only, 2 = read/write.'), + ); +} + +/** + * Callback for mapping. + */ +function comment_feeds_set_target($node, $key, $comment) { + $node->comment = $comment; +} --- translation.inc +++ translation.inc @@ -0,0 +1,79 @@ + t('Translation node ID'), + 'description' => t('The translation set id for this node, which equals the node id of the source post in each set.'), + 'callback' => 'translation_feeds_get_source_tnid', + ); + $sources['parent:translate'] = array( + 'name' => t('Translation status'), + 'description' => t('Whether this translation page needs to be updated or not. 0 = no, 1 = yes.'), + 'callback' => 'translation_feeds_get_source_translate', + ); + } +} + +/** + * Callback, returns specific tnid settings of the parent feed node. + */ +function translation_feeds_get_source_tnid(FeedsImportBatch $batch, $key) { + if ($node = $batch->feedNode()) { + return $node->tnid; + } +} + +/** + * Callback, returns specific translate settings of the parent feed node. + */ +function translation_feeds_get_source_translate(FeedsImportBatch $batch, $key) { + if ($node = $batch->feedNode()) { + return $node->translate; + } +} + +/** + * Implements hook_feeds_node_processor_targets_alter(). + */ +function translation_feeds_node_processor_targets_alter(&$targets, $content_type) { + if (TRANSLATION_ENABLED == variable_get('language_content_type_'. $content_type, FALSE)) { + $targets['tnid'] = array( + 'name' => t('Translation node ID'), + 'callback' => 'translation_feeds_set_target_tnid', + 'description' => t('The translation set id for this node, which equals the node id of the source post in each set.'), + ); + $targets['translate'] = array( + 'name' => t('Translation status'), + 'callback' => 'translation_feeds_set_target_tnid', + 'description' => t('Whether this translation page needs to be updated or not. 0 = no, 1 = yes.'), + ); + } +} + +/** + * Callback for mapping. + */ +function translation_feeds_set_target_tnid($node, $key, $tnid) { + $node->tnid = $tnid; +} + +/** + * Callback for mapping. + */ +function translation_feeds_set_target_translate($node, $key, $translate) { + $node->translate = $translate; +}