Projet

Général

Profil

Paste
Télécharger (987 octets) Statistiques
| Branche: | Révision:

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

1
<?php
2

    
3
/**
4
 * @file
5
 * Views handler to display the content of a webform form.
6
 */
7

    
8
/**
9
 * Field handler to present the Webform form body to the user.
10
 */
11
class webform_handler_field_form_body extends views_handler_field {
12
  function construct() {
13
    parent::construct();
14
    $this->additional_fields['nid'] = 'nid';
15
  }
16

    
17
  function option_definition() {
18
    $options = parent::option_definition();
19
    $options['label'] = array('default' => 'Form', 'translatable' => TRUE);
20
    return $options;
21
  }
22

    
23
  function query() {
24
    $this->ensure_my_table();
25
    $this->add_additional_fields();
26
  }
27

    
28
  function render($values) {
29
    $node = node_load($values->{$this->aliases['nid']});
30

    
31
    if (node_access('view', $node)) {
32
      // Populate $node->content['webform'] by reference.
33
      webform_node_view($node, 'form');
34
      $form_body = isset($node->content['webform']) ? drupal_render($node->content['webform']) : NULL;
35
    }
36
    else {
37
      return;
38
    }
39

    
40
    return $form_body;
41
  }
42
}