You are here

function elf_menu in External Links Filter 5.2

Same name and namespace in other branches
  1. 5.3 elf.module \elf_menu()
  2. 5 elf.module \elf_menu()
  3. 6.3 elf.module \elf_menu()
  4. 6.2 elf.module \elf_menu()
  5. 7.3 elf.module \elf_menu()

Implementation of hook_menu().

File

./elf.module, line 6

Code

function elf_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'admin/settings/elf',
      'title' => t('External links filter'),
      'description' => t('Configure external links filter'),
      'callback' => 'drupal_get_form',
      'callback arguments' => array(
        'elf_admin_settings',
      ),
      'access' => user_access('administer site configuration'),
    );
  }
  else {
    if (variable_get('elf_css', TRUE)) {
      $path = drupal_get_path('module', 'elf');
      drupal_add_css($path . '/elf.css');
    }
    if (variable_get('elf_window', FALSE)) {
      drupal_add_js('
        $(document).ready(function() {
          // Find all external links and let them open in a new window.
          $("a.external-link").each(function() {
            $(this).click(function() {
              window.open($(this).attr("href"));
              return false;
            });
          });
        });
      ', 'inline');
    }
  }
  return $items;
}