From ca14ebb7e80fd0e5704fd75fe14adf165be6dea4 Mon Sep 17 00:00:00 2001 From: pdontthink Date: Sun, 21 Dec 2008 09:43:22 +0000 Subject: [PATCH] Fix body onload per FIXME git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@13379 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/page_header.php | 35 +++++++++++----------- src/compose.php | 6 ++-- templates/default/page_header.tpl | 2 +- templates/default_advanced/page_header.tpl | 2 +- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/functions/page_header.php b/functions/page_header.php index 12be877b..3436a9aa 100644 --- a/functions/page_header.php +++ b/functions/page_header.php @@ -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 + * (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 */ @@ -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 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 */ - -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; -//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 ($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 - $sBodyTagJs = 'onload="checkForm();"'; + $sOnload = 'checkForm();'; } $startMessage = (int)$startMessage; @@ -226,7 +227,7 @@ function displayPageHeader($color, $mailbox='', $sHeaderJs='', $sBodyTagJs = '') $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 = ''; @@ -242,7 +243,7 @@ function displayPageHeader($color, $mailbox='', $sHeaderJs='', $sBodyTagJs = '') } else { /* do not use JavaScript */ displayHtmlHeader ($org_title); - $sBodyTagJs = ''; + $sOnload = ''; } if ($mailbox) { /* @@ -265,7 +266,7 @@ function displayPageHeader($color, $mailbox='', $sHeaderJs='', $sBodyTagJs = '') $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); @@ -303,7 +304,7 @@ function compose_Header($color, $mailbox, $sHeaderJs='', $sOnload = '') { $sOnload = 'checkForm();'; } else - $sOnload = 'checkForm();'; + $sOnload = 'checkForm();'; } @@ -329,7 +330,7 @@ function compose_Header($color, $mailbox, $sHeaderJs='', $sOnload = '') { } else { /* javascript off */ displayHtmlHeader(_("Compose")); - $onload = ''; + $sOnload = ''; } // FIXME: change the colorization attributes below to a CSS class! diff --git a/src/compose.php b/src/compose.php index f6c7a304..b2101d4f 100644 --- a/src/compose.php +++ b/src/compose.php @@ -363,11 +363,11 @@ if (sqsession_is_registered('session_expired_post')) { } else { $sHeaderJs = (isset($sHeaderJs)) ? $sHeaderJs : ''; if (strpos($action, 'reply') !== false && $reply_focus) { - $sBodyTagJs = 'onload="checkForm(\''.$replyfocus.'\');"'; + $sOnload = 'checkForm(\''.$replyfocus.'\');'; } else { - $sBodyTagJs = 'onload="checkForm();"'; + $sOnload = 'checkForm();'; } - displayPageHeader($color, $mailbox,$sHeaderJs,$sBodyTagJs); + displayPageHeader($color, $mailbox,$sHeaderJs,$sOnload); } showInputForm($session, false); exit(); diff --git a/templates/default/page_header.tpl b/templates/default/page_header.tpl index 17486a46..dc469bfd 100644 --- a/templates/default/page_header.tpl +++ b/templates/default/page_header.tpl @@ -60,7 +60,7 @@ $options_link = makeInternalLink ('src/options.php', $options_str); $help_link = makeInternalLink ('src/help.php', $help_str); ?> -> +>