function theme_ctools_context_item_form in Chaos Tool Suite (ctools) 7
Same name and namespace in other branches
- 6 includes/context.theme.inc \theme_ctools_context_item_form()
Display the context item.
5 theme calls to theme_ctools_context_item_form()
- ctools_context_add_argument_form in includes/
context-admin.inc - Add the argument table plus gadget plus javascript to the form.
- ctools_context_add_context_form in includes/
context-admin.inc - ctools_context_add_relationship_form in includes/
context-admin.inc - ctools_context_add_required_context_form in includes/
context-admin.inc - ctools_context_ajax_item_add in includes/
context-admin.inc - Ajax entry point to add an context
File
- includes/
context.theme.inc, line 61 - Contains theme registry and theme implementations for the context tool.
Code
function theme_ctools_context_item_form($vars) {
$form = $vars['form'];
$output = '';
$type = $form['#ctools_context_type'];
$module = $form['#ctools_context_module'];
$cache_key = $form['#cache_key'];
$type_info = ctools_context_info($type);
if (!empty($form[$type]) && empty($form['#only_buttons'])) {
$count = 0;
$rows = '';
foreach (array_keys($form[$type]) as $id) {
if (!is_numeric($id)) {
continue;
}
$theme_vars = array();
$theme_vars['type'] = $type;
$theme_vars['form'] = $form[$type][$id];
$theme_vars['position'] = $id;
$theme_vars['count'] = $count++;
$rows .= theme('ctools_context_item_row', $theme_vars);
}
$output .= '<table id="' . $type . '-table">';
$output .= '<thead>';
$output .= '<tr>';
$output .= '<th class="title">' . $type_info['title'] . '</th>';
if (!empty($type_info['sortable']) && $count) {
$output .= '<th class="position">' . t('Weight') . '</th>';
}
$output .= '<th class="operation">' . t('Operation') . '</th>';
$output .= '</tr>';
$output .= '</thead>';
$output .= '<tbody>';
$output .= $rows;
$output .= '</tbody>';
$output .= '</table>';
}
if (!empty($form['buttons'])) {
// Display the add context item.
$row = array();
$row[] = array(
'data' => render($form['buttons'][$type]['item']),
'class' => array(
'title',
),
);
$row[] = array(
'data' => render($form['buttons'][$type]['add']),
'class' => array(
'add',
),
'width' => "60%",
);
$output .= '<div class="buttons">';
$output .= render($form['buttons'][$type]);
$theme_vars = array();
$theme_vars['header'] = array();
$theme_vars['rows'] = array(
$row,
);
$theme_vars['attributes'] = array(
'id' => $type . '-add-table',
);
$output .= theme('table', $theme_vars);
$output .= '</div>';
}
if (!empty($form['description'])) {
$output .= render($form['description']);
}
if (!empty($type_info['sortable'])) {
drupal_add_tabledrag($type . '-table', 'order', 'sibling', 'drag-position');
}
return $output;
}