--- popups.install.orig	2008-03-06 21:32:50.000000000 +0100
+++ popups.install	2008-11-03 01:41:17.000000000 +0100
@@ -2,9 +2,14 @@
 // $Id: popups.install,v 1.4 2008/03/06 20:32:50 starbow Exp $
 
 /**
+ * @file
+ * Install hook for popups module
+ */
+
+/**
  * Implementation of hook_install().
  *
- * Ensures private_upload runs after theme 
+ * Ensures private_upload runs after theme
  * Expiremental - go last.
  */
 function popups_install() {
--- popups.module.orig	2008-10-30 22:05:05.000000000 +0100
+++ popups.module	2008-11-03 01:41:17.000000000 +0100
@@ -2,17 +2,16 @@
 // $Id: popups.module,v 1.11.2.11 2008/10/30 21:05:05 starbow Exp $
 
 /**
- * @file popups.module
- *
+ * @file
  * This module uses popup modal dalogs to enhance the Administration Pages by allowing pages
  *  to be shown inside modual dialogs.
- * It also provides a hook_popups for other pages that want to use this functionality. 
+ * It also provides a hook_popups for other pages that want to use this functionality.
  *
- * @todo 
+ * @todo
  * * Adding Javascript into popups doesn't always work.
- * *   tabledrag onmouse up action. 
+ * *   tabledrag onmouse up action.
  * *   user.js and teaser.js bugs.
- * * Cache the results of hook_popups.
+ * * Cache results of popups hook call.
  * * Taxonomy > Add vocab.  Adding second item to page does not trigger d-n-d transformation.
  *     Might be a problem with Taxonomy.  Menus doesn't have problem (adds d-n-d on first item).
  */
@@ -23,20 +22,20 @@
 // **************************************************************************
 
 /**
- * hook_menu
+ * Implementation of hook_menu().
  *
  * @return array of new menu items.
  */
 function popups_menu() {
-   
+
   // Themable page save dialog.
   $items['popups/save_dialog'] = array(
     'page callback' => 'theme',
     'page arguments' => array('popup_save_dialog'),
     'access callback' => TRUE,
     'type' => MENU_CALLBACK,
-  );  
-  
+  );
+
   // Admin Settings.
   $items['admin/settings/popups'] = array(
     'page callback' => 'drupal_get_form',
@@ -44,8 +43,8 @@ function popups_menu() {
     'title' => 'Popups',
     'access arguments' => array('administer site configuration'),
     'description' => 'Configure the page-in-a-dialog behavior.',
-  ); 
-  
+  );
+
   // Items for testing.
   $items['popups/test'] = array(
     'title' => 'Popup Test',
@@ -64,25 +63,26 @@ function popups_menu() {
     'type' => MENU_CALLBACK,
     'access callback' => TRUE,
   );
-  
+
   return $items;
 }
 
 /**
- * hook_init
- * 
+ * Implementation of hook_init().
+ *
  * Look at the page path and see if popup behavior has been requested for any links in this page.
  */
-function popups_init() {  
+function popups_init() {
   $popups = popups_get_popups();
-  if (isset($popups[$_GET['q']]) || variable_get('popups_always_scan', 0)) {
+  if (isset($popups[$_GET['q']])) {
     popups_add_popups($popups[$_GET['q']]);
   }
-  
-  if (isset($_SERVER['HTTP_X_DRUPAL_RENDER_MODE'])) {
-    $render_mode = $_SERVER['HTTP_X_DRUPAL_RENDER_MODE'];
+  elseif (variable_get('popups_always_scan', 0)) {
+    popups_add_popups();
   }
-  
+
+  $render_mode = isset($_SERVER['HTTP_X_DRUPAL_RENDER_MODE']) ? $_SERVER['HTTP_X_DRUPAL_RENDER_MODE'] : '';
+
   // Check and see if the page_override param is in the URL.
   // Note - the magic happens here.
   // Need to cache the page_override flag in the session, so it will effect
@@ -95,36 +95,36 @@ function popups_init() {  
   if (isset($_SESSION['page_override'])) {
     // This call will not return on form submission.
     $content = menu_execute_active_handler();
-    
-    // The call did return, so it wasn't a form request, 
+
+    // The call did return, so it wasn't a form request,
     // so we are returning a result, so clear the session flag.
     $override = $_SESSION['page_override'];
     unset($_SESSION['page_override']);
-       
+
     // Menu status constants are integers; page content is a string.
     if (isset($content) && !is_int($content) && isset($override)) {
-      print popups_render_as_json($content); 
+      print popups_render_as_json($content);
       exit;  // Do not continue processing request in index.html.
-    }    
+    }
   }
-  
+
 }
 
 /**
- * hook_theme
+ * Implementation of hook_theme().
  *
  */
-function popups_theme($existing, $type) {  
+function popups_theme($existing, $type) {
   return array(
     'popups_popup' => array(
       'template' => 'popups-popup',
 //      'arguments' => array('content' => NULL),
     ),
-    'popups_save_dialog' => array(),      
+    'popups_save_dialog' => array(),
   );
 }
 
-function popups_render_as_json($content) { 
+function popups_render_as_json($content) {
   $path = $_GET['q']; // Get current path from params.
   return drupal_json(array(
     'title' => drupal_get_title(),
@@ -135,22 +135,22 @@ function popups_render_as_json($content)
 }
 
 /**
- * hook_form_alter
- * 
+ * Implementation of hook_form_alter().
+ *
  * Look at the form_id and see if popup behavior has been requested for any links in this form.
  *
  * @param form_array $form
  * @param array $form_state
- * @param str $form_id: 
+ * @param str $form_id:
  */
 function popups_form_alter(&$form, $form_state, $form_id) {
   // Add popup behavior to the form if requested.
   $popups = popups_get_popups();
   if (isset($popups[$form_id])) {
     popups_add_popups($popups[$form_id]);
-  } 
+  }
 
-  // Alter the theme configuration pages, to add a per-theme-content selector. 
+  // Alter the theme configuration pages, to add a per-theme-content selector.
   $theme = arg(4);
   if ($form_id == 'system_theme_settings' && $theme) {
     $form['popups'] = array(
@@ -163,11 +163,11 @@ function popups_form_alter(&$form, $form
       '#title' => t('Content Selector'),
       '#default_value' => variable_get('popups_'. $theme .'_content_selector', 'div.left-corner > div.clear-block:last'),
       '#description' => t("jQuery selector to define the page's content area on this theme."),
-    ); 
+    );
     $form['popups']['popups_theme'] = array(
       '#type' => 'hidden',
       '#value' => $theme,
-    ); 
+    );
     $form['#submit'][] = 'popups_theme_settings_form_submit';
   }
 }
@@ -185,7 +185,7 @@ function popups_theme_settings_form_subm
 
 /**
  * Build the list of popup rules from all modules that implement hook_popups.
- * 
+ *
  * @todo - Add some caching so we don't rebuild everytime.
  */
 function popups_get_popups() {
@@ -198,7 +198,7 @@ function popups_get_popups() {
 
 /**
  * Attach the popup behavior to the page.
- * 
+ *
  * The default behavoir of a popup is to open a form that will modify the original page.  The popup submits
  * the form and reloads the original page with the resulting new content. The popup then replaces
  * the original page's content area with the new copy of that content area.
@@ -211,25 +211,25 @@ function popups_get_popups() {
  *   forceReturn: url to force a stop to work flow (only use in conjunction with noReload).
  *   href: override the href in the a element, or attach an href to a non-link element.
  *   width: override the width specified in the css.
- *   additionalJavascript: Array of JavaScript files that must be included to correctly run the page in the popup. 
- *   additionalCss: Array of CSS files that must be included to correctly style the page in the popup. 
- *  
+ *   additionalJavascript: Array of JavaScript files that must be included to correctly run the page in the popup.
+ *   additionalCss: Array of CSS files that must be included to correctly style the page in the popup.
+ *
  * Rule Format Example:
- * 'admin/content/taxonomy' => array( // Act only on the links on this page. 
+ * 'admin/content/taxonomy' => array( // Act only on the links on this page.
  *   'div#tabs-wrapper a:eq(1)',  // No options, so use defaults. Note: Selectors must select <a> element(s).
- *   'table td:nth-child(2) a' => array( 
+ *   'table td:nth-child(2) a' => array(
  *     'noReload' => true, // Popup will not modify original page.
  *   ),
  * )
- * 
+ *
  */
-function popups_add_popups($rules=null) { 
+function popups_add_popups($rules = NULL) {
   static $added = FALSE;
   $settings = array('popups' => array());
-  
+
   if (is_array($rules)) {
     $settings['popups']['links'] = array();
-    foreach ($rules as $popup_selector => $options) { 
+    foreach ($rules as $popup_selector => $options) {
       if (is_array($options)) {
         $settings['popups']['links'][$popup_selector] = $options;
         if (isset($options['additionalJavascript']) && is_array($options['additionalJavascript'])) {
@@ -247,7 +247,7 @@ function popups_add_popups($rules=null) 
         $settings['popups']['links'][$options] = array();
       }
     }
-    if($added) {
+    if ($added) {
       drupal_add_js( $settings, 'setting' );
     }
   }
@@ -256,15 +256,15 @@ function popups_add_popups($rules=null) 
     drupal_add_css(drupal_get_path('module', 'popups') .'/popups-skin.css');
     drupal_add_js(drupal_get_path('module', 'popups') .'/popups.js');
     drupal_add_js('misc/jquery.form.js');
-    
+
     // Determing if we are showing the default theme or a custom theme.
     global $custom_theme;
     $theme = $custom_theme;
     if (!$theme) {
-      $theme = variable_get('theme_default','none');
+      $theme = variable_get('theme_default', 'none');
     }
     $defaultTargetSelector = variable_get('popups_'. $theme .'_content_selector', 'div.left-corner > div.clear-block:last');
-    
+
     $settings['popups']['defaultTargetSelector'] = $defaultTargetSelector;
     $settings['popups']['template'] = theme('popups_popup');
     $settings['popups']['modulePath'] = drupal_get_path('module', 'popups');
@@ -272,13 +272,13 @@ function popups_add_popups($rules=null) 
     drupal_add_js( $settings, 'setting' );
     $added = TRUE;
   }
-  
+
 
 }
 
 /**
- * hook_popups
- * 
+ * Implementation of hook_popups().
+ *
  * This implements hook_popups, defined in popups_get_popups.
  * See the comments in popups_add_popups for explination of the options.
  * Adding popup behavior to the core admin pages has been moved to popups_admin.
@@ -286,14 +286,14 @@ function popups_add_popups($rules=null) 
  * @return: Array of link selectors to apply popup behavior to.
  *          Keyed by path or form_id.
  */
-function popups_popups() {   
+function popups_popups() {
   return array(
     'popups/test' => array( // test page.
-      '#test-popup' => array( 
+      '#test-popup' => array(
         'additionalJavascript' => array('misc/collapse.js'),
         'forceReturn' => 'node/add/story',
       ),
-    ),  
+    ),
   );
 }
 
@@ -315,7 +315,7 @@ function popups_admin_settings() {
     '#title' => t('Do NOT auto-close final message.'),
     '#default_value' => variable_get('popups_popup_final_message', 1),
   );
-  
+
   return system_settings_form($form);
 }
 
@@ -326,42 +326,39 @@ function popups_admin_settings() {
 function _popups_test_popups() {
   popups_add_popups();
   $output = '<ul id="test-list">';
-  $output .= '<li>'. l("Pop up entire local page.", 'popups/test/response', 
-               array('attributes' => array('class' => 'popups')));
-  $output .= "<li>". l("Pop with options (href override).", 'popups/test/', 
-               array('attributes' => array('class' => 'popups', 'on-popups-options' => '{href: "test/response"}')));
-  $output .= "<li>". l("Pop with options (width=200px).", 'popups/test/response', 
-               array('attributes' => array('class' => 'popups', 'on-popups-options' => '{width: "200px"}')));
+  $output .= '<li>'. l("Pop up entire local page.", 'popups/test/response',
+    array('attributes' => array('class' => 'popups')));
+  $output .= "<li>". l("Pop with options (href override).", 'popups/test/',
+    array('attributes' => array('class' => 'popups', 'on-popups-options' => '{href: "test/response"}')));
+  $output .= "<li>". l("Pop with options (width=200px).", 'popups/test/response',
+    array('attributes' => array('class' => 'popups', 'on-popups-options' => '{width: "200px"}')));
   $output .= "<li class=\"popups\" on-popups-options=\"{href: 'test/response'}\">Non-link popup</li>";
   $output .= '<li>'. l("Add Story (hook).", 'node/add/story',
-               array( 'attributes' => array('id' => 'test-popup')));
+    array( 'attributes' => array('id' => 'test-popup')));
   $output .= '<li>'. l("Add Story (attribute).", 'node/add/story',
-               array( 'attributes' => array('class' => 'popups-form')));
-  $output .= '<li>'. l("Change Settings: " . (variable_get('popups_popup_final_message', 1) ? 'on' : 'off'), 
-                       'admin/settings/popups',
-                       array( 'attributes' => array('class' => 'popups-form'),
-                              'query' => array('destination' => 'popups/test'),
-                     ));
-//  popups_add_popups(array('#change-settings'=>array('titleSelector'=>'#page-title')));       
-  $output .= '<li>'. l("Change Settings and cold reload page.", 
-                       'admin/settings/popups',
-                       array( 'attributes' => array('class' => 'popups'),
-                              'query' => array('destination' => 'popups/test'),
-                     ));
-                     
-  $output .= '<li>'. l("Change Settings and cherry pick.", 'admin/settings/popups',
-             array( 'attributes' => array(
-                'id' => 'foo',
-                'class' => 'popups-form',
-                'on-popups-options' => '{targetSelectors: {"label": "#foo", "label:first": "#test-list li:first"}, forceReturn: "admin/settings/popups"}')));
-  $output .= '<li>'. l("Pop up defined by popups_add_popups rule.", 'popups/test/response', 
-                     array('attributes' => array('id' => 'rule-test')));
-  popups_add_popups(array('#rule-test'=>array('width'=>'300px')));       
-  $output .= '<li>'. l("Change Page Title.", 'popups/test/namechange', 
-                     array('attributes' => array('id' => 'title-test')));
-  popups_add_popups(array('#title-test'=>array('titleSelectors'=>array('#page-title'), 'forceReturn'=>'popups/test/namechange')));       
-  
-  $output .= "</ul>";                
+    array( 'attributes' => array('class' => 'popups-form')));
+  $output .= '<li>'. l("Change Settings: " . (variable_get('popups_popup_final_message', 1) ? 'on' : 'off'),
+    'admin/settings/popups', array('attributes' => array('class' => 'popups-form'),
+    'query' => array('destination' => 'popups/test')));
+//  popups_add_popups(array('#change-settings'=>array('titleSelector'=>'#page-title')));
+  $output .= '<li>'. l("Change Settings and cold reload page.", 'admin/settings/popups',
+    array( 'attributes' => array('class' => 'popups'), 'query' => array('destination' => 'popups/test')));
+
+  $output .= '<li>'. l("Change Settings and cherry pick.", 'admin/settings/popups', array(
+    'attributes' => array(
+      'id' => 'foo',
+      'class' => 'popups-form',
+      'on-popups-options' => '{targetSelectors: {"label": "#foo", "label:first": "#test-list li:first"}, forceReturn: "admin/settings/popups"}',
+    ),
+  ));
+  $output .= '<li>'. l("Pop up defined by popups_add_popups rule.", 'popups/test/response',
+    array('attributes' => array('id' => 'rule-test')));
+  popups_add_popups(array('#rule-test' => array('width' => '300px')));
+  $output .= '<li>'. l("Change Page Title.", 'popups/test/namechange',
+    array('attributes' => array('id' => 'title-test')));
+  popups_add_popups(array('#title-test' => array('titleSelectors' => array('#page-title'), 'forceReturn' => 'popups/test/namechange')));
+
+  $output .= "</ul>";
   return $output;
 }
 
@@ -378,6 +375,6 @@ function _popups_test_namechange() {
     '#type' => 'submit',
     '#value' => t('Test Name Change'),
   );
-  
+
   return $form;
 }
--- popups-popup.tpl.php.orig	2008-09-15 03:48:52.000000000 +0200
+++ popups-popup.tpl.php	2008-11-03 01:41:18.000000000 +0100
@@ -1,5 +1,10 @@
 <?php
 // $Id: popups-popup.tpl.php,v 1.1.2.4 2008/09/15 01:48:52 starbow Exp $
+
+/**
+ * @file
+ * Popups module template
+ */
 ?>
 <div id="popups">
   <div id="popups-title">
