function webform_localization_webform_component_insert in Webform Localization 7.4
Same name and namespace in other branches
- 7 webform_localization.module \webform_localization_webform_component_insert()
Implements hook_webform_component_insert().
File
- ./
webform_localization.module, line 155 - Webform localization module.
Code
function webform_localization_webform_component_insert($component) {
// Gets webform localization options that match this node ID.
$wl_options = webform_localization_get_config($component['nid']);
// Create translation source for i18n_string for all the translatable
// properties.
if ($wl_options['expose_strings']) {
module_load_include('inc', 'webform_localization', 'includes/webform_localization.i18n');
webform_localization_component_update_translation_strings($component);
$component['extra'] = serialize($component['extra']);
drupal_write_record('webform_component', $component, array(
'nid',
'cid',
));
}
if ($wl_options['sync_components'] && _webform_localization_sync()) {
if (!module_exists('translation')) {
// Enable the translation module as it is needed for localization sync.
module_enable('translation');
}
// Turn Off Sync.
_webform_localization_sync(FALSE);
// Get all versions of the node.
$node = node_load($component['nid']);
$translations = translation_node_get_translations($node->tnid);
if ($translations) {
unset($translations[$node->language]);
foreach ($translations as $trans_c) {
$new_component = $component;
$new_component['nid'] = $trans_c->nid;
webform_component_insert($new_component);
}
}
// Turn On Sync.
_webform_localization_sync(TRUE);
}
}