function theme_ctools_context_list
Create a visible list of all the contexts available on an object. Assumes arguments, relationships and context objects.
Contexts must be preloaded.
1 theme call to theme_ctools_context_list()
- ctools_context_handler_edit_context in includes/
context-task-handler.inc - Edit contexts that go with this panel.
File
-
includes/
context.theme.inc, line 135
Code
function theme_ctools_context_list($vars) {
$object = $vars['object'];
$header = $vars['header'];
$description = !empty($vars['description']) ? $vars['description'] : NULL;
$titles = array();
$output = '';
$count = 1;
$contexts = ctools_context_load_contexts($object);
// Describe 'built in' contexts.
if (!empty($object->base_contexts)) {
foreach ($object->base_contexts as $id => $context) {
$output .= '<tr>';
$output .= '<td valign="top"><em>' . t('Built in context') . '</em></td>';
$desc = check_plain($context->identifier);
if (isset($context->keyword)) {
$desc .= '<div class="description">' . t('Keyword: %@keyword', array(
'@keyword' => $context->keyword,
));
foreach (ctools_context_get_converters('%' . $context->keyword . ':', $context) as $keyword => $title) {
$desc .= '<br />' . t('@keyword --> @title', array(
'@keyword' => $keyword,
'@title' => $title,
));
}
$desc .= '</div>';
}
if (isset($context->description)) {
$desc .= '<div class="description">' . filter_xss_admin($context->description) . '</div>';
}
$output .= '<td>' . $desc . '</td>';
$output .= '</tr>';
$titles[$id] = $context->identifier;
}
}
// First, make a list of arguments. Arguments are pretty simple.
if (!empty($object->arguments)) {
foreach ($object->arguments as $argument) {
$output .= '<tr>';
$output .= '<td valign="top"><em>' . t('Argument @count', array(
'@count' => $count,
)) . '</em></td>';
$desc = check_plain($argument['identifier']);
if (isset($argument['keyword'])) {
$desc .= '<div class="description">' . t('Keyword: %@keyword', array(
'@keyword' => $argument['keyword'],
));
if (isset($contexts[ctools_context_id($argument, 'argument')])) {
foreach (ctools_context_get_converters('%' . $argument['keyword'] . ':', $contexts[ctools_context_id($argument, 'argument')]) as $keyword => $title) {
$desc .= '<br />' . t('@keyword --> @title', array(
'@keyword' => $keyword,
'@title' => $title,
));
}
}
$desc .= '</div>';
}
$output .= '<td>' . $desc . '</td>';
$output .= '</tr>';
$titles[ctools_context_id($argument, 'argument')] = $argument['identifier'];
$count++;
}
}
$count = 1;
// Then, make a nice list of contexts.
if (!empty($object->contexts)) {
foreach ($object->contexts as $context) {
$output .= '<tr>';
$output .= '<td valign="top"><em>' . t('Context @count', array(
'@count' => $count,
)) . '</em></td>';
$desc = check_plain($context['identifier']);
if (isset($context['keyword'])) {
$desc .= '<div class="description">' . t('Keyword: %@keyword', array(
'@keyword' => $context['keyword'],
));
foreach (ctools_context_get_converters('%' . $context['keyword'] . ':', $contexts[ctools_context_id($context, 'context')]) as $keyword => $title) {
$desc .= '<br />' . t('@keyword --> @title', array(
'@keyword' => $keyword,
'@title' => $title,
));
}
$desc .= '</div>';
}
$output .= '<td>' . $desc . '</td>';
$output .= '</tr>';
$titles[ctools_context_id($context)] = $context['identifier'];
$count++;
}
}
// And relationships.
if (!empty($object->relationships)) {
foreach ($object->relationships as $relationship) {
$output .= '<tr>';
if (is_array($relationship['context'])) {
$rtitles = array();
foreach ($relationship['context'] as $cid) {
$rtitles[$cid] = $titles[$cid];
}
$title = implode(' + ', $rtitles);
}
else {
$title = $titles[$relationship['context']];
}
$output .= '<td valign="top"><em>' . t('From "@title"', array(
'@title' => $title,
)) . '</em></td>';
$desc = check_plain($relationship['identifier']);
if (isset($relationship['keyword'])) {
$desc .= '<div class="description">' . t('Keyword: %@keyword', array(
'@keyword' => $relationship['keyword'],
));
foreach (ctools_context_get_converters('%' . $relationship['keyword'] . ':', $contexts[ctools_context_id($relationship, 'relationship')]) as $keyword => $title) {
$desc .= '<br />' . t('@keyword --> @title', array(
'@keyword' => $keyword,
'@title' => $title,
));
}
$desc .= '</div>';
}
$output .= '<td>' . $desc . '</td>';
$output .= '</tr>';
$titles[ctools_context_id($relationship, 'relationship')] = $relationship['identifier'];
$count++;
}
}
$head = '';
if ($header) {
if ($description) {
$header .= '<div class="description">' . $description . '</div>';
}
$head .= '<thead><tr>';
$head .= '<th colspan="2">' . $header . '</th>';
$head .= '</tr></thead>';
}
return $output ? "<table>{$head}<tbody>{$output}</tbody></table>\n" : "<table>{$head}</table>\n";
}