extlink.module 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. * @file
  4. * This is the External Links module.
  5. */
  6. use Drupal\Component\Utility\Html;
  7. /**
  8. * Implements hook_page_attachments().
  9. */
  10. function extlink_page_attachments(array &$attachments) {
  11. $config = \Drupal::config('extlink.settings');
  12. $attachments['#attached']['library'][] = 'extlink/drupal.extlink';
  13. $attachments['#attached']['drupalSettings']['data']['extlink'] = array(
  14. 'extTarget' => $config->get('extlink_target', 0),
  15. 'extClass' => $config->get('extlink_class', 'ext'),
  16. 'extLabel' => Html::escape($config->get('extlink_label', t('(link is external)'))),
  17. 'extImgClass' => $config->get('extlink_img_class', 0),
  18. 'extSubdomains' => $config->get('extlink_subdomains', 1),
  19. 'extExclude' => $config->get('extlink_exclude', ''),
  20. 'extInclude' => $config->get('extlink_include', ''),
  21. 'extCssExclude' => $config->get('extlink_css_exclude', ''),
  22. 'extCssExplicit' => $config->get('extlink_css_explicit', ''),
  23. 'extAlert' => $config->get('extlink_alert', 0),
  24. 'extAlertText' => $config->get('extlink_alert_text', t('This link will take you to an external web site. We are not responsible for their content.')),
  25. 'mailtoClass' => $config->get('extlink_mailto_class', 'mailto'),
  26. 'mailtoLabel' => Html::escape($config->get('extlink_mailto_label', t('(link sends e-mail)'))),
  27. );
  28. }