function lingotek_admin_node_translation_settings_form_submit in Lingotek Translation 7.3
Same name and namespace in other branches
- 7.4 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 - Entity translation form
File
- ./
lingotek.admin.inc, line 204
Code
function lingotek_admin_node_translation_settings_form_submit($form, &$form_state) {
$translate = array();
$operations = array();
foreach ($form_state['values'] 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];
$translate[$content_type][] = $content_field;
// Set this content type to be Lingotek translated.
variable_set('language_content_type_' . $content_type, LINGOTEK_ENABLED);
// 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['lingotek_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_'));
// Do the actual title replacement
$entity_type = 'node';
$bundle = $content_type;
$legacy_field = 'title';
// 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[$content_type][] = 'title_field';
$field = field_info_field('title_field');
$field['translatable'] = 1;
$field['lingotek_translatable'] = 1;
// Ensure the title field is flagged for Lingotek translation.
$operations[] = array(
'field_update_field',
array(
$field,
),
);
//field_update_field($field);
}
}
}
}
$_SESSION['lingotek_setup_path'][] = 'admin/config/lingotek/node-translation-settings';
variable_set('lingotek_translate_fields', $translate);
//$setup_complete = variable_get('lingotek_setup_complete', 0);
$setup_complete = lingotek_setup_check_credentials();
if (count($operations)) {
$batch = array(
'title' => t('Preparing content for translation'),
'operations' => $operations,
);
batch_set($batch);
//if (!variable_get('lingotek_setup_complete', 0)) {
if (!$setup_complete) {
$redirect = 'admin/config/lingotek/additional-translation-settings';
}
else {
$redirect = LINGOTEK_MENU_LANG_BASE_URL . '/settings';
}
if ($setup_complete) {
drupal_set_message(t('Your account status has been updated.'));
}
batch_process($redirect);
}
else {
if ($setup_complete) {
drupal_set_message(t('Your account status has been updated.'));
}
}
}