? page-terms_of_use_popup.tpl.php
? terms_of_use.js
Index: terms_of_use.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/terms_of_use/terms_of_use.module,v
retrieving revision 1.1.2.26
diff -u -p -r1.1.2.26 terms_of_use.module
--- terms_of_use.module	15 May 2010 13:05:40 -0000	1.1.2.26
+++ terms_of_use.module	3 Jul 2010 11:47:50 -0000
@@ -74,6 +74,12 @@ function terms_of_use_admin_settings() {
   $form['terms_of_use_form'] = array(
     '#type' => 'fieldset',
   );
+  $form['terms_of_use_form']['terms_of_use_fieldset_enabled'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Use a fieldset'),
+    '#default_value' => variable_get('terms_of_use_fieldset_enabled', 1),
+    '#description' => t('Check this if you like to use a fieldset.'),
+  );
   $form['terms_of_use_form']['terms_of_use_fieldset_name'] = array(
     '#type' => 'textfield',
     '#title' => t('Label for the fieldset'),
@@ -86,7 +92,31 @@ function terms_of_use_admin_settings() {
     '#default_value' => variable_get('terms_of_use_checkbox_label', t('I agree with these terms.')),
     '#description' => t('Type here something like "I agree with these terms." or "I CERTIFY THAT I AM OVER THE AGE OF 18 YEARS OLD.", without quotes. You can use the token @link to insert a link to the Terms in this label. For example, the label can be: "I agree with the @link.", without quotes. You may want to link to the Terms if you prefer not to show the full text of the Terms in the registration form. If you use the token, the Terms will not be shown.'),
   );
+  $form['terms_of_use_form']['terms_of_use_link_target'] = array(
+    '#type' => 'radios',
+    '#title' => t('Target'),
+    '#options' => array(
+      '_self' => t('Same window'),
+      '_blank' => t('New window using the \'target="_blank"\' attribute.'),
+      'popup' => t('New popup window using javasvript.'),
+    ),
+    '#default_value' => variable_get('terms_of_use_link_target', '_self'),
+    '#description' => t('Check this if you like to open the terms of use node in a separate popup.'),
+  );
+  $form['terms_of_use_form']['terms_of_use_popup_width'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Popup width'),
+    '#default_value' => variable_get('terms_of_use_popup_width', 450),
+    '#description' => t('Set a width for the popup window.'),
+  );
+  $form['terms_of_use_form']['terms_of_use_popup_height'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Popup height'),
+    '#default_value' => variable_get('terms_of_use_popup_height', 600),
+    '#description' => t('Set a height for the popup window.'),
+  );
 
+  drupal_add_js(drupal_get_path('module', 'terms_of_use') .'/terms_of_use.js');
   return system_settings_form($form);
 }
 
@@ -144,12 +174,14 @@ function terms_of_use_form_user_register
     variable_get('terms_of_use_checkbox_label', t('I agree with these terms.'))
   ));
 
-  // Adding the fieldset.
-  $form['terms_of_use'] = array(
-    '#type' => 'fieldset',
-    '#title' => $fieldset_name,
-    '#weight' => 10,
-  );
+  if (variable_get('terms_of_use_fieldset_enabled', 1)) {
+    // Adding the fieldset.
+    $form['terms_of_use'] = array(
+      '#type' => 'fieldset',
+      '#title' => $fieldset_name,
+      '#weight' => 10,
+    );
+  }
 
   $show_terms = TRUE;
 
@@ -171,7 +203,17 @@ function terms_of_use_form_user_register
     if ($node->nid) {
       // Show terms on the registration for or just a link?s
       if (strpos($checkbox_label, '@link') !== FALSE) {
-        $checkbox_label = str_replace('@link', l($node->title, 'node/' . $node->nid), $checkbox_label);
+        $options = array();
+        $target = variable_get('terms_of_use_link_target', '_self');
+        if ($target == 'popup') {
+          $width = variable_get('terms_of_use_popup_width', 600);
+          $height = variable_get('terms_of_use_popup_height', 800);
+          $options['attributes']['onclick'] = "window.open(this.href + '?terms_of_use_popup=1', 'terms_of_use', 'width=$width,height=$height'); return false;";
+        }
+        elseif ($target == '_blank') {
+          $options['attributes']['target'] = 'blank';
+        }
+        $checkbox_label = str_replace('@link', l($node->title, 'node/' . $node->nid, $options), $checkbox_label);
         $show_terms = FALSE;
       }
       // Adding the nodes body by theme_terms_of_use() to the fieldset if desired.
@@ -255,6 +297,26 @@ function theme_terms_of_use($terms, $nod
   return $output;
 }
 
+
+/**
+ * Implementation of hook_preprocess_page().
+ */
+function terms_of_use_theme_registry_alter(&$theme_registry) {
+  // Add the module diretory to the theme paths in order to use a custom page template file (page-terms_of_use_popup.tpl.php).
+  // @see terms_of_use_preprocess_page()
+  $theme_registry['page']['theme paths'][] = drupal_get_path('module', 'terms_of_use');
+}
+
+/**
+ * Implementation of hook_preprocess_page().
+ */
+function terms_of_use_preprocess_page(&$variables) {
+  // If the current page is opened in a popup, use the custom page template.
+  if (($_GET['q'] == 'node/'. variable_get('terms_of_use_node_id', 0)) && ($_GET['terms_of_use_popup'])) {
+    $variables['template_files'][] = 'page-terms_of_use_popup';
+  }
+}
+
 /**
  * Implementation of hook_locale().
  */
