function ctools_context_load_contexts in Chaos Tool Suite (ctools) 6
Same name and namespace in other branches
- 7 includes/context.inc \ctools_context_load_contexts()
Load a full array of contexts for an object.
Not all of the types need to be supported by this object.
This function is not used to load contexts from external data, but may be used to load internal contexts and relationships. Otherwise it can also be used to generate a full set of placeholders for UI purposes.
Parameters
$object: An object that contains some or all of the following variables:
- requiredcontexts: A list of UI configured contexts that are required from an external source. Since these require external data, they will only be added if $placeholders is set to TRUE, and empty contexts will be created.
- arguments: A list of UI configured arguments that will create contexts. Since these require external data, they will only be added if $placeholders is set to TRUE.
- contexts: A list of UI configured contexts that have no external source, and are essentially hardcoded. For example, these might configure a particular node or a particular taxonomy term.
- relationships: A list of UI configured contexts to be derived from other contexts that already exist from other sources. For example, these might be used to get a user object from a node via the node author relationship.
$placeholders: If TRUE, this will generate placeholder objects for types this function cannot load.
$contexts: An array of pre-existing contexts that will be part of the return value.
10 calls to ctools_context_load_contexts()
- ctools_access_ruleset_ui::edit_form_rules in ctools_access_ruleset/
plugins/ export_ui/ ctools_access_ruleset_ui.class.php - ctools_context_add_relationship_form in includes/
context-admin.inc - ctools_context_ajax_item_add in includes/
context-admin.inc - Ajax entry point to add an context
- ctools_context_ajax_item_edit in includes/
context-admin.inc - Ajax entry point to edit an item
- ctools_context_handler_get_all_contexts in includes/
context-task-handler.inc - Load the contexts for a task and task handler together.
File
- includes/
context.inc, line 1141 - Contains code related to the ctools system of 'context'.
Code
function ctools_context_load_contexts($object, $placeholders = TRUE, $contexts = array()) {
if (!empty($object->base_contexts)) {
$contexts += $object->base_contexts;
}
if ($placeholders) {
// This will load empty contexts as placeholders for arguments that come
// from external sources. If this isn't set, it's assumed these context
// will already have been matched up and loaded.
if (!empty($object->requiredcontexts) && is_array($object->requiredcontexts)) {
$contexts += ctools_context_get_context_from_contexts($object->requiredcontexts, 'requiredcontext', $placeholders);
}
if (!empty($object->arguments) && is_array($object->arguments)) {
$contexts += ctools_context_get_placeholders_from_argument($object->arguments);
}
}
if (!empty($object->contexts) && is_array($object->contexts)) {
$contexts += ctools_context_get_context_from_contexts($object->contexts, 'context', $placeholders);
}
// add contexts from relationships
if (!empty($object->relationships) && is_array($object->relationships)) {
ctools_context_get_context_from_relationships($object->relationships, $contexts, $placeholders);
}
return $contexts;
}