function views_content_context_view_create

2 string references to 'views_content_context_view_create'
view.inc in views_content/plugins/contexts/view.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.
_views_content_get_context_from_display in views_content/views_content.module
Get the child plugin for a view context display.

File

views_content/plugins/contexts/view.inc, line 72

Code

function views_content_context_view_create($empty, $data = NULL, $conf = FALSE, $plugin = array()) {
    $context = new ctools_context('view');
    $context->plugin = 'view';
    if ($empty) {
        return $context;
    }
    if ($conf) {
        if (is_array($data) && !empty($data['view'])) {
            // This code is left in for backward compatibility. Will not be used
            // with child plugins.
            list($name, $display_id) = explode(':', $data['view'], 2);
            $data = views_get_view($name);
            if ($data) {
                $data->set_display($display_id);
            }
        }
        elseif (!empty($plugin['view name'])) {
            $data = views_get_view($plugin['view name']);
            $data->set_display($plugin['view display id']);
        }
    }
    if (is_object($data) && $data->current_display != 'default') {
        // We don't store the loaded view as we don't want the view object
        // cached. However, in order to extract it you can use:
        // @code
        // $output = views_content_context_get_output($context);
        // $view = $output['view'];
        // @endcode
        $context->data = array(
            'name' => $data->name,
            'display' => $data->current_display,
            'args' => $data->args,
        );
        // At runtime, this can get populated. Once it is populated this
        // object should not be cached.
        $context->view = NULL;
        $context->title = $data->get_title();
        $context->argument = $data->name . ':' . $data->current_display;
        $context->restrictions['base'] = array(
            $data->base_table,
        );
        return $context;
    }
}