You are here

function lingotek_advanced_parsing_upgrade_form_submit in Lingotek Translation 7.6

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

Submit handler for the lingotek_advanced_parsing_upgrade_form form.

Parameters

array $form: A FAPI form array.

array $form_state: A FAPI form state array.

File

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

Code

function lingotek_advanced_parsing_upgrade_form_submit($form, $form_state) {
  $error = FALSE;
  if (!empty($form_state['values']['node_id'])) {
    lingotek_keystore('node', $form_state['values']['node_id'], 'use_advanced_parsing', 1);
    $target_node = lingotek_node_load_default($form_state['values']['node_id']);
    if ($target_node->nid) {
      if (LingotekApi::instance()
        ->updateContentDocument(LingotekEntity::load($target_node))) {
        drupal_set_message(t('This node has been upgraded to use advanced content parsing.'));
      }
      else {
        $error = TRUE;
        LingotekLog::error('Error updating node for advanced content parsing. Lingotek updateContentDocument call failed.', array());
      }
    }
    else {
      $error = TRUE;
      LingotekLog::error('Unable to load target node for content parsing upgrade: @node_id', array(
        '@node_id' => $form_state['values']['node_id'],
      ));
    }
  }
  else {
    $error = TRUE;
    LingotekLog::error('No target node ID in parsing upgrade form data.', array());
  }
  if ($error) {
    drupal_set_message(t('There was an error upgrading this node. It has <strong>not</strong> been updated to use advanced parsing.'), 'error');
  }
}