function lingotek_field_language_data_cleanup_update_node in Lingotek Translation 7.3
Same name and namespace in other branches
- 7.2 lingotek.batch.inc \lingotek_field_language_data_cleanup_update_node()
- 7.4 lingotek.batch.inc \lingotek_field_language_data_cleanup_update_node()
Ensures correct language-specific field data for the specified item.
Logic: Look at each translatable_node_field (Any field marked for lingotek translation management) for the given node. If the field has data in the language 'und' area, and is empty in the language area that this node is, copy the data over. So if this node is marked as English, but there is no data in the English language spots, but there IS in the 'und' spots, move the data to the English locations.
Parameters
int $nid: The node ID of the item to be updated.
Return value
bool TRUE if the specified node's field data was updated. FALSE if no changes were made.
1 call to lingotek_field_language_data_cleanup_update_node()
- lingotek_field_language_data_cleanup_batch_worker in ./
lingotek.batch.inc - Batch API processor for field data language updates.
File
- ./
lingotek.batch.inc, line 593 - Central location for batch create functions, before control is handed off to individual batch command files.
Code
function lingotek_field_language_data_cleanup_update_node($nid) {
$edited = FALSE;
$node = lingotek_node_load_default($nid, NULL, TRUE);
if ($node->nid) {
if ($node->language != 'und') {
$translatable_fields = lingotek_translatable_node_fields();
foreach ($translatable_fields as $field_name) {
if (!empty($node->{$field_name}['und']) && empty($node->{$field_name}[$node->language])) {
$node->{$field_name}[$node->language] = $node->{$field_name}['und'];
$edited = TRUE;
}
}
}
if ($edited) {
$node->lingotek_upload_override = 0;
node_save($node);
}
}
else {
LingotekLog::error('Attempted to update field data for a non-existent node: @node_id', array(
'@node_id' => $node->nid,
));
}
return $edited;
}