You are here

function theme_quicktabs_admin_form_tabs in Quick Tabs 6.2

Same name and namespace in other branches
  1. 6.3 includes/admin.inc \theme_quicktabs_admin_form_tabs()
  2. 7.3 quicktabs.admin.inc \theme_quicktabs_admin_form_tabs()
  3. 7.2 includes/admin.inc \theme_quicktabs_admin_form_tabs()

Theme function for quicktabs admin page. Theme the form elements for the tabs as draggable table rows.

1 theme call to theme_quicktabs_admin_form_tabs()
_qt_admin_main_form in includes/admin.inc

File

includes/admin.inc, line 308

Code

function theme_quicktabs_admin_form_tabs($form) {
  drupal_add_tabledrag('qt-tablist-table', 'order', 'sibling', 'qt-tabs-weight');
  $rows = array();
  $headers = array(
    t('Tab title'),
    t('Tab weight'),
    t('Tab type'),
    t('Tab content'),
    t('Operations'),
  );
  foreach (element_children($form) as $key) {
    $form[$key]['weight']['#attributes']['class'] = 'qt-tabs-weight';

    // Build the table row.
    $row = array(
      'data' => array(
        array(
          'data' => drupal_render($form[$key]['title']),
          'class' => 'qt-tab-title',
        ),
        array(
          'data' => drupal_render($form[$key]['weight']),
          'class' => 'qt-tab-weight',
        ),
        array(
          'data' => drupal_render($form[$key]['type']),
          'class' => 'qt-tab-type',
        ),
        // tab content (only 1 tab content (block, node or view) will be displayed. see: quicktabs_form.js)
        array(
          'data' => drupal_render($form[$key]['block']),
          'class' => 'qt-tab-content qt-tab-block-content',
        ),
        array(
          'data' => module_exists('views') ? drupal_render($form[$key]['view']) : '',
          'class' => 'qt-tab-content qt-tab-view-content',
        ),
        array(
          'data' => drupal_render($form[$key]['node']),
          'class' => 'qt-tab-content qt-tab-node-content',
        ),
        array(
          'data' => drupal_render($form[$key]['qtabs']),
          'class' => 'qt-tab-content qt-tab-qtabs-content',
        ),
        array(
          'data' => drupal_render($form[$key]['remove']),
          'class' => 'qt-tab-remove',
        ),
      ),
      '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);

  // Add our JS file, which has some Drupal core JS overrides, and ensures ahah behaviours get re-attached
  drupal_add_js(drupal_get_path('module', 'quicktabs') . '/js/quicktabs_ahah.js', 'module', 'footer');
  drupal_add_js(drupal_get_path('module', 'quicktabs') . '/js/quicktabs_form.js');
  drupal_add_css(drupal_get_path('module', 'quicktabs') . '/css/quicktabs-admin.css');
  return $output;
}