From baf543ec3a00d254c5fe0ffc46e12b469f6d966d Mon Sep 17 00:00:00 2001 From: "cedric@yterium.com" <> Date: Thu, 21 Jun 2012 15:06:50 +0000 Subject: [PATCH] Le reglage configurable "Transformer les styles contenus entre
en des styles en ligne" n'a pas de sens en tant que filtre systematique applique a tous les mails : - il casse les mails faits mains sur mesure (comme le wrapper html des emails texte du plugin) car incapable de gerer les @media - il peut etre utile sur certains mails html simples - il est a utiliser au cas par cas, et c'est le webmestre qui code son mail html qui peut le savoir, pas l'admin qui configure le site et utilise simplement En consequence, le reglage disparait de la configuration et n'est plus pris en compte Par compatibilite la methode ConvertirStylesEnligne de la classe Facteur reste disponible, mais tout son code est deporte dans le filtre facteur_convertir_styles_inline que l'on appellera au cas par cas dans les squelettes HTML par un appel #FILTRE{facteur_convertir_styles_inline} Ainsi on preserve son usage quand necessaire, sans plus risque de casser les emails HTML bien fichus On incremente la version en 2.2.0 pour marquer la difference fonctionnelle --- classes/facteur.php | 167 +--------------------------- facteur_fonctions.php | 164 +++++++++++++++++++++++++++ formulaires/configurer_facteur.html | 5 - formulaires/configurer_facteur.php | 2 - paquet.xml | 2 +- 5 files changed, 169 insertions(+), 171 deletions(-) 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- - 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+ - 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<:facteur:facteur_filtres_descriptif:>