webform_handler_field_form_body.inc 987 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * @file
  4. * Views handler to display the content of a webform form.
  5. */
  6. /**
  7. * Field handler to present the Webform form body to the user.
  8. */
  9. class webform_handler_field_form_body extends views_handler_field {
  10. function construct() {
  11. parent::construct();
  12. $this->additional_fields['nid'] = 'nid';
  13. }
  14. function option_definition() {
  15. $options = parent::option_definition();
  16. $options['label'] = array('default' => 'Form', 'translatable' => TRUE);
  17. return $options;
  18. }
  19. function query() {
  20. $this->ensure_my_table();
  21. $this->add_additional_fields();
  22. }
  23. function render($values) {
  24. $node = node_load($values->{$this->aliases['nid']});
  25. if (node_access('view', $node)) {
  26. // Populate $node->content['webform'] by reference.
  27. webform_node_view($node, 'full');
  28. $form_body = isset($node->content['webform']) ? drupal_render($node->content['webform']) : NULL;
  29. }
  30. else {
  31. return;
  32. }
  33. return $form_body;
  34. }
  35. }