Fix body onload per FIXME
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 21 Dec 2008 09:43:22 +0000 (09:43 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 21 Dec 2008 09:43:22 +0000 (09:43 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@13379 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/page_header.php
src/compose.php
templates/default/page_header.tpl
templates/default_advanced/page_header.tpl

index 12be877beacb810354184395c2040db50f85a39c..3436a9aaba1e06ceb206d0dbac9352ae9854814c 100644 (file)
@@ -166,6 +166,8 @@ EOS;
  * Given a path to a SquirrelMail file, return a HTML link to it
  *
  * @param string path the SquirrelMail file to link to
  * Given a path to a SquirrelMail file, return a HTML link to it
  *
  * @param string path the SquirrelMail file to link to
+ *               (should start with something like "src/..." or
+ *               "functions/..." or "plugins/..." etc.)
  * @param string text the link text
  * @param string target the target frame for this link
  */
  * @param string text the link text
  * @param string target the target frame for this link
  */
@@ -193,29 +195,28 @@ function makeInternalLink($path, $text, $target='') {
  * @param array color the array of theme colors
  * @param string mailbox the current mailbox name to display
  * @param string sHeaderJs javascipt code to be inserted in a script block in the header
  * @param array color the array of theme colors
  * @param string mailbox the current mailbox name to display
  * @param string sHeaderJs javascipt code to be inserted in a script block in the header
- * @param string sBodyTagJs js events to be inserted in the body tag
+ * @param string sOnload JavaScript code to be added inside the body's onload handler
+ *                       as of 1.5.2, this replaces $sBodyTagJs argument
  * @return void
  */
  * @return void
  */
-
-function displayPageHeader($color, $mailbox='', $sHeaderJs='', $sBodyTagJs = '') {
+function displayPageHeader($color, $mailbox='', $sHeaderJs='', $sOnload = '') {
 
     global $reply_focus, $hide_sm_attributions, $frame_top,
         $provider_name, $provider_uri, $startMessage,
         $action, $oTemplate, $org_title, $base_uri,
         $data_dir, $username;
 
 
     global $reply_focus, $hide_sm_attributions, $frame_top,
         $provider_name, $provider_uri, $startMessage,
         $action, $oTemplate, $org_title, $base_uri,
         $data_dir, $username;
 
-//FIXME: $sBodyTag should be turned into $sOnload and should only contain the contents of the onload attribute (not the attribute name nor any quotes).... only question is if anyone was using $sBodyTag for anything but onload event handlers? (see function compose_Header() below for how to fix it once we confirm it can be changed)
-    if (empty($sBodyTagJs)) {
+    if (empty($sOnload)) {
         if (strpos($action, 'reply') !== FALSE && $reply_focus) {
         if (strpos($action, 'reply') !== FALSE && $reply_focus) {
-        if ($reply_focus == 'select')
-            $sBodyTagJs = 'onload="checkForm(\'select\');"';
-        else if ($reply_focus == 'focus')
-            $sBodyTagJs = 'onload="checkForm(\'focus\');"';
-        else if ($reply_focus != 'none')
-            $sBodyTagJs = 'onload="checkForm();"';
+            if ($reply_focus == 'select')
+                $sOnload = 'checkForm(\'select\');';
+            else if ($reply_focus == 'focus')
+                $sOnload = 'checkForm(\'focus\');';
+            else if ($reply_focus != 'none')
+                $sOnload = 'checkForm();';
         }
         else
         }
         else
-        $sBodyTagJs = 'onload="checkForm();"';
+            $sOnload = 'checkForm();';
     }
 
     $startMessage = (int)$startMessage;
     }
 
     $startMessage = (int)$startMessage;
@@ -226,7 +227,7 @@ function displayPageHeader($color, $mailbox='', $sHeaderJs='', $sBodyTagJs = '')
         $frame_top = '_top';
     }
 
         $frame_top = '_top';
     }
 
-//FIXME: does checkForJavascript() make the 2nd part of the if() below unneccessary??
+//FIXME: does checkForJavascript() make the 2nd part of the if() below unneccessary?? (that is, I think checkForJavascript() might already look for new_js_autodetect_results...(?))
     if( checkForJavascript() || strpos($sHeaderJs, 'new_js_autodetect_results.value') ) {
         $js_includes = $oTemplate->get_javascript_includes(TRUE);
         $sJsBlock = '';
     if( checkForJavascript() || strpos($sHeaderJs, 'new_js_autodetect_results.value') ) {
         $js_includes = $oTemplate->get_javascript_includes(TRUE);
         $sJsBlock = '';
@@ -242,7 +243,7 @@ function displayPageHeader($color, $mailbox='', $sHeaderJs='', $sBodyTagJs = '')
     } else {
         /* do not use JavaScript */
         displayHtmlHeader ($org_title);
     } else {
         /* do not use JavaScript */
         displayHtmlHeader ($org_title);
-        $sBodyTagJs = '';
+        $sOnload = '';
     }
     if ($mailbox) {
         /*
     }
     if ($mailbox) {
         /*
@@ -265,7 +266,7 @@ function displayPageHeader($color, $mailbox='', $sHeaderJs='', $sBodyTagJs = '')
         $provider_link = create_hyperlink($provider_uri, $provider_name, '_blank');
     }
 
         $provider_link = create_hyperlink($provider_uri, $provider_name, '_blank');
     }
 
-    $oTemplate->assign('body_tag_js', $sBodyTagJs);
+    $oTemplate->assign('onload', $sOnload);
     $oTemplate->assign('shortBoxName', $shortBoxName);
     $oTemplate->assign('provider_link', $provider_link);
     $oTemplate->assign('frame_top', $frame_top);
     $oTemplate->assign('shortBoxName', $shortBoxName);
     $oTemplate->assign('provider_link', $provider_link);
     $oTemplate->assign('frame_top', $frame_top);
@@ -303,7 +304,7 @@ function compose_Header($color, $mailbox, $sHeaderJs='', $sOnload = '') {
                 $sOnload = 'checkForm();';
         }
         else
                 $sOnload = 'checkForm();';
         }
         else
-        $sOnload = 'checkForm();';
+            $sOnload = 'checkForm();';
     }
 
 
     }
 
 
@@ -329,7 +330,7 @@ function compose_Header($color, $mailbox, $sHeaderJs='', $sOnload = '') {
     } else {
         /* javascript off */
         displayHtmlHeader(_("Compose"));
     } else {
         /* javascript off */
         displayHtmlHeader(_("Compose"));
-        $onload = '';
+        $sOnload = '';
     }
 
 // FIXME: change the colorization attributes below to a CSS class!
     }
 
 // FIXME: change the colorization attributes below to a CSS class!
index f6c7a3047ece10e533b20a0eb3ccc8d87c69d94e..b2101d4f727232c3ef8af0d8094231b56167c66e 100644 (file)
@@ -363,11 +363,11 @@ if (sqsession_is_registered('session_expired_post')) {
     } else {
         $sHeaderJs = (isset($sHeaderJs)) ? $sHeaderJs : '';
         if (strpos($action, 'reply') !== false && $reply_focus) {
     } else {
         $sHeaderJs = (isset($sHeaderJs)) ? $sHeaderJs : '';
         if (strpos($action, 'reply') !== false && $reply_focus) {
-            $sBodyTagJs = 'onload="checkForm(\''.$replyfocus.'\');"';
+            $sOnload = 'checkForm(\''.$replyfocus.'\');';
         } else {
         } else {
-            $sBodyTagJs = 'onload="checkForm();"';
+            $sOnload = 'checkForm();';
         }
         }
-        displayPageHeader($color, $mailbox,$sHeaderJs,$sBodyTagJs);
+        displayPageHeader($color, $mailbox,$sHeaderJs,$sOnload);
     }
     showInputForm($session, false);
     exit();
     }
     showInputForm($session, false);
     exit();
index 17486a46bff30b5444729e7993ddf75b336f8e20..dc469bfd5b6837b252737a5016fb4abb33236616 100644 (file)
@@ -60,7 +60,7 @@ $options_link = makeInternalLink ('src/options.php', $options_str);
 $help_link             = makeInternalLink ('src/help.php', $help_str);
 
 ?>
 $help_link             = makeInternalLink ('src/help.php', $help_str);
 
 ?>
-<body <?php echo $body_tag_js; ?>>
+<body <?php if (!empty($onload)) echo ' onload="' . $onload . '"'; ?>>
 <div id="page_header">
 <a name="pagetop"></a>
 <?php if (!empty($plugin_output['page_header_top'])) echo $plugin_output['page_header_top']; ?>
 <div id="page_header">
 <a name="pagetop"></a>
 <?php if (!empty($plugin_output['page_header_top'])) echo $plugin_output['page_header_top']; ?>
index 4913d6c29c70900ab1b926e09b7faa1a65b17f0b..185a6744b5e0d53f8895a65ddd9f0c708a02ed45 100644 (file)
@@ -60,7 +60,7 @@ $options_link = makeInternalLink ('src/options.php', $options_str);
 $help_link             = makeInternalLink ('src/help.php', $help_str);
 
 ?>
 $help_link             = makeInternalLink ('src/help.php', $help_str);
 
 ?>
-<body <?php echo $body_tag_js; ?>>
+<body <?php if (!empty($onload)) echo ' onload="' . $onload . '"'; ?>>
 <?php
 
    /** if preview pane turned on, do not show menubar above message */
 <?php
 
    /** if preview pane turned on, do not show menubar above message */