Projet

Général

Profil

Paste
Télécharger (1,04 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / webform / views / webform_handler_field_form_body.inc @ 01f36513

1
<?php
2

    
3
/**
4
 * Views handler to display the content of a webform form.
5
 *
6
 * Field handler to present the Webform form body to the user.
7
 */
8
class webform_handler_field_form_body extends views_handler_field {
9

    
10
  /**
11
   *
12
   */
13
  public function construct() {
14
    parent::construct();
15
    $this->additional_fields['nid'] = 'nid';
16
  }
17

    
18
  /**
19
   *
20
   */
21
  public function option_definition() {
22
    $options = parent::option_definition();
23
    $options['label'] = array('default' => 'Form', 'translatable' => TRUE);
24
    return $options;
25
  }
26

    
27
  /**
28
   *
29
   */
30
  public function query() {
31
    $this->ensure_my_table();
32
    $this->add_additional_fields();
33
  }
34

    
35
  /**
36
   *
37
   */
38
  public function render($values) {
39
    $node = node_load($values->{$this->aliases['nid']});
40

    
41
    if (node_access('view', $node)) {
42
      // Populate $node->content['webform'] by reference.
43
      webform_node_view($node, 'form');
44
      $form_body = isset($node->content['webform']) ? drupal_render($node->content['webform']) : NULL;
45
    }
46
    else {
47
      return;
48
    }
49

    
50
    return $form_body;
51
  }
52

    
53
}