function ctools_context_create_node

It's important to remember that $conf is optional here, because contexts are not always created from the UI.

1 string reference to 'ctools_context_create_node'
node.inc in plugins/contexts/node.inc
Plugin to provide a node context. A node context is a node wrapped in a context object that can be utilized by anything that accepts contexts.

File

plugins/contexts/node.inc, line 37

Code

function ctools_context_create_node($empty, $data = NULL, $conf = FALSE) {
    $context = new ctools_context('node');
    $context->plugin = 'node';
    if ($empty) {
        return $context;
    }
    if ($conf) {
        $nid = is_array($data) && isset($data['nid']) ? $data['nid'] : (is_object($data) ? $data->nid : 0);
        if (module_exists('translation')) {
            if ($translation = module_invoke('translation', 'node_nid', $nid, $GLOBALS['language']->language)) {
                $nid = $translation;
                $reload = TRUE;
            }
        }
        if (is_array($data) || !empty($reload)) {
            $data = node_load($nid);
        }
    }
    if (!empty($data)) {
        $context->data = $data;
        $context->title = $data->title;
        $context->argument = $data->nid;
        $context->restrictions['type'] = array(
            $data->type,
        );
        return $context;
    }
}