diff --git a/plugins/hash.inc b/plugins/hash.inc index 98e73de..ff76a37 100644 --- a/plugins/hash.inc +++ b/plugins/hash.inc @@ -16,19 +16,29 @@ $plugin = array( function feeds_tamper_hash_form($importer, $element_key, $settings) { return array( 'help' => array( - '#markup' => t('Makes the value a hash of the values being imported. This allows for importing content that does not have a unique ID.'), + '#markup' => t('Helps importing content that does not have a unique ID.'), ), 'override' => array( '#type' => 'checkbox', '#title' => t('Override set value'), - '#description' => t('If checked, the existing value of this field will be overridden.'), + '#description' => t('If checked, the current value will always be overriden (Not only when it is empty)'), '#default_value' => isset($settings['override']) ? $settings['override'] : FALSE, ), + 'hash_option' => array( + '#type' => 'radios', + '#title' => t('Hashing Rule'), + '#options' => array( 1 => t('Convert to hash all the values of the feed item'), 2 => t('Convert to hash only the current value')), + '#default_value' => isset($settings['hash_option']) ? $settings['hash_option'] : 1, + ), ); } function feeds_tamper_hash_callback($result, $item_key, $element_key, &$field, $settings, $source) { if ($settings['override'] || !trim($field)) { - $field = md5(serialize($result->items[$item_key])); + if (isset($settings['hash_option']) && $settings['hash_option'] == 2 ){ + $field = md5(serialize($field)); + }else{ + $field = md5(serialize($result->items[$item_key])); + } } }