function panels_term_context in Panels 6.2
Same name and namespace in other branches
- 5.2 arguments/term.inc \panels_term_context()
Discover if this argument gives us the term we crave.
1 string reference to 'panels_term_context'
- panels_term_panels_arguments in arguments/
term.inc - @file arguments/term.inc
File
- arguments/
term.inc, line 29 - arguments/term.inc
Code
function panels_term_context($arg = NULL, $conf = NULL, $empty = FALSE) {
// If unset it wants a generic, unfilled context.
if ($empty) {
return panels_context_create_empty('term');
}
switch ($conf['input_form']) {
case 'tid':
default:
if (!is_numeric($arg)) {
return FALSE;
}
$term = taxonomy_get_term($arg);
break;
case 'term':
$terms = taxonomy_get_term_by_name($arg);
if (count($terms) != 1) {
foreach ($terms as $potential) {
foreach ($conf['vids'] as $vid => $active) {
if ($active == 1 && $potential->vid == $vid) {
$term = $potential;
// break out of the foreaches AND the case
break 3;
}
}
}
}
$term = array_shift($terms);
break;
}
if (empty($term)) {
return PANELS_ARG_IS_BAD;
}
if (!empty($conf['vids']) && array_filter($conf['vids']) && empty($conf['vids'][$term->vid])) {
return PANELS_ARG_USE_FALLBACK;
}
$context = panels_context_create('term', $term);
$context->original_argument = $arg;
return $context;
}