You are here

function fieldset_helper_preprocess_html in Fieldset helper 7.2

File

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

Code

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

  // Only use regular expression fieldset counting if no fieldsets are found
  if (fieldset_helper_number_of_collapsible_fieldset() !== 0) {
    return;
  }

  // Reset fieldset counter.
  fieldset_helper_number_of_collapsible_fieldset(0, TRUE);
  $regions = array(
    'page_top',
    'page',
    'page_bottom',
  );
  foreach ($regions as $region) {
    if (!isset($variables[$region]) || !isset($variables[$region]['#children'])) {
      continue;
    }
    $html = $variables[$region]['#children'];
    if (stripos($html, '<fieldset') !== FALSE && ($count = preg_match_all('/<fieldset[^>]+class="[^"]*collapsible/', $html, $mat))) {
      fieldset_helper_number_of_collapsible_fieldset($count);
      return;
    }
  }
}