You are here

function theme_page_manager_handler_rearrange in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 page_manager/theme/page_manager.theme.inc \theme_page_manager_handler_rearrange()

Turn the rearrange form into a table with tablesorting on.

File

page_manager/theme/page_manager.theme.inc, line 77
Preprocess functions for page manager editing templates.

Code

function theme_page_manager_handler_rearrange($form) {

  // Assemble the data for a table from everything in $form['handlers']
  foreach (element_children($form['handlers']) as $id) {

    // provide a reference shortcut.
    $element =& $form['handlers'][$id];
    if (isset($element['title'])) {
      $row = array();
      $row[] = array(
        'data' => drupal_render($element['title']),
        'class' => 'page-manager-handler',
      );
      $element['weight']['#attributes']['class'] = 'weight';
      $row[] = drupal_render($element['weight']);
      $rows[] = array(
        'data' => $row,
        'class' => 'draggable',
        'id' => 'page-manager-row-' . $id,
      );
    }
  }
  if (empty($rows)) {
    $rows[] = array(
      array(
        'data' => t('No task handlers are defined for this task.'),
        'colspan' => '5',
      ),
    );
  }
  $header = array(
    array(
      'data' => t('Variant'),
      'class' => 'page-manager-handler',
    ),
    t('Weight'),
  );
  drupal_add_tabledrag('page-manager-arrange-handlers', 'order', 'sibling', 'weight');
  $output = theme('table', $header, $rows, array(
    'id' => 'page-manager-arrange-handlers',
  ));
  $output .= drupal_render($form);
  return $output;
}