form.inc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * Plugins are described by creating a $plugin array which will be used
  4. * by the system that includes this file.
  5. */
  6. $plugin = array(
  7. // only provides a single content type
  8. 'single' => TRUE,
  9. 'render last' => TRUE,
  10. 'title' => t('General form'),
  11. 'icon' => 'icon_form.png',
  12. 'description' => t('Everything in the form that is not displayed by other content.'),
  13. 'required context' => new ctools_context_required(t('Form'), 'form'),
  14. 'category' => t('Form'),
  15. );
  16. /**
  17. * Output function for the 'node' content type. Outputs a node
  18. * based on the module and delta supplied in the configuration.
  19. */
  20. function ctools_form_content_type_render($subtype, $conf, $panel_args, &$context) {
  21. $block = new stdClass();
  22. $block->module = 'form';
  23. if (isset($context->form)) {
  24. if (isset($context->form['#pre_render'])) {
  25. foreach ($context->form['#pre_render'] as $function) {
  26. if (function_exists($function)) {
  27. $context->form = $function($context->form);
  28. }
  29. }
  30. unset($context->form['#pre_render']);
  31. }
  32. $block->title = $context->form_title;
  33. $block->content = array();
  34. foreach (element_children($context->form) as $element) {
  35. $block->content[$element] = $context->form[$element];
  36. unset($context->form[$element]);
  37. }
  38. $block->delta = $context->form_id;
  39. }
  40. else {
  41. $block->title = t('Form');
  42. $block->content = t('Form goes here.');
  43. $block->delta = 'unknown';
  44. }
  45. return $block;
  46. }
  47. function ctools_form_content_type_admin_title($subtype, $conf, $context) {
  48. return t('"@s" base form', array('@s' => $context->identifier));
  49. }
  50. function ctools_form_content_type_edit_form($form, &$form_state) {
  51. // provide a blank form so we have a place to override title
  52. // and stuff.
  53. return $form;
  54. }