You are here

function fieldset_helper_preprocess_page in Fieldset helper 7.2

Same name and namespace in other branches
  1. 6.2 fieldset_helper.theme.inc \fieldset_helper_preprocess_page()

Implements hook_preprocess_page().

File

./fieldset_helper.theme.inc, line 95
Theme functions for fieldset helper module

Code

function fieldset_helper_preprocess_page(&$variables) {
  if (!user_access('save fieldset state')) {
    return;
  }

  // Count collapsible fieldsets in admin/modules
  if (isset($variables['page']['content']['system_main']['modules'])) {
    foreach (array_keys($variables['page']['content']['system_main']['modules']) as $key) {
      if (strpos($key, '#') !== 0) {
        fieldset_helper_number_of_collapsible_fieldset(1);
      }
    }
  }

  // Add toggle all.
  $number_of_collapsible_fieldsets = fieldset_helper_number_of_collapsible_fieldset();
  $minimum = variable_get('fieldset_helper_toggle_all_minimum', 2);
  if ($number_of_collapsible_fieldsets >= $minimum) {
    if ($output = fieldset_helper_toggle_all_output()) {
      $variables['page']['content']['fieldset_helper_toggle_all'] = array(
        '#children' => fieldset_helper_toggle_all_output(),
        '#weight' => -1000,
      );
      $variables['page']['content']['#sorted'] = FALSE;
    }
  }
}