You are here

function _textimage_vertical_tabs in Textimage 5.2

Same name and namespace in other branches
  1. 6.2 textimage_admin.inc \_textimage_vertical_tabs()
1 call to _textimage_vertical_tabs()
textimage_preset_edit in ./textimage_admin.inc

File

./textimage_admin.inc, line 464

Code

function _textimage_vertical_tabs(&$form) {
  $settings = array();

  // Iterate through the form, finding fieldsets.
  foreach (element_children($form['settings']) as $delta => $key) {

    // We need to make sure that the element we have is a fieldset
    // and the user has access to this field.
    if (isset($form['settings'][$key]['#type']) && $form['settings'][$key]['#type'] == 'fieldset' && (!isset($form['settings'][$key]['#access']) || $form['settings'][$key]['#access'] != FALSE)) {

      // Add the JavaScript.
      $settings[$key] = array(
        'name' => $form['settings'][$key]['#title'],
        'weight' => 0.01 * $delta,
      );

      // Add a class to identify the fieldset.
      if (isset($form[$key]['#attributes']['class']) && !empty($form[$key]['#attributes']['class'])) {
        $form['settings'][$key]['#attributes']['class'] .= ' vertical-tabs-fieldset vertical-tabs-' . $key;
      }
      else {
        $form['settings'][$key]['#attributes']['class'] = 'vertical-tabs-fieldset vertical-tabs-' . $key;
      }
    }
  }
  if (!empty($settings)) {
    $js = array(
      drupal_get_path('module', 'vertical_tabs') . '/vertical_tabs.node_form.js',
    );
    $css = array();

    // Add Garland specific theming.
    if (variable_get('theme_default', NULL) == 'garland' || $GLOBALS['theme'] == 'garland') {
      $garland_stylesheets = variable_get('color_garland_stylesheets', array());
      if (count($garland_stylesheets) == 0 || !module_exists('color')) {
        $css[] = drupal_get_path('module', 'vertical_tabs') . '/garland/vertical_tabs.garland.css';
      }
      else {
        foreach ($garland_stylesheets as $path) {
          if (strstr($path, 'vertical_tabs.garland.css')) {
            $css[] = $path;
          }
        }
      }
    }

    // User sort orders by the "weight" key.
    uasort($settings, '_user_sort');
    $form['settings']['vertical_tabs'] = array(
      '#vertical_tabs_settings' => $settings,
      '#vertical_tabs_js' => $js,
      '#vertical_tabs_css' => $css,
      '#form_id' => 'textimage_preset_edit',
      '#type' => 'markup',
      '#value' => '',
      '#theme' => 'vertical_tabs',
      '#attributes' => array(
        'class' => 'vertical-tabs',
      ),
    );
  }
}