diff --git a/classes/facteur.php b/classes/facteur.php index 9548408..c3809f3 100755 --- a/classes/facteur.php +++ b/classes/facteur.php @@ -94,8 +94,6 @@ class Facteur extends PHPMailer { $message_html = unicode_to_utf_8(charset2unicode($message_html,$GLOBALS['meta']['charset'])); $this->Body = $message_html; $this->IsHTML(true); - if ($GLOBALS['meta']['facteur_filtre_css']) - $this->ConvertirStylesEnligne(); if ($GLOBALS['meta']['facteur_filtre_images']) $this->JoindreImagesHTML(); $this->UrlsAbsolues(); @@ -276,168 +274,11 @@ class Facteur extends PHPMailer { } + /** + * Compat ascendante, obsolete + */ function ConvertirStylesEnligne() { - /* - - Written by Eric Dols - edols@auditavenue.com - - You may freely use or modify this, provided - you leave credits to the original coder. - Feedback about (un)successfull uses, bugs and improvements done - are much appreciated, but don't expect actual support. - - PURPOSE OF THIS FUNCTION - It is designed to process html emails relying - on a css stylesheet placed in the for layout in - order to enhance compatibility with email clients, - including webmail services. - Provided you use minimal css, you can keep styling separate - from the content in your email template, and let this function - "inject" those styles inline in your email html tags on-the-fly, - just before sending. - Technically, it grabs the style declarations found in the - section and inserts each declaration inline, - inside the corresponding html tags in the email message. - - Supports both HTML and XHTML markup seamlessly. Thus - tolerant to email message writers using non-xhtml tag, - even when template is xhtml compliant (e.g. they would - add instead of a xhtml compliant ). - - NEW 10 dec. 2003: - - code revised, including a few regexp bugs fixed. - - multiple class for a tag are now allowed

- - all unsupported css styles are now moved to the body section (not just a:hover etc...) - - USE - Add this function to a function library include, like "inline.inc" - and include it near the beginning of your php page: - require ("inline.inc"); - - load the html source of message into a variable - like $html_source and process it using: - $html_source = sheet2inline($html_source) - - - STYLE DEFINITIONS SUPPORTED - TAG { ... } - TAG1, TAG2, ... { ... } - TAG.class { ... } - .class { ...) - TAG:pseudo { ... } - - - CSS definitions may be freely formatted (spaces, tabs, linefeeds...), - they are converted to oneliners before inserting them inline in the html tags. - - .class definitions are processed AFTER tag definitions, - thus appended inline after any existing tag styling to - preserve the normal css priority behavior. - - Existing style="..." attributes in tags are NOT stripped. However they MUST - be with double quotes. If not, an addtional style="..." attribute will be added - - - KNOWN LIMITATIONS - - style info should be placed in section. I believe - it shouldnt be too hard to modify to point to an external - stylesheet instead. - - no support (yet?): - * chains like P UL LI { .... } or P UL LI.class { .... } - * #divname p { ... } and - * a:hover, a:visited {...} multiple class:pseudo - They require a significantly more complicated processing likely - based on stylesheet and document trees parsing. - Many email clients don't handle more than what is supported - by this script anyway. - - pseudo-classes like a:hover {...} can't be inserted inline - in the html tags: they are moved to a \n", $this->Body); - } - // append a copy of the pseudo-element declaration to that body style section - $styledefinition = trim($styles[5][$i]); - $styledefinition = preg_replace ("!\s+!mi", " ", $styledefinition ); // convert style definition to a one-liner (optional) - $declaration = $styles[1][$i].trim($styles[2][$i]).$styles[3][$i].trim($styles[4][$i])." { ".$styledefinition." }"; - $this->Body = preg_replace ("!(]*>\s*]*>\s*<\!\-\-[^>]*)"."(\s*\-\->\s*)!si", "\$1".$declaration."\n\$2", $this->Body); - $styles[6][$i]= 2; // mark as moved to (.*)!si", "\$1\$2" , $this->Body); - - // check what styles have been injected -# print_r($styles); - + $this->Body = facteur_convertir_styles_inline($this->Body); } diff --git a/facteur_fonctions.php b/facteur_fonctions.php index 3aaa329..9de4876 100755 --- a/facteur_fonctions.php +++ b/facteur_fonctions.php @@ -8,6 +8,170 @@ if (!defined("_ECRIRE_INC_VERSION")) return; + /* + + Written by Eric Dols - edols@auditavenue.com + + You may freely use or modify this, provided + you leave credits to the original coder. + Feedback about (un)successfull uses, bugs and improvements done + are much appreciated, but don't expect actual support. + + PURPOSE OF THIS FUNCTION + It is designed to process html emails relying + on a css stylesheet placed in the for layout in + order to enhance compatibility with email clients, + including webmail services. + Provided you use minimal css, you can keep styling separate + from the content in your email template, and let this function + "inject" those styles inline in your email html tags on-the-fly, + just before sending. + Technically, it grabs the style declarations found in the + section and inserts each declaration inline, + inside the corresponding html tags in the email message. + + Supports both HTML and XHTML markup seamlessly. Thus + tolerant to email message writers using non-xhtml tag, + even when template is xhtml compliant (e.g. they would + add instead of a xhtml compliant ). + + NEW 10 dec. 2003: + - code revised, including a few regexp bugs fixed. + - multiple class for a tag are now allowed

+ - all unsupported css styles are now moved to the body section (not just a:hover etc...) + + USE + Add this function to a function library include, like "inline.inc" + and include it near the beginning of your php page: + require ("inline.inc"); + + load the html source of message into a variable + like $html_source and process it using: + $html_source = sheet2inline($html_source) + + + STYLE DEFINITIONS SUPPORTED + TAG { ... } + TAG1, TAG2, ... { ... } + TAG.class { ... } + .class { ...) + TAG:pseudo { ... } + + + CSS definitions may be freely formatted (spaces, tabs, linefeeds...), + they are converted to oneliners before inserting them inline in the html tags. + + .class definitions are processed AFTER tag definitions, + thus appended inline after any existing tag styling to + preserve the normal css priority behavior. + + Existing style="..." attributes in tags are NOT stripped. However they MUST + be with double quotes. If not, an addtional style="..." attribute will be added + + + KNOWN LIMITATIONS + - style info should be placed in section. I believe + it shouldnt be too hard to modify to point to an external + stylesheet instead. + - no support (yet?): + * chains like P UL LI { .... } or P UL LI.class { .... } + * #divname p { ... } and + * a:hover, a:visited {...} multiple class:pseudo + They require a significantly more complicated processing likely + based on stylesheet and document trees parsing. + Many email clients don't handle more than what is supported + by this script anyway. + - pseudo-classes like a:hover {...} can't be inserted inline + in the html tags: they are moved to a \n", $body); + } + // append a copy of the pseudo-element declaration to that body style section + $styledefinition = trim($styles[5][$i]); + $styledefinition = preg_replace ("!\s+!mi", " ", $styledefinition ); // convert style definition to a one-liner (optional) + $declaration = $styles[1][$i].trim($styles[2][$i]).$styles[3][$i].trim($styles[4][$i])." { ".$styledefinition." }"; + $body = preg_replace ("!(]*>\s*]*>\s*<\!\-\-[^>]*)"."(\s*\-\->\s*)!si", "\$1".$declaration."\n\$2", $body); + $styles[6][$i]= 2; // mark as moved to (.*)!si", "\$1\$2" , $body); + + // check what styles have been injected +# print_r($styles); + + return $body; +} + /** * facteur_addstyle * @author Eric Dols diff --git a/formulaires/configurer_facteur.html b/formulaires/configurer_facteur.html index 1639c9c..5411b6d 100644 --- a/formulaires/configurer_facteur.html +++ b/formulaires/configurer_facteur.html @@ -118,17 +118,12 @@ <:facteur:facteur_filtres:>