'External links', 'description' => 'Alter the display of external links on the site.', 'page callback' => 'drupal_get_form', 'page arguments' => array('extlink_admin_settings'), 'access callback' => 'user_access', 'access arguments' => array('administer site configuration'), ); return $items; } /** * Implementation of hook_init(). */ function extlink_init() { $path = drupal_get_path('module', 'extlink'); drupal_add_js($path .'/extlink.js'); drupal_add_js(array('extlink' => 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', ''), 'extAlert' => variable_get('extlink_alert', 0), 'extAlertText' => variable_get('extlink_alert_text', 'This link will take you to an external web site. We are not responsible for their content.'), 'mailtoClass' => variable_get('extlink_mailto_class', 'mailto'))), 'setting' ); if (variable_get('extlink_class', 'ext') == 'ext' || variable_get('extlink_mailto_class', 'mailto') == 'mailto') { drupal_add_css($path . '/extlink.css'); } } function extlink_admin_settings() { $form = array(); $form['extlink_class'] = array( '#type' => 'checkbox', '#title' => t('Add icon to external links'), '#return_value' => 'ext', '#default_value' => variable_get('extlink_class', 'ext'), '#description' => t('Places an !icon icon next to external links.', array('!icon' => theme_image(array('path' => drupal_get_path('module', 'extlink') .'/extlink.png', 'alt' => t('External Links icon'), 'attributes' => array())))), ); $form['extlink_mailto_class'] = array( '#type' => 'checkbox', '#title' => t('Add icon to mailto links'), '#return_value' => 'mailto', '#default_value' => variable_get('extlink_mailto_class', 'mailto'), '#description' => t('Places an !icon icon next to mailto links.', array( '!icon' => theme_image(array( 'path' => drupal_get_path('module', 'extlink') . '/mailto.png', 'alt' => t('Email links icon'), 'attributes' => '', )), )), ); $form['extlink_subdomains'] = array( '#type' => 'checkbox', '#title' => t('Consider subdomains internal'), '#default_value' => variable_get('extlink_subdomains', 1), '#description' => t('If checked, links with the same primary domain will all be considered internal. A link from www.example.com to my.example.com would be considered internal. Links between the www. and non-www. domain are always considered internal.'), ); $form['extlink_target'] = array( '#type' => 'checkbox', '#title' => t('Open external links in a new window'), '#return_value' => '_blank', '#default_value' => variable_get('extlink_target', 0), '#description' => t('Should all external links be opened in a new window?'), ); $form['extlink_alert'] = array( '#type' => 'checkbox', '#title' => t('Display pop-up warnings'), '#return_value' => '_blank', '#default_value' => variable_get('extlink_alert', 0), '#description' => t('Displays a pop-up warning when any external link is clicked.'), ); $form['extlink_alert_text'] = array( '#type' => 'textarea', '#rows' => 3, '#title' => t('Pop-up warning text'), '#default_value' => variable_get('extlink_alert_text', 'This link will take you to an external web site. We are not responsible for their content.'), '#description' => t('Text to display in the pop-up external link warning box.'), '#wysiwyg' => FALSE, ); $patterns = array( '(example\.com) ' . t('Matches example.com.'), '(example\.com)|(example.net) ' . t('Multiple patterns can be strung together by using a pipe. Matches example.com OR example.net.'), '(links/goto/[0-9]+/[0-9]+) ' . t('Matches links that go through the Links module redirect.'), ); $wildcards = array( '. ' . t('Matches any character.'), '? ' . t('The previous character or set is optional.'), '\d ' . t('Matches any digit (0-9).'), '[a-z] ' . t('Brackets may be used to match a custom set of characters. This matches any alphabetic letter.'), ); $form['patterns'] = array( '#tree' => FALSE, '#type' => 'fieldset', '#title' => t('Pattern matching'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#description' => '
' . t('External links uses patterns (regular expressions) to match the "href" property of links.') . '
' . t('Here are some common patterns.') . theme('item_list', $patterns) . t('Common special characters:') . theme('item_list', $wildcards) . '' . t('All special characters (^ $ . ? ( ) | * +) must also be escaped with backslashes. Patterns are not case-sensitive. Any pattern supported by JavaScript may be used.') . '
', ); $form['patterns']['extlink_exclude'] = array( '#type' => 'textfield', '#title' => t('Exclude links matching the pattern'), '#maxlength' => NULL, '#default_value' => variable_get('extlink_exclude', ''), '#description' => t('Enter a regular expression for links that you wish to exclude from being considered external.'), ); $form['patterns']['extlink_include'] = array( '#type' => 'textfield', '#title' => t('Include links matching the pattern'), '#maxlength' => NULL, '#default_value' => variable_get('extlink_include', ''), '#description' => t('Enter a regular expression for internal links that you wish to be considered external.'), ); return system_settings_form($form); }