You are here

function webform_localization_preprocess_webform_confirmation in Webform Localization 7.4

Same name and namespace in other branches
  1. 7 webform_localization.module \webform_localization_preprocess_webform_confirmation()

Translate webform confirmation field.

File

./webform_localization.module, line 1058
Webform localization module.

Code

function webform_localization_preprocess_webform_confirmation(&$vars) {
  if (empty($vars['node']->tnid)) {
    return;
  }

  // Select all webforms that match the localization configuration.
  $query = db_select('webform', 'w');
  $query
    ->innerJoin('webform_localization', 'wl', 'w.nid = wl.nid');
  $query
    ->fields('w', array(
    'nid',
  ));
  $query
    ->condition('wl.single_webform', $vars['node']->tnid, '=');
  $query
    ->condition('w.nid', $vars['node']->nid, '<>');
  $result = $query
    ->execute()
    ->fetchField();
  if ($result) {
    $source_node = node_load($result);

    // We replace the webform with the node translation source.
    $vars['node']->webform = $source_node->webform;
  }
  else {
    return;
  }
  $confirmation = check_markup($vars['node']->webform['confirmation'], $vars['node']->webform['confirmation_format'], '', TRUE);

  // Strip out empty tags added by WYSIWYG editors if needed.
  $vars['confirmation_message'] = drupal_strlen(trim(strip_tags($confirmation))) ? $confirmation : '';
}