function nodereference_node_from_noderef_context in Content Construction Kit (CCK) 6.3
Same name and namespace in other branches
- 5 nodereference.module \nodereference_node_from_noderef_context()
- 6.2 modules/nodereference/panels/relationships/node_from_noderef.inc \nodereference_node_from_noderef_context()
Return a new ctools context based on an existing context.
1 string reference to 'nodereference_node_from_noderef_context'
- nodereference_node_from_noderef_ctools_relationships in modules/
nodereference/ panels/ relationships/ node_from_noderef.inc - Implementation of hook_ctools_relationships().
File
- modules/
nodereference/ panels/ relationships/ node_from_noderef.inc, line 26 - Implements the node reference relationship for Panels.
Code
function nodereference_node_from_noderef_context($context, $conf) {
$field = content_fields($conf['field_name']);
// If unset it wants a generic, unfilled context, which is just NULL.
if (empty($context->data)) {
$new_context = ctools_context_create_empty('node', NULL);
}
else {
if (isset($context->data->{$conf['field_name']}[0]['nid']) && ($nid = $context->data->{$conf['field_name']}[0]['nid'])) {
if ($node = node_load($nid)) {
$new_context = ctools_context_create('node', $node);
}
}
}
if (!empty($new_context)) {
// Have nodereference relationships limit CCK field availability as well.
$restrictions = array_keys(array_filter($field['referenceable_types']));
if ($restrictions) {
if (isset($new_context->restrictions['type'])) {
$new_context->restrictions['type'] = array_unique(array_merge($new_context->restrictions['type'], $restrictions));
}
else {
$new_context->restrictions['type'] = $restrictions;
}
}
return $new_context;
}
}