You are here

function shadowbox_construct_header in Shadowbox 6.2

Same name and namespace in other branches
  1. 5.2 shadowbox.module \shadowbox_construct_header()
  2. 5 shadowbox.module \shadowbox_construct_header()
  3. 6.4 shadowbox.module \shadowbox_construct_header()
  4. 6.3 shadowbox.module \shadowbox_construct_header()

Build the Shadowbox header by adding the necessary CSS and JS files.

1 call to shadowbox_construct_header()
shadowbox_init in ./shadowbox.module
Implementation of hook_init().

File

./shadowbox.module, line 793
Shadowbox, a JavaScript media viewer application for displaying content in a modal dialogue.

Code

function shadowbox_construct_header() {
  global $language;
  $module_path = drupal_get_path('module', 'shadowbox');
  $shadowbox_location = variable_get('shadowbox_location', $shadowbox_path);
  $images = variable_get('shadowbox_supported_images', shadowbox_get_types('image'));
  $swf = variable_get('shadowbox_supported_swf', shadowbox_get_types('swf'));
  $flv = variable_get('shadowbox_supported_flv', shadowbox_get_types('flv'));
  $quicktime = variable_get('shadowbox_supported_quicktime', shadowbox_get_types('quicktime'));
  $wmp = variable_get('shadowbox_supported_wmp', shadowbox_get_types('wmp'));
  $qtwmp = variable_get('shadowbox_supported_qtwmp', shadowbox_get_types('qtwmp'));
  $iframe = variable_get('shadowbox_supported_iframe', shadowbox_get_types('iframe'));
  $image_support = array_filter($images);
  $swf_support = array_filter($swf);
  $flv_support = array_filter($flv);
  $quicktime_support = array_filter($quicktime);
  $wmp_support = array_filter($wmp);
  $qtwmp_support = array_filter($qtwmp);
  $iframe_support = array_filter($iframe);
  if (shadowbox_active() && variable_get('shadowbox_enabled', TRUE)) {
    drupal_add_js($shadowbox_location . '/build/adapter/shadowbox-jquery.js');
    drupal_add_js($shadowbox_location . '/build/shadowbox.js');
    drupal_add_js($module_path . '/shadowbox_auto.js');
    drupal_add_js($module_path . '/shadowbox.js');
    drupal_add_js($shadowbox_location . '/src/skin/classic/skin.js');
    drupal_add_css($shadowbox_location . '/src/skin/classic/skin.css');

    // If language is set to xx (i.e. when using string overrides module) default to English.
    if ($language->language == 'xx') {
      $language->language = 'en';
    }
    $language_file = $shadowbox_location . '/build/lang/shadowbox-' . $language->language . '.js';
    if (file_exists($language_file)) {
      drupal_add_js($language_file);
    }
    else {
      drupal_set_message(t('Shadowbox: A language file does not exist for your language: !language (!code). Tried to load: !file', array(
        '!language' => $language->name,
        '!code' => $language->language,
        '!file' => $language_file,
      )), 'error');
    }
    if (!empty($image_support)) {
      drupal_add_js($shadowbox_location . '/build/player/shadowbox-img.js');
    }
    if (!empty($swf_support)) {
      drupal_add_js($shadowbox_location . '/build/player/shadowbox-swf.js');
    }
    if (!empty($flv_support)) {
      drupal_add_js($shadowbox_location . '/build/player/shadowbox-flv.js');
    }
    if (!empty($quicktime_support)) {
      drupal_add_js($shadowbox_location . '/build/player/shadowbox-qt.js');
    }
    if (!empty($wmp_support) || !empty($qtwmp_support)) {
      drupal_add_js($shadowbox_location . '/build/player/shadowbox-wmp.js');
    }
    if (!empty($iframe_support)) {
      drupal_add_js($shadowbox_location . '/build/player/shadowbox-html.js');
      drupal_add_js($shadowbox_location . '/build/player/shadowbox-iframe.js');
    }
    drupal_add_js(shadowbox_get_settings(), 'setting');
  }
}