You are here

function ctools_context_get_context_from_context in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 includes/context.inc \ctools_context_get_context_from_context()

Parameters

$context: The configuration of a context. It must contain the following data:

  • name: The name of the context plugin being used.
  • context_settings: The configuration based upon the plugin forms.
  • identifier: The human readable identifier for this context, usually defined by the UI.
  • keyword: The keyword used for this context for substitutions.

$type: This is either 'context' which indicates the context will be loaded from data in the settings, or 'required_context' which means the context must be acquired from an external source. This is the method used to pass pure contexts from one system to another.

Return value

A context object if one can be loaded.

2 calls to ctools_context_get_context_from_context()
ctools_context_get_context_from_contexts in includes/context.inc
Retrieve a list of base contexts based upon a simple 'contexts' definition.
ctools_context_replace_placeholders in includes/context.inc
Replace placeholders with real contexts using data extracted from a form for the purposes of previews.

File

includes/context.inc, line 1021
Contains code related to the ctools system of 'context'.

Code

function ctools_context_get_context_from_context($context, $type = 'context', $argument = NULL) {
  ctools_include('plugins');
  $plugin = ctools_get_context($context['name']);
  if ($function = ctools_plugin_get_function($plugin, 'context')) {
    if (!isset($context['context_settings'])) {
      $context['context_settings'] = array();
    }
    if (isset($argument) && isset($plugin['placeholder name'])) {
      $context['context_settings'][$plugin['placeholder name']] = $argument;
    }
    $return = $function($type == 'requiredcontext', $context['context_settings'], TRUE);
    if ($return) {
      $return->identifier = $context['identifier'];
      $return->page_title = isset($context['title']) ? $context['title'] : '';
      $return->keyword = $context['keyword'];
      if (!empty($context->empty)) {
        $context->placeholder = array(
          'type' => 'context',
          'conf' => $context,
        );
      }
      return $return;
    }
  }
}