1 |
7b9e8704
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Calculate hash of a feed item.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
$plugin = array(
|
9 |
|
|
'form' => 'feeds_tamper_hash_form',
|
10 |
|
|
'callback' => 'feeds_tamper_hash_callback',
|
11 |
|
|
'name' => 'Calculate hash',
|
12 |
|
|
'multi' => 'direct',
|
13 |
|
|
'category' => 'Other',
|
14 |
|
|
);
|
15 |
|
|
|
16 |
|
|
function feeds_tamper_hash_form($importer, $element_key, $settings) {
|
17 |
|
|
return array(
|
18 |
|
|
'help' => array(
|
19 |
|
|
'#markup' => t('Makes the value a hash of the values being imported. This allows for importing content that does not have a unique ID.'),
|
20 |
|
|
),
|
21 |
|
|
'override' => array(
|
22 |
|
|
'#type' => 'checkbox',
|
23 |
|
|
'#title' => t('Override set value'),
|
24 |
|
|
'#description' => t('If checked, the existing value of this field will be overridden.'),
|
25 |
|
|
'#default_value' => isset($settings['override']) ? $settings['override'] : FALSE,
|
26 |
|
|
),
|
27 |
|
|
);
|
28 |
|
|
}
|
29 |
|
|
|
30 |
|
|
function feeds_tamper_hash_callback($result, $item_key, $element_key, &$field, $settings, $source) {
|
31 |
|
|
if ($settings['override'] || !trim($field)) {
|
32 |
|
|
$field = md5(serialize($result->items[$item_key]));
|
33 |
|
|
}
|
34 |
|
|
} |