Projet

Général

Profil

Paste
Télécharger (2,52 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / webform / components / pagebreak.inc @ 651307cd

1 85ad3d82 Assos Assos
<?php
2
3
/**
4
 * @file
5
 * Webform module page break component.
6
 */
7
8
/**
9
 * Implements _webform_defaults_component().
10
 */
11
function _webform_defaults_pagebreak() {
12
  return array(
13
    'name' => '',
14
    'form_key' => NULL,
15
    'pid' => 0,
16
    'weight' => 0,
17
    'extra' => array(
18
      'private' => FALSE,
19
      'next_page_label' => '',
20
      'prev_page_label' => '',
21
    ),
22
  );
23
}
24
25
/**
26
 * Implements _webform_theme_component().
27
 */
28
function _webform_theme_pagebreak() {
29
  return array(
30
    'webform_display_pagebreak' => array(
31
      'render element' => 'element',
32
      'file' => 'components/pagebreak.inc',
33
    ),
34
  );
35
}
36
37
/**
38
 * Implements _webform_edit_component().
39
 */
40
function _webform_edit_pagebreak($component) {
41
  $form = array();
42
  // Force the parent to always be root.
43
  $form['position']['pid'] = array(
44
    '#type' => 'hidden',
45
    '#value' => '0',
46
  );
47
48
  $form['extra']['next_page_label'] = array(
49
    '#type' => 'textfield',
50
    '#title' => t('Next page button label'),
51
    '#description' => t('This is used for the <em>Next Page</em> button on the page before this page break. Default: <em>Next Page &gt;</em>'),
52
    '#default_value' => $component['extra']['next_page_label'],
53
    '#size' => 30,
54
  );
55
  $form['extra']['prev_page_label'] = array(
56
    '#type' => 'textfield',
57 a45e4bc1 Assos Assos
    '#title' => t('Previous page button label'),
58
    '#description' => t('This is used for the <em>Previous Page</em> button on the page after this page break. Default: <em>&lt; Prev Page</em>'),
59 85ad3d82 Assos Assos
    '#default_value' => $component['extra']['prev_page_label'],
60
    '#size' => 30,
61
  );
62
63
  return $form;
64
}
65
66
/**
67
 * Implements _webform_render_component().
68
 */
69 a45e4bc1 Assos Assos
function _webform_render_pagebreak($component, $value = NULL, $filter = TRUE, $submission = NULL) {
70 85ad3d82 Assos Assos
  $element = array(
71
    '#type' => 'hidden',
72
    '#value' => $component['name'],
73
    '#weight' => $component['weight'],
74
  );
75
  return $element;
76
}
77
78
/**
79 a45e4bc1 Assos Assos
 * Implements _webform_display_component().
80 85ad3d82 Assos Assos
 */
81 a45e4bc1 Assos Assos
function _webform_display_pagebreak($component, $value = NULL, $format = 'html', $submission = array()) {
82 85ad3d82 Assos Assos
  $element = array(
83
    '#theme' => 'webform_display_pagebreak',
84
    '#title' => $component['name'],
85
    '#weight' => $component['weight'],
86
    '#format' => $format,
87
    '#translatable' => array('title'),
88
  );
89
  return $element;
90
}
91
92
/**
93
 * Format the text output data for this component.
94
 */
95
function theme_webform_display_pagebreak($variables) {
96
  $element = $variables['element'];
97
98 a45e4bc1 Assos Assos
  return $element['#format'] == 'html' ? '<h2 class="webform-page">' . check_plain($element['#title']) . '</h2>' : '==' . $element['#title'] . "==\n";
99 85ad3d82 Assos Assos
}