function ctools_context_create_terms

It's important to remember that $conf is optional here, because contexts are not always created from the UI.

1 string reference to 'ctools_context_create_terms'
terms.inc in plugins/contexts/terms.inc
Plugin to provide a terms context.

File

plugins/contexts/terms.inc, line 36

Code

function ctools_context_create_terms($empty, $data = NULL, $conf = FALSE) {
    // The input is expected to be an object as created by ctools_break_phrase
    // which contains a group of terms.
    $context = new ctools_context(array(
        'terms',
        'entity:taxonomy_term',
    ));
    $context->plugin = 'terms';
    if ($empty) {
        return $context;
    }
    if (!empty($data) && is_object($data)) {
        $context->operator = $data->operator;
        $context->tids = $data->value;
        if (!isset($data->term)) {
            // Load the first term:
            reset($context->tids);
            $data->term = taxonomy_term_load(current($context->tids));
        }
        $context->data = $data->term;
        $context->title = $data->term->name;
        $context->argument = implode($context->operator == 'or' ? '+' : ',', array_unique($context->tids));
        return $context;
    }
}