'admin/settings/tabs', 'title' => t('Tabs'), 'description' => t('Configuration for tabs'), 'callback' => 'drupal_get_form', 'callback arguments' => array('tabs_admin_settings') ); } else { tabs_load(); } return $items; } /** * Menu callback for admin settings. */ function tabs_admin_settings() { $form = array(); $form['tabs_slide'] = array( '#type' => 'radios', '#title' => t('Slide effect'), '#description' => t('Apply slide effect when changing tabs.'), '#default_value' => variable_get('tabs_slide', 0), '#options' => array(t('disabled'), t('enabled')), ); $form['tabs_fade'] = array( '#type' => 'radios', '#title' => t('Fade effect'), '#description' => t('Apply fade effect when changing tabs.'), '#default_value' => variable_get('tabs_fade', 0), '#options' => array(t('disabled'), t('enabled')), ); $form['tabs_speed'] = array( '#type' => 'radios', '#title' => t('Effect speed'), '#description' => t('Speed at which to apply effects.'), '#default_value' => variable_get('tabs_speed', 'slow'), '#options' => array('slow' => t('slow'), 'fast' => t('fast')), ); $form['tabs_auto_height'] = array( '#type' => 'radios', '#title' => t('Fixed height'), '#description' => t('Set all tabs to have the height of the tallest tab. If not enabled, content will adjust to fit when tabs are changed. Note: fixed height is not fully compatible with slide and fade effects.'), '#default_value' => variable_get('tabs_auto_height', 0), '#options' => array(t('disabled'), t('enabled')), ); $form['tabs_navigation'] = array( '#type' => 'radios', '#title' => t('Navigation buttons'), '#description' => t('Enable to add "next" and "previous" buttons to the bottom of all tab sets.'), '#default_value' => variable_get('tabs_navigation', 0), '#options' => array(t('disabled'), t('enabled')), ); $form = system_settings_form($form); return $form; } /** * Process a tabset prior to rendering. */ function tabs_process_tabset($element) { static $names = array(); // Ensure name is unique. $i = 0; // Assign a name, reading from the first parent (the key of this tabset element). $name = $element['#tabset_name'] = ($element['#tabset_name'] ? $element['#tabset_name'] : (isset($element['#parents']) && count($element['#parents']) ? $element['#parents'][0] : 'tabset')); // In case we have duplicate names... while (in_array($element['#tabset_name'], $names)) { $element['#tabset_name'] = $name . $i; $i++; } $names[] = $element['#tabset_name']; // Add class. if (!isset($element['#attributes'])) { $element['#attributes'] = array(); } $element['#attributes']['class'] = (isset($element['#attributes']['class']) ? $element['#attributes']['class'] .' ' : '') .'drupal-tabs'. (isset($element['#tabs_navigation']) && $element['#tabs_navigation'] ? ' tabs-navigation' : ''); $index = 1; // Sort the elements by weight. // Because uasort doesn't keep the original order for equal values, // we assign a nominal weight to all elements. foreach (element_children($element) as $count => $key) { if (!isset($element[$key]['#weight']) || $element[$key]['#weight'] == 0) { $element[$key]['#weight'] = $count/1000; } } uasort($element, '_element_sort'); foreach (element_children($element) as $key) { if (isset($element[$key]['#type']) && $element[$key]['#type'] == 'tabpage') { // Display any #description before the #content. $element[$key]['#content'] = ($element[$key]['#description'] ? '