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