summaryrefslogtreecommitdiff
path: root/sites/all/modules/ctools/plugins/content_types/form/form.inc
blob: 73f7c780166e3afa0850b351bc91681d1457a027 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php

/**
 * Plugins are described by creating a $plugin array which will be used
 * by the system that includes this file.
 */
$plugin = array(
  // only provides a single content type
  'single' => TRUE,
  'render last' => TRUE,
  'title' => t('General form'),
  'icon' => 'icon_form.png',
  'description' => t('Everything in the form that is not displayed by other content.'),
  'required context' => new ctools_context_required(t('Form'), 'form'),
  'category' => t('Form'),
);

/**
 * Output function for the 'node' content type. Outputs a node
 * based on the module and delta supplied in the configuration.
 */
function ctools_form_content_type_render($subtype, $conf, $panel_args, &$context) {
  $block = new stdClass();
  $block->module = 'form';

  if (isset($context->form)) {
    if (isset($context->form['#pre_render'])) {
      foreach ($context->form['#pre_render'] as $function) {
        if (function_exists($function)) {
          $context->form = $function($context->form);
        }
      }
      unset($context->form['#pre_render']);
    }

    $block->title = $context->form_title;
    $block->content = array();
    foreach (element_children($context->form) as $element) {
      $block->content[$element] = $context->form[$element];
      unset($context->form[$element]);
    }

    $block->delta = $context->form_id;
  }
  else {
    $block->title = t('Form');
    $block->content = t('Form goes here.');
    $block->delta   = 'unknown';
  }

  return $block;
}

function ctools_form_content_type_admin_title($subtype, $conf, $context) {
  return t('"@s" base form', array('@s' => $context->identifier));
}

function ctools_form_content_type_edit_form($form, &$form_state) {
  // provide a blank form so we have a place to override title
  // and stuff.
  return $form;
}