1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Plugin to handle the Display Suite content type.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Plugins are described by creating a $plugin array which will be used
|
10 |
|
|
* by the system that includes this file.
|
11 |
|
|
*/
|
12 |
|
|
$plugin = array(
|
13 |
|
|
'title' => t('Display Suite content'),
|
14 |
|
|
'category' => t('Display Suite'),
|
15 |
|
|
'single' => TRUE,
|
16 |
|
|
'defaults' => array(
|
17 |
|
|
'title' => '',
|
18 |
|
|
'body' => '',
|
19 |
|
|
'format' => 'ds_code',
|
20 |
|
|
'context' => array(),
|
21 |
|
|
),
|
22 |
|
|
'description' => t('Add custom content with the possibility to use the entity object when using the Display Suite format.'),
|
23 |
|
|
'js' => array('misc/textarea.js', 'misc/collapse.js'),
|
24 |
|
|
'all contexts' => TRUE,
|
25 |
|
|
);
|
26 |
|
|
|
27 |
|
|
/**
|
28 |
|
|
* Output function for the 'Display Suite' content type.
|
29 |
|
|
*/
|
30 |
|
|
function ds_dsc_content_type_render($subtype, $conf, $panel_args, $context, $incoming) {
|
31 |
|
|
$block = new stdClass();
|
32 |
|
|
|
33 |
|
|
$field = array();
|
34 |
|
|
|
35 |
|
|
$entity = array_shift($context);
|
36 |
|
|
$field['entity'] = isset($entity->data) ? $entity->data : NULL;
|
37 |
|
|
$field['properties']['code']['format'] = $conf['format'];
|
38 |
|
|
$field['properties']['code']['value'] = $conf['body'];
|
39 |
|
|
|
40 |
|
|
$block->module = 'ds';
|
41 |
|
|
$block->title = $conf['title'];
|
42 |
|
|
$block->content = ds_render_code_field($field);
|
43 |
|
|
|
44 |
|
|
return $block;
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
/**
|
48 |
|
|
* The form to add or edit Display Suite content.
|
49 |
|
|
*/
|
50 |
|
|
function ds_dsc_content_type_edit_form($form, &$form_state) {
|
51 |
|
|
$conf = $form_state['conf'];
|
52 |
|
|
|
53 |
|
|
$form['title'] = array(
|
54 |
|
|
'#type' => 'textfield',
|
55 |
|
|
'#default_value' => isset($conf['title']) ? $conf['title'] : '',
|
56 |
|
|
'#title' => t('Title'),
|
57 |
|
|
);
|
58 |
|
|
|
59 |
|
|
$form['body'] = array(
|
60 |
|
|
'#type' => 'text_format',
|
61 |
|
|
'#title' => t('Body'),
|
62 |
|
|
'#default_value' => isset($conf['body']) ? $conf['body'] : '',
|
63 |
|
|
'#format' => isset($conf['format']) ? $conf['format'] : 'ds_code',
|
64 |
|
|
);
|
65 |
|
|
|
66 |
|
|
return $form;
|
67 |
|
|
}
|
68 |
|
|
|
69 |
|
|
/**
|
70 |
|
|
* Save the Display Suite content.
|
71 |
|
|
*/
|
72 |
|
|
function ds_dsc_content_type_edit_form_submit($form, &$form_state) {
|
73 |
|
|
$form_state['conf']['title'] = $form_state['values']['title'];
|
74 |
|
|
$form_state['conf']['body'] = $form_state['values']['body']['value'];
|
75 |
|
|
$form_state['conf']['format'] = $form_state['values']['body']['format'];
|
76 |
|
|
$form_state['conf']['context'] = array();
|
77 |
|
|
}
|
78 |
|
|
|
79 |
|
|
/**
|
80 |
|
|
* Returns the administrative title for a Display Suite content.
|
81 |
|
|
*/
|
82 |
|
|
function ds_dsc_content_type_admin_title($subtype, $conf) {
|
83 |
|
|
return (!empty($conf['title'])) ? $conf['title'] : t('Display Suite content');
|
84 |
|
|
}
|
85 |
|
|
|
86 |
|
|
/**
|
87 |
|
|
* Display the administrative information for a Display Suite content pane.
|
88 |
|
|
*/
|
89 |
|
|
function ds_dsc_content_type_admin_info($subtype, $conf) {
|
90 |
|
|
return 'Display Suite content can only be rendered on the frontend.';
|
91 |
|
|
} |