From: pdontthink Date: Wed, 7 Feb 2007 20:34:28 +0000 (+0000) Subject: Add body tag template; stop outputting body tags directly from core (there are still... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=5bcce0502df20ab7ce4e3ca2faa5cce53ad9e7a6;p=squirrelmail.git Add body tag template; stop outputting body tags directly from core (there are still a couple places that need to be updated to use this) git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@12239 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/html.php b/functions/html.php index d1850788..41f38bd5 100644 --- a/functions/html.php +++ b/functions/html.php @@ -201,10 +201,43 @@ function create_span($value, $class='', $id='', $aAttribs=array()) { } +/** + * Generates an opening body tag + * + * @param string $onload Body onload JavaScript handler code + * (OPTIONAL; default not used) + * @param string $class The CSS class name (OPTIONAL; default + * not used) + * @param array $aAttribs Any extra attributes: this must be an + * associative array, where keys will be + * added as the attribute name, and values + * (which are optional - should be null if + * none should be used) will be placed in + * double quotes (pending template implementation) + * as the attribute value (OPTIONAL; default empty). + * + * @return string The desired body tag. + * + * @since 1.5.2 + * + */ +function create_body($onload='', $class='', $aAttribs=array()) { + + global $oTemplate; + + $oTemplate->assign('onload', $onload); + $oTemplate->assign('class', $class); + + $oTemplate->assign('aAttribs', $aAttribs); + + return $oTemplate->fetch('body.tpl'); + +} + + /** * Generates html tags -//FIXME: this should not be used anywhere in the core, or we should -// convert this to use templates. We sould not be assuming HTML output. +//FIXME: This should not be used anywhere in the core, or we should convert this to use templates. We sould not be assuming HTML output. * * @param string $tag Tag to output * @param string $val Value between tags @@ -282,14 +315,19 @@ function html_tag( $tag, // Tag to output /** * handy function to set url vars +//FIXME: You call this documentation? :-) What does "set url vars" mean? Looks like it might take a fully-formed URI (possibly with a query string) and adds a variable/value pair to it(?)... Does $link work on only the var being added or the whole URI? * * especially useful when $url = $PHP_SELF + * * @param string $url url that must be modified * @param string $var variable name * @param string $val variable value * @param boolean $link controls sanitizing of ampersand in urls (since 1.3.2) + * * @return string $url modified url + * * @since 1.3.0 + * */ function set_url_var($url, $var, $val=0, $link=true) { $k = ''; diff --git a/functions/page_header.php b/functions/page_header.php index dbccb756..3420c882 100644 --- a/functions/page_header.php +++ b/functions/page_header.php @@ -188,6 +188,7 @@ function displayPageHeader($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') { $provider_name, $provider_uri, $startMessage, $action, $oTemplate, $org_title, $base_uri; +//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 (strpos($action, 'reply') !== FALSE && $reply_focus) { if ($reply_focus == 'select') @@ -268,24 +269,25 @@ function displayPageHeader($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') { * @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 compose_Header($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') { +function compose_Header($color, $mailbox, $sHeaderJs='', $sOnload = '') { global $reply_focus, $action, $oTemplate; - 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();'; } @@ -313,6 +315,12 @@ function compose_Header($color, $mailbox, $sHeaderJs='', $sBodyTagJs = '') { displayHtmlHeader(_("Compose")); $onload = ''; } -// FIXME: should let the template echo all these kinds of things - echo "\n\n"; + +// FIXME: change the colorization attributes below to a CSS class! + $class = ''; + $aAttribs = array('text' => $color[8], 'bgcolor' => $color[4], + 'link' => $color[7], 'vlink' => $color[7], + 'alink' => $color[7]); + echo create_body($sOnload, $class, $aAttribs); + } diff --git a/templates/default/body.tpl b/templates/default/body.tpl new file mode 100644 index 00000000..7d2947f0 --- /dev/null +++ b/templates/default/body.tpl @@ -0,0 +1,42 @@ + $value) { + echo ' ' . $key . (is_null($value) ? '' : '="' . $value . '"'); +} +echo '>'; + +if (!empty($plugin_output['body_after'])) echo $plugin_output['body_after']; +