function views_content_view_from_argument_context

Return a new context based on an existing context.

2 string references to 'views_content_view_from_argument_context'
view_from_argument.inc in views_content/plugins/relationships/view_from_argument.inc
Plugin to provide an relationship handler for a view by argument input settings.
_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/relationships/view_from_argument.inc, line 57

Code

function views_content_view_from_argument_context($contexts, $conf) {
    $name = $conf['name'];
    list($plugin, $view_data) = explode(':', $name);
    list($view_name, $display_id) = explode('-', $view_data);
    $keys = array_keys($conf['context']);
    if (empty($contexts[$keys[0]]->data)) {
        return ctools_context_create_empty('view', NULL);
    }
    // Load our view up.
    $data = views_get_view($view_name);
    if ($data) {
        // Set the display.
        $data->set_display($display_id);
        $context_keys = array_keys($contexts);
        foreach ($data->display_handler
            ->get_argument_input() as $id => $argument) {
            if ($argument['type'] == 'context') {
                $key = array_shift($context_keys);
                if (isset($contexts[$key])) {
                    if (strpos($argument['context'], '.')) {
                        list($context, $converter) = explode('.', $argument['context'], 2);
                        $args[] = ctools_context_convert_context($contexts[$key], $converter, array(
                            'sanitize' => FALSE,
                        ));
                    }
                    else {
                        $args[] = $contexts[$key]->argument;
                    }
                }
            }
        }
        // Remove any trailing NULL arguments as these are non-args:
        while (count($args) && end($args) === NULL) {
            array_pop($args);
        }
        $data->set_arguments($args);
        if ($path = $data->display_handler
            ->get_option('inherit_panels_path')) {
            $data->override_path = $_GET['q'];
        }
    }
    if (isset($contexts[$keys[0]]->data)) {
        return ctools_context_create('view', $data);
    }
}