markup.inc 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * @file
  4. * Webform module markup component.
  5. */
  6. /**
  7. * Implements _webform_defaults_component().
  8. */
  9. function _webform_defaults_markup() {
  10. return array(
  11. 'name' => '',
  12. 'form_key' => NULL,
  13. 'pid' => 0,
  14. 'weight' => 0,
  15. 'value' => '',
  16. 'extra' => array(
  17. 'format' => NULL,
  18. 'private' => FALSE,
  19. ),
  20. );
  21. }
  22. /**
  23. * Implements _webform_edit_component().
  24. */
  25. function _webform_edit_markup($component) {
  26. $form = array();
  27. $form['value'] = array(
  28. '#type' => 'text_format',
  29. '#title' => t('Value'),
  30. '#default_value' => $component['value'],
  31. '#description' => t('Markup allows you to enter custom HTML or PHP logic into your form.') . theme('webform_token_help'),
  32. '#weight' => -1,
  33. '#format' => $component['extra']['format'],
  34. '#element_validate' => array('_webform_edit_markup_validate'),
  35. );
  36. return $form;
  37. }
  38. /**
  39. * Element validate handler; Set the text format value.
  40. */
  41. function _webform_edit_markup_validate($form, &$form_state) {
  42. if (is_array($form_state['values']['value'])) {
  43. $form_state['values']['extra']['format'] = $form_state['values']['value']['format'];
  44. $form_state['values']['value'] = $form_state['values']['value']['value'];
  45. }
  46. }
  47. /**
  48. * Implements _webform_render_component().
  49. */
  50. function _webform_render_markup($component, $value = NULL, $filter = TRUE) {
  51. $node = isset($component['nid']) ? node_load($component['nid']) : NULL;
  52. $element = array(
  53. '#type' => 'markup',
  54. '#title' => $filter ? NULL : $component['name'],
  55. '#weight' => $component['weight'],
  56. '#markup' => $filter ? _webform_filter_values(check_markup($component['value'], $component['extra']['format'], '', TRUE), $node, NULL, NULL, FALSE) : $component['value'],
  57. '#format' => $component['extra']['format'],
  58. '#theme_wrappers' => array('webform_element'),
  59. '#translatable' => array('title', 'markup'),
  60. );
  61. return $element;
  62. }
  63. /**
  64. * Implements _webform_display_component().
  65. */
  66. function _webform_display_markup($component, $value, $format = 'html') {
  67. return array();
  68. }