You are here

function webform_page_labels in Webform 7.4

Find the label of a given page based on page breaks.

Parameters

object $node: The webform node.

$form_state: The form's state, if available

Return value

array An array of all page labels, indexed by page number.

2 calls to webform_page_labels()
template_preprocess_webform_confirmation in ./webform.module
Prepare for theming of the webform submission confirmation.
webform_client_form in ./webform.module
Client form generation function.

File

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

Code

function webform_page_labels($node, $form_state = array()) {
  $page_count = 1;
  $page_labels = array();
  $page_labels[0] = t($node->webform['progressbar_label_first']);
  foreach ($node->webform['components'] as $component) {
    if ($component['type'] == 'pagebreak') {
      if (module_exists('webform_localization')) {
        module_load_include('inc', 'webform_localization', 'includes/webform_localization.i18n');
        $string = webform_localization_i18n_string_name($component['nid'], $component['cid'], '#title');
        $component['name'] = i18n_string($string, $component['name'], array(
          'update' => TRUE,
          'sanitize' => FALSE,
        ));
      }
      $page_labels[$page_count] = $component['name'];
      $page_count++;
    }
  }
  if ($node->webform['preview'] || !empty($form_state['webform']['preview'])) {
    $page_labels[] = $node->webform['preview_title'] ? t($node->webform['preview_title']) : t('Preview');
  }
  if ($node->webform['progressbar_include_confirmation']) {
    $page_labels[] = t($node->webform['progressbar_label_confirmation']);
  }
  return $page_labels;
}