From b3d4811b6fa0e8b5a81d95737c5cba2c7630eb80 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 24 Mar 2013 19:00:58 +0100 Subject: [PATCH] New: Another method to allow style tags into email. Preivous one was using encoding, but this create data to not be stored correctly into database. Old method is still available by adding '_encoded' at end of toolbar name. --- htdocs/comm/mailing/fiche.php | 29 ++++--- htdocs/core/class/doleditor.class.php | 12 +-- htdocs/main.inc.php | 10 +-- htdocs/theme/eldy/ckeditor/config.js | 7 ++ htdocs/user/fiche.php | 118 +++++++++++++------------- 5 files changed, 98 insertions(+), 78 deletions(-) diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index b0f32a3e69d..0147ec57dff 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -23,6 +23,8 @@ * \brief Fiche mailing, onglet general */ +if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); + require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -768,7 +770,7 @@ else $linkback = ''.$langs->trans("BackToList").''; - print ''.$langs->trans("Ref").''; + print ''.$langs->trans("Ref").''; print ''; print $form->showrefnav($object,'id', $linkback); print ''; @@ -789,10 +791,10 @@ else print ''; // Status - print ''.$langs->trans("Status").''.$object->getLibStatut(4).''; + print ''.$langs->trans("Status").''.$object->getLibStatut(4).''; // Nb of distinct emails - print ''; + print ''; print $langs->trans("TotalNbOfDistinctRecipients"); print ''; $nbemail = ($object->nbemail?$object->nbemail:img_warning('').' '.$langs->trans("NoTargetYet").''); @@ -979,7 +981,7 @@ else print ''; // Subject - print ''; + print ''; // Joined files print ''; print ''; print ''; @@ -1040,7 +1049,7 @@ else print ''; - print '
'.$langs->trans("MailTopic").''.$object->sujet.'
'.$langs->trans("MailTopic").''.$object->sujet.'
'.$langs->trans("MailFile").''; @@ -1007,7 +1009,14 @@ else // Message print '
'.$langs->trans("MailMessage").''; - print dol_htmlentitiesbr($object->body); + if (empty($object->bgcolor) || strtolower($object->bgcolor) == 'ffffff') + { + // Editeur wysiwyg + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor('body',$object->body,'',320,'dolibarr_readonly','',false,true,empty($conf->global->FCKEDITOR_ENABLE_MAILING)?0:1,20,70); + $doleditor->Create(); + } + else print dol_htmlentitiesbr($object->body); print '
'; print $langs->trans("TotalNbOfDistinctRecipients"); print ''; - $nbemail = ($object->nbemail?$object->nbemail:''.$langs->trans("NoTargetYet").''); + $nbemail = ($object->nbemail?$object->nbemail:img_warning('').' '.$langs->trans("NoTargetYet").''); if (!empty($conf->global->MAILING_LIMIT_SENDBYWEB) && is_numeric($nbemail) && $conf->global->MAILING_LIMIT_SENDBYWEB < $nbemail) { $text=$langs->trans('LimitSendingEmailing',$conf->global->MAILING_LIMIT_SENDBYWEB); @@ -1142,13 +1151,13 @@ else $doleditor->Create(); print '
'; + print '
'; + + print '
'; print ''; print '   '; print ''; - print ''; - - print ''; + print '
'; print ''; print '
'; diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 9256e08318c..55cc984c12f 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -51,7 +51,7 @@ class DolEditor * @param string $content Content of WYSIWIG field * @param int $width Width in pixel of edit area (auto by default) * @param int $height Height in pixel of edit area (200px by default) - * @param string $toolbarname Name of bar set to use ('Full', 'dolibarr_notes', 'dolibarr_details', 'dolibarr_mailings') + * @param string $toolbarname Name of bar set to use ('Full', 'dolibarr_notes[_encoded]', 'dolibarr_details[_encoded]', 'dolibarr_mailings[_encoded]', ') * @param string $toolbarlocation Where bar is stored : * 'In' each window has its own toolbar * 'Out:name' share toolbar into the div called 'name' @@ -69,6 +69,7 @@ class DolEditor if (! $rows) $rows=round($height/20); if (! $cols) $cols=($width?round($width/6):80); + $shorttoolbarname=preg_replace('/_encoded$/','',$toolbarname); // Name of extended editor to use (FCKEDITOR_EDITORNAME can be 'ckeditor' or 'fckeditor') $defaulteditor='ckeditor'; @@ -97,7 +98,7 @@ class DolEditor $this->editor->Value = $content; $this->editor->Height = $height; if (! empty($width)) $this->editor->Width = $width; - $this->editor->ToolbarSet = $toolbarname; + $this->editor->ToolbarSet = $shorttoolbarname; $this->editor->Config['AutoDetectLanguage'] = 'true'; $this->editor->Config['ToolbarLocation'] = $toolbarlocation ? $toolbarlocation : 'In'; $this->editor->Config['ToolbarStartExpanded'] = $toolbarstartexpanded; @@ -124,7 +125,7 @@ class DolEditor { $this->content = $content; $this->htmlname = $htmlname; - $this->toolbarname = $toolbarname; + $this->toolbarname = $shorttoolbarname; $this->toolbarstartexpanded = $toolbarstartexpanded; $this->rows = max(ROWS_3,$rows); $this->cols = max(40,$cols); @@ -169,9 +170,8 @@ class DolEditor //$skin='office2003'; //$skin='v2'; $skin='kama'; - - if ($this->toolbarname=='dolibarr_mailings') {$htmlencode_force='true';} - else {$htmlencode_force='false';} + + $htmlencode_force=preg_match('/_encoded$/',$this->toolbarname)?'true':'false'; $out.= '