You are here

function extlink_init in External Links 6

Implements hook_init().

File

./extlink.module, line 22

Code

function extlink_init() {
  $path = drupal_get_path('module', 'extlink');
  $settings = array(
    'extTarget' => variable_get('extlink_target', 0),
    'extClass' => variable_get('extlink_class', 'ext'),
    'extSubdomains' => variable_get('extlink_subdomains', 1),
    'extExclude' => variable_get('extlink_exclude', ''),
    'extInclude' => variable_get('extlink_include', ''),
    'extCssExclude' => variable_get('extlink_css_exclude', ''),
    'extCssExplicit' => variable_get('extlink_css_explicit', ''),
    'extAlert' => variable_get('extlink_alert', 0),
    'extAlertText' => variable_get('extlink_alert_text', NULL),
    'mailtoClass' => variable_get('extlink_mailto_class', 'mailto'),
  );

  // The default alert text must be translated separately to avoid caching.
  if ($settings['extAlertText'] === NULL) {
    $settings['extAlertText'] = t('This link will take you to an external web site. We are not responsible for their content.');
  }
  drupal_add_js($path . '/extlink.js');
  drupal_add_js(array(
    'extlink' => $settings,
  ), 'setting');
  if (variable_get('extlink_class', 'ext') == 'ext' || variable_get('extlink_mailto_class', 'mailto') == 'mailto') {
    drupal_add_css($path . '/extlink.css');
  }
}