function _views_content_get_context_from_display

Get the child plugin for a view context display.

This can return both the context and relationship style. The $required parameter is used to distinguish if context is required or not, so we know whether we need it suitable as a pure context (i.e, no context required) or a relationship (i.e, context required).

4 calls to _views_content_get_context_from_display()
views_content_context_view_get_child in views_content/plugins/contexts/view.inc
views_content_context_view_get_children in views_content/plugins/contexts/view.inc
views_content_view_from_argument_get_child in views_content/plugins/relationships/view_from_argument.inc
views_content_view_from_argument_get_children in views_content/plugins/relationships/view_from_argument.inc

File

views_content/views_content.module, line 224

Code

function _views_content_get_context_from_display($view, $id, $parent, $required = TRUE) {
    $title = views_content_get_display_title($view, $id, 'admin_title');
    $description = $view->description;
    $contexts = array();
    $arguments = $view->display_handler
        ->get_argument_input();
    ctools_include('views');
    foreach ($arguments as $argument) {
        $argument['label'] = $argument['name'] ? $argument['name'] : '';
        $contexts[] = ctools_views_get_argument_context($argument);
    }
    $pass = FALSE;
    if ($required) {
        // If context is required, make sure we have at least one optional
        // or required context.
        foreach ($contexts as $context) {
            if (is_object($context)) {
                $pass = TRUE;
                break;
            }
        }
        if (!$pass) {
            return;
        }
    }
    else {
        // If context is not required, then having any required context
        // causes a fail.
        foreach ($contexts as $context) {
            if (is_object($context) && get_class($context) == 'ctools_context_required') {
                return;
            }
        }
        // Since we know we don't want contexts, we an unset this now.
        $contexts = array();
    }
    if ($required) {
        $function = 'views_content_view_from_argument_context';
    }
    else {
        $function = 'views_content_context_view_create';
    }
    return array(
        'title' => $title,
        'description' => filter_xss_admin($description),
        'required context' => $contexts,
        'keyword' => 'view',
        'context' => $function,
        'context name' => $view->name,
        'name' => $parent . ':' . $view->name . '-' . $id,
        'view name' => $view->name,
        'view display id' => $id,
    );
}