Projet

Général

Profil

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

root / drupal7 / sites / all / modules / webform / components / markup.inc @ ca0757b9

1
<?php
2

    
3
/**
4
 * @file
5
 * Webform module markup component.
6
 */
7

    
8
/**
9
 * Implements _webform_defaults_component().
10
 */
11
function _webform_defaults_markup() {
12
  return array(
13
    'name' => '',
14
    'form_key' => NULL,
15
    'pid' => 0,
16
    'weight' => 0,
17
    'value' => '',
18
    'extra' => array(
19
      'format' => NULL,
20
      'private' => FALSE,
21
    ),
22
  );
23
}
24

    
25
/**
26
 * Implements _webform_edit_component().
27
 */
28
function _webform_edit_markup($component) {
29
  $form = array();
30
  $form['value'] = array(
31
    '#type' => 'text_format',
32
    '#title' => t('Value'),
33
    '#default_value' => $component['value'],
34
    '#description' => t('Markup allows you to enter custom HTML or PHP logic into your form.') . theme('webform_token_help'),
35
    '#weight' => -1,
36
    '#format' => $component['extra']['format'],
37
    '#element_validate' => array('_webform_edit_markup_validate'),
38
  );
39

    
40
  return $form;
41
}
42

    
43
/**
44
 * Element validate handler; Set the text format value.
45
 */
46
function _webform_edit_markup_validate($form, &$form_state) {
47
  if (is_array($form_state['values']['value'])) {
48
    $form_state['values']['extra']['format'] = $form_state['values']['value']['format'];
49
    $form_state['values']['value'] = $form_state['values']['value']['value'];
50
  }
51
}
52

    
53
/**
54
 * Implements _webform_render_component().
55
 */
56
function _webform_render_markup($component, $value = NULL, $filter = TRUE) {
57
  $node = isset($component['nid']) ? node_load($component['nid']) : NULL;
58

    
59
  $element = array(
60
    '#type' => 'markup',
61
    '#title' => $filter ? NULL : $component['name'],
62
    '#weight' => $component['weight'],
63
    '#markup' => $filter ? _webform_filter_values(check_markup($component['value'], $component['extra']['format'], '', TRUE), $node, NULL, NULL, FALSE) : $component['value'],
64
    '#format' => $component['extra']['format'],
65
    '#theme_wrappers' => array('webform_element'),
66
    '#translatable' => array('title', 'markup'),
67
  );
68

    
69
  return $element;
70
}
71

    
72
/**
73
 * Implements _webform_display_component().
74
 */
75
function _webform_display_markup($component, $value, $format = 'html') {
76
  return array();
77
}