You are here

function collapse_text_preprocess_page in Collapse Text 6

Same name and namespace in other branches
  1. 8 collapse_text.module \collapse_text_preprocess_page()
  2. 6.2 collapse_text.module \collapse_text_preprocess_page()
  3. 7.2 collapse_text.module \collapse_text_preprocess_page()
  4. 2.0.x collapse_text.module \collapse_text_preprocess_page()

File

./collapse_text.module, line 188
collapse_text is an input filter that allows text to be collapsible

Code

function collapse_text_preprocess_page(&$variables) {
  global $theme;

  // Add collapse.js if a collapsible fieldset is found in a region or the main content.
  if (strpos($variables['scripts'], 'misc/collapse.js') === FALSE) {
    $regions = array_keys(system_region_list($theme));
    $regions[] = 'content';
    foreach ($regions as $region) {

      // Using stripos() is much faster then executing preg_match() on every page.
      if (stripos($variables[$region], '<fieldset') !== FALSE && stripos($variables[$region], 'collapsible') !== FALSE) {
        drupal_add_js('misc/collapse.js', 'core');
        $variables['scripts'] = drupal_get_js();
        return;
      }
    }
  }
}