function lingotek_publish_form_submit in Lingotek Translation 7.3
Same name and namespace in other branches
- 7.7 lingotek.page.inc \lingotek_publish_form_submit()
- 7.2 lingotek.page.inc \lingotek_publish_form_submit()
- 7.4 lingotek.page.inc \lingotek_publish_form_submit()
- 7.5 lingotek.page.inc \lingotek_publish_form_submit()
- 7.6 lingotek.page.inc \lingotek_publish_form_submit()
Submit handler for the lingotek_publish_form form. Update the entity_translation module publishing fields
File
- ./
lingotek.page.inc, line 267 - Lingotek Tab for Nodes
Code
function lingotek_publish_form_submit($form, $form_state) {
if (module_exists('entity_translation')) {
$node = lingotek_node_load_default($form_state['values']['node_id']);
$status_request = $form_state['triggering_element']['#id'] == 'publish' ? 1 : 0;
$handler = entity_translation_get_handler('node', $node);
$language_codes = $form_state['values']['languages'];
$languages_updated = array();
$updates = 0;
foreach ($language_codes as $langcode) {
if ($langcode !== 0) {
// set node (source or target as specified) flag (in the entity_translation table) as published or unpublished
$handler
->setTranslation(array(
'language' => $langcode,
'status' => $status_request,
));
$languages_updated[$langcode] = lingotek_language_name($langcode);
$updates++;
}
}
$handler
->saveTranslations();
$publish_status_text = $status_request ? 'published' : 'unpublished';
$languages_updated_html = "<ul><li>" . implode("</li><li>", $languages_updated) . "</li></ul>";
if ($updates > 0) {
drupal_set_message(t('The following languages have been <b><i>@publish_status_text</i></b>: ' . $languages_updated_html, array(
'@publish_status_text' => $publish_status_text,
'@languages_updated_html' => $languages_updated_html,
)));
//'@node_title' => $node->title,
}
else {
drupal_set_message(t('Nothing was changed, since no languages were selected'));
}
}
}