You are here

function theme_ctools_context_item_form in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 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 56
Contains theme registry and theme implementations for the context tool.

Code

function theme_ctools_context_item_form($form) {
  $output = '';
  $type = $form['#ctools_context_type'];
  $module = $form['#ctools_context_module'];
  $name = $form['#object_name'];
  $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;
      }
      $rows .= theme('ctools_context_item_row', $type, $form[$type][$id], $id, $count++);
    }
    $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' => drupal_render($form['buttons'][$type]['item']),
      'class' => 'title',
    );
    $row[] = array(
      'data' => drupal_render($form['buttons'][$type]['add']),
      'class' => 'add',
      'width' => "60%",
    );
    $output .= '<div class="buttons">';
    $output .= drupal_render($form['buttons'][$type]);
    $output .= theme('table', array(), array(
      $row,
    ), array(
      'id' => $type . '-add-table',
    ));
    $output .= '</div>';
  }
  if (!empty($form['description'])) {
    $output .= drupal_render($form['description']);
  }
  if (!empty($type_info['sortable'])) {
    drupal_add_tabledrag($type . '-table', 'order', 'sibling', 'drag-position');
  }
  return $output;
}