Révision ed9a13f1
Ajouté par Assos Assos il y a presque 4 ans
drupal7/sites/all/modules/feeds/mappers/taxonomy.inc | ||
---|---|---|
103 | 103 |
if (!isset($cache['allowed_vocabularies'][$target])) { |
104 | 104 |
foreach ($info['settings']['allowed_values'] as $tree) { |
105 | 105 |
if ($vocabulary = taxonomy_vocabulary_machine_name_load($tree['vocabulary'])) { |
106 |
$cache['allowed_vocabularies'][$target][$vocabulary->vid] = $vocabulary->machine_name; |
|
106 |
$vid = $vocabulary->vid; |
|
107 |
|
|
108 |
$cache['allowed_vocabularies'][$target][$vid] = $vocabulary->machine_name; |
|
109 |
$cache['vocabulary_targets'][$vid][] = $target; |
|
107 | 110 |
} |
108 | 111 |
} |
109 | 112 |
} |
... | ... | |
119 | 122 |
->entityCondition('bundle', $cache['allowed_vocabularies'][$target]) |
120 | 123 |
->range(0, 1); |
121 | 124 |
|
122 |
|
|
123 | 125 |
$field = isset($entity->$target) ? $entity->$target : array($language => array()); |
124 | 126 |
|
125 | 127 |
if (!isset($field[$language])) { |
... | ... | |
160 | 162 |
} |
161 | 163 |
} |
162 | 164 |
elseif ($mapping['autocreate'] && strlen($term)) { |
165 |
$term_vid = key($cache['allowed_vocabularies'][$target]); |
|
163 | 166 |
$term = (object) array( |
164 | 167 |
'name' => drupal_substr($term, 0, 255), |
165 |
'vid' => key($cache['allowed_vocabularies'][$target]),
|
|
168 |
'vid' => $term_vid,
|
|
166 | 169 |
'vocabulary_machine_name' => reset($cache['allowed_vocabularies'][$target]), |
167 | 170 |
); |
168 | 171 |
// Set language if the taxonomy is multilingual. |
... | ... | |
174 | 177 |
} |
175 | 178 |
taxonomy_term_save($term); |
176 | 179 |
$tid = $term->tid; |
180 |
|
|
177 | 181 |
// Add to the list of allowed values. |
178 | 182 |
$cache['allowed_values'][$target][$tid] = $term->name; |
183 |
|
|
184 |
// Invalidate caches for other fields targeting the same vocabulary. |
|
185 |
foreach ($cache['vocabulary_targets'][$term_vid] as $clear_target) { |
|
186 |
if ($clear_target !== $target) { |
|
187 |
unset($cache['allowed_values'][$clear_target]); |
|
188 |
} |
|
189 |
} |
|
179 | 190 |
} |
180 | 191 |
break; |
181 | 192 |
|
... | ... | |
253 | 264 |
* @param string $guid |
254 | 265 |
* The Feeds GUID to compare against. |
255 | 266 |
* |
256 |
* @return int|FALSE
|
|
267 |
* @return int|false
|
|
257 | 268 |
* The term id, or FALSE if one was not found. |
258 | 269 |
*/ |
259 | 270 |
function taxonomy_feeds_term_lookup_term_by_guid($guid) { |
Formats disponibles : Unified diff
Weekly update of contrib modules