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
|
'single' => TRUE,
|
11
|
'title' => t('Comment links'),
|
12
|
'icon' => 'icon_comment.png',
|
13
|
'description' => t('Comment links of the referenced comment.'),
|
14
|
'required context' => new ctools_context_required(t('Comment'), 'entity:comment'),
|
15
|
'category' => t('Comment'),
|
16
|
'defaults' => array(
|
17
|
'override_title' => FALSE,
|
18
|
'override_title_text' => '',
|
19
|
'build_mode' => '',
|
20
|
),
|
21
|
);
|
22
|
|
23
|
/**
|
24
|
* Output function for the comment links.
|
25
|
*/
|
26
|
function ctools_comment_links_content_type_render($subtype, $conf, $panel_args, $context) {
|
27
|
if (!empty($context) && empty($context->data)) {
|
28
|
return;
|
29
|
}
|
30
|
|
31
|
$comment = isset($context->data) ? clone $context->data : NULL;
|
32
|
$block = new stdClass();
|
33
|
$block->module = 'comment';
|
34
|
$block->delta = $comment->cid;
|
35
|
|
36
|
if (empty($comment)) {
|
37
|
$block->delta = 'placeholder';
|
38
|
$block->subject = t('Comment subject.');
|
39
|
$block->content = t('Comment links go here.');
|
40
|
}
|
41
|
else {
|
42
|
$node = node_load($comment->nid);
|
43
|
$block->subject = $comment->subject;
|
44
|
comment_build_content($comment, $node, $conf['build_mode']);
|
45
|
$block->content = $comment->content['links'];
|
46
|
}
|
47
|
return $block;
|
48
|
}
|
49
|
|
50
|
/**
|
51
|
* Returns an edit form for the custom type.
|
52
|
*/
|
53
|
function ctools_comment_links_content_type_edit_form($form, &$form_state) {
|
54
|
$conf = $form_state['conf'];
|
55
|
|
56
|
$entity = entity_get_info('comment');
|
57
|
$build_mode_options = array();
|
58
|
foreach ($entity['view modes'] as $mode => $option) {
|
59
|
$build_mode_options[$mode] = $option['label'];
|
60
|
}
|
61
|
|
62
|
$form['build_mode'] = array(
|
63
|
'#title' => t('Build mode'),
|
64
|
'#type' => 'select',
|
65
|
'#description' => t('Select a build mode for this comment.'),
|
66
|
'#options' => $build_mode_options,
|
67
|
'#default_value' => $conf['build_mode'],
|
68
|
);
|
69
|
|
70
|
return $form;
|
71
|
}
|
72
|
|
73
|
function ctools_comment_links_content_type_edit_form_submit($form, &$form_state) {
|
74
|
// Copy everything from our defaults.
|
75
|
foreach (array_keys($form_state['plugin']['defaults']) as $key) {
|
76
|
$form_state['conf'][$key] = $form_state['values'][$key];
|
77
|
}
|
78
|
}
|
79
|
|
80
|
function ctools_comment_links_content_type_admin_title($subtype, $conf, $context) {
|
81
|
return t('"@s" links', array('@s' => $context->identifier));
|
82
|
}
|