You are here

function theme_qt_tabs in Quick Tabs 6

Same name and namespace in other branches
  1. 5 quicktabs.module \theme_qt_tabs()

theme the form elements for the tabs as draggable table rows

1 theme call to theme_qt_tabs()
quicktabs_form in ./quicktabs.module
build the Quick Tabs creation and edit form

File

./quicktabs.module, line 334

Code

function theme_qt_tabs($form) {
  drupal_add_tabledrag('qt-tablist-table', 'order', 'sibling', 'qt-tabs-weight');
  $rows = array();
  $headers = array(
    t('Tab Title'),
    t('Weight'),
    module_exists('views') ? t('Tab type') : '',
    t('Content'),
  );
  foreach (element_children($form) as $key) {

    // No need to print the field title every time.
    unset($form[$key]['tabtext']['#title'], $form[$key]['tabtype']['#title'], $form[$key]['bvid']['#title']);
    $form[$key]['tabweight']['#attributes']['class'] = 'qt-tabs-weight';

    // Build the table row.
    $row = array(
      'data' => array(
        array(
          'data' => drupal_render($form[$key]['tabtext']),
          'class' => 'qt-tab-title',
        ),
        array(
          'data' => drupal_render($form[$key]['tabweight']),
          'class' => 'qt-tab-weight',
        ),
        module_exists('views') ? array(
          'data' => drupal_render($form[$key]['tabtype']),
          'class' => 'qt-tab-type',
        ) : array(
          'data' => '',
          'class' => 'qt-tabtype-hidden',
        ),
        array(
          'data' => drupal_render($form[$key]['bid']) . drupal_render($form[$key]['hide_title']) . (module_exists('views') ? drupal_render($form[$key]['vid']) . drupal_render($form[$key]['args']) . drupal_render($form[$key]['limit']) . drupal_render($form[$key]['display']) . drupal_render($form[$key]['get_displays']) : ''),
          'class' => 'qt-tab-bvid',
        ),
      ),
      'class' => 'draggable',
    );

    // Add additional attributes to the row, such as a class for this row.
    if (isset($form[$key]['#attributes'])) {
      $row = array_merge($row, $form[$key]['#attributes']);
    }
    $rows[] = $row;
  }
  $output = theme('table', $headers, $rows, array(
    'id' => 'qt-tablist-table',
  ));
  $output .= drupal_render($form);
  return $output;
}