You are here

function lingotek_download_translations_form_submit in Lingotek Translation 7.6

Same name and namespace in other branches
  1. 7.7 lingotek.page.inc \lingotek_download_translations_form_submit()
  2. 7.3 lingotek.page.inc \lingotek_download_translations_form_submit()
  3. 7.4 lingotek.page.inc \lingotek_download_translations_form_submit()
  4. 7.5 lingotek.page.inc \lingotek_download_translations_form_submit()

Download Translations Form Submit

File

./lingotek.page.inc, line 105
Lingotek Tab for Nodes

Code

function lingotek_download_translations_form_submit($form, $form_state) {
  $nid = $form_state['values']['nid'];

  // clear any caching from entitycache module
  if (module_exists('entitycache')) {
    cache_clear_all($nid, 'cache_entity_node');
  }
  $document_id = lingotek_keystore('node', $nid, 'document_id');
  $locales = array();
  $download_targets = array();
  foreach ($form_state['values']['documents'] as $locale => $selected) {
    if ($selected) {
      $locales[] = $locale;
      $download_targets[] = (object) array(
        'document_id' => $document_id,
        'locale' => $locale,
      );
    }
  }
  $extra_operations = array();
  lingotek_sync_batch_create(array(), $download_targets, array(), 'node/' . $form_state['values']['nid'] . '/lingotek_pm', $extra_operations);
  drupal_set_message(t('Updated local translations for the selected languages: @selected_locales', array(
    '@selected_locales' => implode(", ", $locales),
  )));
  cache_clear_all('field:node:' . $form_state['values']['nid'], 'cache_field');
}