--- /Users/edmund/Documents/Speed Download 4/Applications/extlink/extlink.module
+++ extlink.module
@@ -1,5 +1,5 @@
 <?php
-// $Id: extlink.module,v 1.1.2.5 2008/04/30 02:58:22 quicksketch Exp $
+// $Id: extlink.module,v 1.1.2.3 2008/01/28 00:26:48 quicksketch Exp $
 
 function extlink_menu($may_cache) {
   $items = array();
@@ -12,15 +12,29 @@
       'callback arguments' => array('extlink_admin_settings'),
       'access' => user_access('administer site configuration')
     );
+    $items[] = array(
+      'path' => 'extlink-frameset',
+      'callback' => 'extlink_frameset',
+      'access' => TRUE,
+      'type' => MENU_CALLBACK,
+    );
+    $items[] = array(
+      'path' => 'extlink-frameset-content',
+      'callback' => 'extlink_frameset_content_page',
+      'access' => TRUE,
+      'type' => MENU_CALLBACK,
+    );
   }
   else {
     $path = drupal_get_path('module', 'extlink');
+    $extlink_url = url('extlink-frameset');
     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),
-      'mailtoClass'   => variable_get('extlink_mailto_class', 'mailto'))), 'setting'
+      'extTarget'     => variable_get('extlink_target', 0), 
+      'extClass'      => variable_get('extlink_class', 'ext'), 
+      'extSubdomains' => variable_get('extlink_subdomains', 1), 
+      'mailtoClass'   => variable_get('extlink_mailto_class', 'mailto'), 
+      'extUrl'        => $extlink_url)), 'setting'
     );
 
     if (variable_get('extlink_class', 'ext') == 'ext' || variable_get('extlink_mailto_class', 'mailto') == 'mailto') {
@@ -55,14 +69,58 @@
     '#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?'),
+    '#type' => 'radios',
+    '#title' => t('Behavior for external links'),
+    '#description' => t('How should the external links be displayed?'),
+    '#options' => array('_blank' => t('Open in new window'), '_top' => t('Open in same window'), '_frame' => t('Open in split frame')),
+    '#default_value' => variable_get('extlink_target', '_blank'),
   );
-  
+  $form['extlink_frameset_content'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Split frame content'),
+    '#description' => t('The content that should be shown in the top frame. Full HTML supported.'),
+    '#cols' => 60,
+    '#rows' => 5,
+    '#default_value' => variable_get('extlink_frameset_content', ''),
+  );
+  $form['extlink_frameset_height'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Split frame height'),
+    '#description' => t('Enter frame height in pixels.'),
+    '#size' => 5,
+    '#maxlength' => 5,
+    '#default_value' => variable_get('extlink_frameset_height', 200)
+  );
+
   return system_settings_form($form);
-}
\ No newline at end of file
+}
+
+function extlink_frameset() {
+  $external_url = $_GET['url'];
+  $external_content_url = url('extlink-frameset-content');
+  $height = variable_get('extlink_frameset_height', 200);
+  print theme('extlink_frameset_page', $external_url, $external_content_url, $height);
+  exit();
+}
+
+function theme_extlink_frameset_page($external_url, $external_content_url, $height) {
+  $output .= '<frameset rows="' . $height .'px, *">';
+  $output .= '<frame src="' . $external_content_url . '">';
+  $output .= '<frame src="' . $external_url . '">';
+  $output .= '<noframes>';
+  $output .= ' Error: Either your browser does not support frames or you have them switched off. Please update or configure your browser and refresh the page.';
+  $output .= '</noframes>';
+  $output .= '</frameset>';
+  
+  return $output;
+}
+
+function extlink_frameset_content_page() {
+  print theme('extlink_frameset_content');
+  exit();
+}
+
+function theme_extlink_frameset_content() {
+  return check_markup(variable_get('extlink_frameset_content', ''), FILTER_HTML_ESCAPE);
+}
