1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* "No context" sample content type. It operates with no context at all. It would
|
6 |
|
|
* be basically the same as a 'custom content' block, but it's not even that
|
7 |
|
|
* sophisticated.
|
8 |
|
|
*
|
9 |
|
|
*/
|
10 |
|
|
|
11 |
|
|
/**
|
12 |
|
|
* Plugins are described by creating a $plugin array which will be used
|
13 |
|
|
* by the system that includes this file.
|
14 |
|
|
*/
|
15 |
|
|
$plugin = array(
|
16 |
|
|
'title' => t('CTools example no context content type'),
|
17 |
|
|
'description' => t('No context content type - requires and uses no context.'),
|
18 |
|
|
|
19 |
|
|
// 'single' => TRUE means has no subtypes.
|
20 |
|
|
'single' => TRUE,
|
21 |
|
|
// Constructor.
|
22 |
|
|
'content_types' => array('no_context_content_type'),
|
23 |
|
|
// Name of a function which will render the block.
|
24 |
|
|
'render callback' => 'no_context_content_type_render',
|
25 |
|
|
// The default context.
|
26 |
|
|
'defaults' => array(),
|
27 |
|
|
|
28 |
|
|
// This explicitly declares the config form. Without this line, the func would be
|
29 |
|
|
// ctools_plugin_example_no_context_content_type_edit_form.
|
30 |
|
|
'edit form' => 'no_context_content_type_edit_form',
|
31 |
|
|
|
32 |
|
|
// Icon goes in the directory with the content type.
|
33 |
|
|
'icon' => 'icon_example.png',
|
34 |
|
|
'category' => array(t('CTools Examples'), -9),
|
35 |
|
|
|
36 |
|
|
// this example does not provide 'admin info', which would populate the
|
37 |
|
|
// panels builder page preview.
|
38 |
|
|
);
|
39 |
|
|
|
40 |
|
|
/**
|
41 |
|
|
* Run-time rendering of the body of the block.
|
42 |
|
|
*
|
43 |
|
|
* @param $subtype
|
44 |
|
|
* @param $conf
|
45 |
|
|
* Configuration as done at admin time.
|
46 |
|
|
* @param $args
|
47 |
|
|
* @param $context
|
48 |
|
|
* Context - in this case we don't have any.
|
49 |
|
|
*
|
50 |
|
|
* @return
|
51 |
|
|
* An object with at least title and content members.
|
52 |
|
|
*/
|
53 |
|
|
function no_context_content_type_render($subtype, $conf, $args, $context) {
|
54 |
|
|
$block = new stdClass();
|
55 |
|
|
|
56 |
|
|
$ctools_help = theme('advanced_help_topic', array('module' => 'ctools', 'topic' => 'plugins', 'type' => 'title'));
|
57 |
|
|
$ctools_plugin_example_help = theme('advanced_help_topic', array('module' => 'ctools_plugin_example', 'topic' => 'Chaos-Tools--CTools--Plugin-Examples', 'type' => 'title'));
|
58 |
|
|
|
59 |
|
|
// The title actually used in rendering
|
60 |
|
|
$block->title = check_plain("No-context content type");
|
61 |
|
|
$block->content = t("
|
62 |
|
|
<div>Welcome to the CTools Plugin Example demonstration content type.
|
63 |
|
|
|
64 |
|
|
This block is a content type which requires no context at all. It's like a custom block,
|
65 |
|
|
but not even that sophisticated.
|
66 |
|
|
|
67 |
|
|
For more information on the example plugins, please see the advanced help for
|
68 |
|
|
|
69 |
|
|
{$ctools_help} and {$ctools_plugin_example_help}
|
70 |
|
|
</div>
|
71 |
|
|
");
|
72 |
|
|
if (!empty($conf)) {
|
73 |
|
|
$block->content .= '<div>The only information that can be displayed in this block comes from the code and its settings form: </div>';
|
74 |
|
|
$block->content .= '<div style="border: 1px solid red;">' . var_export($conf, TRUE) . '</div>';
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
return $block;
|
78 |
|
|
|
79 |
|
|
}
|
80 |
|
|
|
81 |
|
|
/**
|
82 |
|
|
* 'Edit form' callback for the content type.
|
83 |
|
|
* This example just returns a form; validation and submission are standard drupal
|
84 |
|
|
* Note that if we had not provided an entry for this in hook_content_types,
|
85 |
|
|
* this could have had the default name
|
86 |
|
|
* ctools_plugin_example_no_context_content_type_edit_form.
|
87 |
|
|
*
|
88 |
|
|
*/
|
89 |
|
|
function no_context_content_type_edit_form($form, &$form_state) {
|
90 |
|
|
$conf = $form_state['conf'];
|
91 |
|
|
$form['item1'] = array(
|
92 |
|
|
'#type' => 'textfield',
|
93 |
|
|
'#title' => t('Item1'),
|
94 |
|
|
'#size' => 50,
|
95 |
|
|
'#description' => t('The setting for item 1.'),
|
96 |
|
|
'#default_value' => !empty($conf['item1']) ? $conf['item1'] : '',
|
97 |
|
|
'#prefix' => '<div class="clear-block no-float">',
|
98 |
|
|
'#suffix' => '</div>',
|
99 |
|
|
);
|
100 |
|
|
$form['item2'] = array(
|
101 |
|
|
'#type' => 'textfield',
|
102 |
|
|
'#title' => t('Item2'),
|
103 |
|
|
'#size' => 50,
|
104 |
|
|
'#description' => t('The setting for item 2'),
|
105 |
|
|
'#default_value' => !empty($conf['item2']) ? $conf['item2'] : '',
|
106 |
|
|
'#prefix' => '<div class="clear-block no-float">',
|
107 |
|
|
'#suffix' => '</div>',
|
108 |
|
|
);
|
109 |
|
|
return $form;
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
function no_context_content_type_edit_form_submit($form, &$form_state) {
|
113 |
|
|
foreach (array('item1', 'item2') as $key) {
|
114 |
|
|
$form_state['conf'][$key] = $form_state['values'][$key];
|
115 |
|
|
}
|
116 |
|
|
} |