1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Sample relationship plugin.
|
6
|
*
|
7
|
* We take a simplecontext, look in it for what we need to make a relcontext, and make it.
|
8
|
* In the real world, this might be getting a taxonomy id from a node, for example.
|
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("Relcontext from simplecontext"),
|
17
|
'keyword' => 'relcontext',
|
18
|
'description' => t('Adds a relcontext from existing simplecontext.'),
|
19
|
'required context' => new ctools_context_required(t('Simplecontext'), 'simplecontext'),
|
20
|
'context' => 'ctools_relcontext_from_simplecontext_context',
|
21
|
'settings form' => 'ctools_relcontext_from_simplecontext_settings_form',
|
22
|
);
|
23
|
|
24
|
/**
|
25
|
* Return a new context based on an existing context.
|
26
|
*/
|
27
|
function ctools_relcontext_from_simplecontext_context($context = NULL, $conf) {
|
28
|
// If unset it wants a generic, unfilled context, which is just NULL.
|
29
|
if (empty($context->data)) {
|
30
|
return ctools_context_create_empty('relcontext', NULL);
|
31
|
}
|
32
|
|
33
|
// You should do error-checking here.
|
34
|
// Create the new context from some element of the parent context.
|
35
|
// In this case, we'll pass in the whole context so it can be used to
|
36
|
// create the relcontext.
|
37
|
return ctools_context_create('relcontext', $context);
|
38
|
}
|
39
|
|
40
|
/**
|
41
|
* Settings form for the relationship.
|
42
|
*/
|
43
|
function ctools_relcontext_from_simplecontext_settings_form($conf) {
|
44
|
// We won't configure it in this case.
|
45
|
return array();
|
46
|
}
|