You are here

function template_preprocess_webform_confirmation in Webform 7.4

Same name and namespace in other branches
  1. 8.5 includes/webform.theme.template.inc \template_preprocess_webform_confirmation()
  2. 6.3 webform.module \template_preprocess_webform_confirmation()
  3. 6.2 webform.module \template_preprocess_webform_confirmation()
  4. 7.3 webform.module \template_preprocess_webform_confirmation()
  5. 6.x includes/webform.theme.template.inc \template_preprocess_webform_confirmation()

Prepare for theming of the webform submission confirmation.

File

./webform.module, line 3594
This module provides a simple way to create forms and questionnaires.

Code

function template_preprocess_webform_confirmation(&$vars) {
  $node = $vars['node'];

  // Strip out empty tags added by WYSIWYG editors if needed.
  $confirmation = $node->webform['confirmation'];
  $confirmation = strlen(trim(strip_tags($confirmation))) ? $confirmation : '';

  // Replace tokens.
  module_load_include('inc', 'webform', 'includes/webform.submissions');
  $submission = webform_get_submission($node->nid, $vars['sid']);
  $vars['confirmation_message'] = webform_replace_tokens($confirmation, $node, $submission, NULL, $node->webform['confirmation_format']);

  // URL back to form (or same page for in-block confirmations).
  $vars['url'] = empty($node->webform_block) ? url('node/' . $node->nid) : url(current_path(), array(
    'query' => drupal_get_query_parameters(),
  ));

  // Progress bar.
  $vars['progressbar'] = '';
  if ($node->webform['progressbar_include_confirmation']) {
    $page_labels = webform_page_labels($node);
    $page_count = count($page_labels);
    $vars['progressbar'] = theme('webform_progressbar', array(
      'node' => $node,
      'page_num' => $page_count,
      'page_count' => $page_count,
      'page_labels' => $page_labels,
    ));
  }
}