function lingotek_admin_node_translation_settings_form_submit in Lingotek Translation 7.4
Same name and namespace in other branches
- 7.3 lingotek.admin.inc \lingotek_admin_node_translation_settings_form_submit()
Node Translation Settings - Form Submit
1 call to lingotek_admin_node_translation_settings_form_submit()
- lingotek_setup_node_translation_settings_form_submit in ./
lingotek.setup.inc - Node Translation Settings - Form Submit
1 string reference to 'lingotek_admin_node_translation_settings_form_submit'
- lingotek_admin_node_translation_settings_form in ./
lingotek.admin.inc - Content translation form
File
- ./
lingotek.admin.inc, line 265
Code
function lingotek_admin_node_translation_settings_form_submit($form, &$form_state) {
$entity_type = $form_state['input']['entity_type'];
if (isset($form_state['values']['lingotek_nodes_translation_method'])) {
variable_set('lingotek_nodes_translation_method', $form_state['values']['lingotek_nodes_translation_method']);
}
$translate = variable_get('lingotek_enabled_fields', array());
unset($translate[$entity_type]);
$operations = array();
$entity_profiles = variable_get('lingotek_entity_profiles', array());
foreach ($form_state['input'] as $key => $value) {
// Look for Selected Content Types and Fields.
if (FALSE !== strpos($key, '_SEPERATOR_')) {
// And only if set to translate
if ($value != 0) {
$parts = explode('_SEPERATOR_', $key);
$content_type = $parts[0];
$content_field = $parts[1];
//check to make sure that the content type is enabled
if ($form_state['input']['profile_' . $content_type] != LingotekSync::PROFILE_DISABLED) {
$translate[$entity_type][$content_type][] = $content_field;
// Set this content type to be Lingotek translated.
variable_set('language_content_type_' . $content_type, '1');
// Set this field to 'translatable'.
// Update the field via the Field API (Instead of the direct db_update)
$field = field_info_field($content_field);
$field['translatable'] = 1;
field_update_field($field);
}
}
}
// END: Selected Content Types and Fields
// Look for any nodes we need to do the Title swap for.
if (FALSE !== strpos($key, 'title_swap_')) {
// And only if set to swap
if ($value != 0) {
$content_type = substr($key, strlen('title_swap_'));
//check to make sure that the content type is enabled
if ($form_state['input']['profile_' . $content_type] != LingotekSync::PROFILE_DISABLED) {
// Do the actual title replacement
$bundle = $content_type;
$legacy_field = $entity_type == 'node' ? 'title' : 'subject';
// Use the Title module to migrate the content.
if (title_field_replacement_toggle($entity_type, $bundle, $legacy_field)) {
//title_field_replacement_batch_set($title_entity, $title_bundle, $title_field);
$operations[] = array(
'title_field_replacement_batch',
array(
$entity_type,
$bundle,
$legacy_field,
),
);
$translate[$entity_type][$content_type][] = $legacy_field . '_field';
$field = field_info_field($legacy_field . '_field');
$field['translatable'] = 1;
$operations[] = array(
'field_update_field',
array(
$field,
),
);
//field_update_field($field);
}
}
}
}
// Look for any profiles
if (FALSE !== strpos($key, 'profile_')) {
$content_type = substr($key, strlen('profile_'));
$entity_profiles[$entity_type][$content_type] = $value;
}
}
$_SESSION['lingotek_setup_path'][] = 'admin/config/lingotek/node-translation-settings';
variable_set('lingotek_enabled_fields', $translate);
variable_set('lingotek_entity_profiles', $entity_profiles);
drupal_set_message(t('Your content types have been updated.'));
if (count($operations)) {
$batch = array(
'title' => t('Preparing content for translation'),
'operations' => $operations,
);
batch_set($batch);
if (is_null(variable_get('lingotek_translate_comments', NULL)) || is_null(variable_get('lingotek_translate_config', NULL))) {
$redirect = 'admin/config/lingotek/comment-translation-settings';
}
else {
$redirect = LINGOTEK_MENU_LANG_BASE_URL . '/settings';
}
batch_process($redirect);
}
}