1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file relationships/comment_parent.inc
|
5
|
* Plugin to provide a relationship handler for comment parent.
|
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('Parent comment'),
|
14
|
'keyword' => 'parent_comment',
|
15
|
'description' => t('Adds a parent comment from a comment context.'),
|
16
|
'required context' => new ctools_context_required(t('Comment'), 'entity:comment'),
|
17
|
'context' => 'ctools_comment_parent_context',
|
18
|
);
|
19
|
|
20
|
/**
|
21
|
* Return a new context based on an existing context.
|
22
|
*/
|
23
|
function ctools_comment_parent_context($context, $conf) {
|
24
|
if (empty($context->data)) {
|
25
|
return ctools_context_create_empty('entity:comment');
|
26
|
}
|
27
|
|
28
|
if (isset($context->data->pid) && ($context->data->pid !== 0)) {
|
29
|
$parent_comment = comment_load($context->data->pid);
|
30
|
return ctools_context_create('entity:comment', $parent_comment);
|
31
|
}
|
32
|
}
|