You are here

function panels_pane_select_context in Panels 5.2

Same name and namespace in other branches
  1. 6.3 panels.module \panels_pane_select_context()
  2. 6.2 includes/plugins.inc \panels_pane_select_context()

Select a context for a pane.

Parameters

object $pane: A fully populated pane.

array $contexts: A keyed array of available contexts.

string $context_type: Indicates whether a required or optional context is being sought.

Return value

The matching contexts or NULL if none or necessary, or FALSE if requirements can't be met.

2 calls to panels_pane_select_context()
panels_get_pane_title in includes/plugins.inc
Get the title of a pane.
panels_render_pane_content in ./panels.module
Render a single pane, identifying its context, and put it into the $panes array.

File

includes/plugins.inc, line 1233
plugins.inc

Code

function panels_pane_select_context($pane, $contexts, $context_type = 'required context') {

  // Identify which of our possible contexts apply.
  if (empty($pane->subtype)) {
    return;
  }
  $content_type = panels_ct_get_types($pane->type);

  // If the pane requires a context, fetch it; if no context is returned,
  // do not display the pane.
  if (empty($content_type[$pane->subtype][$context_type])) {
    return $context_type == 'required context' ? panels_pane_select_context($pane, $contexts, 'optional context') : NULL;
  }
  $context = panels_context_select($contexts, $content_type[$pane->subtype][$context_type], $pane->configuration['context']);
  return $context;
}