You are here

function theme_quickbar_form in Quickbar 7

Same name and namespace in other branches
  1. 6 quickbar.admin.inc \theme_quickbar_form()
  2. 7.2 quickbar.admin.inc \theme_quickbar_form()

Theme handler for quickbar_form()

See also

theme_quickbar_form()

File

./quickbar.admin.inc, line 166
Handles quickbar administration

Code

function theme_quickbar_form($variables) {
  $form = $variables['form'];
  $output = drupal_render($form['intro']);
  drupal_add_tabledrag('quickbar-role-order', 'order', 'sibling', 'quickbar-role-order-weight');
  $header = array(
    t('Role'),
    t('Assigned Menu'),
    t('Weight'),
    t('Operations'),
  );

  // Build the table rows.
  $rows = array();
  foreach (element_children($form) as $item) {
    $element =& $form[$item];

    // Build a list of operations.
    $operations = array(
      drupal_render($element['operations']),
    );

    // Add special class to be used with tabledrag.js
    if (isset($element['weight'])) {
      $element['weight']['#attributes']['class'] = array(
        'quickbar-role-order-weight',
      );
    }
    if (isset($element['rid'])) {
      $row = array();
      $row[] = drupal_render($element['title']);
      $row[] = drupal_render($element['menu']);
      $row[] = drupal_render($element['weight']);
      $row = array_merge($row, $operations);
      $row = array(
        'data' => $row,
      );
      $row['class'][] = 'draggable';
      $rows[] = $row;
    }
  }
  $output .= theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'id' => 'quickbar-role-order',
    ),
  ));
  $output .= drupal_render_children($form);
  return $output;
}