Skip to content

Commit

Permalink
FIX : bug #1840 Email template modules in HTML are not render correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
FHenry committed Feb 11, 2015
1 parent ddb95e5 commit 7f5e4aa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
10 changes: 6 additions & 4 deletions htdocs/core/class/doleditor.class.php
Expand Up @@ -43,6 +43,7 @@ class DolEditor
var $height;
var $width;
var $readonly;
var $allowed_content;


/**
Expand All @@ -62,8 +63,9 @@ class DolEditor
* @param int $rows Size of rows for textarea tool
* @param int $cols Size of cols for textarea tool (textarea number of cols or %)
* @param int $readonly 0=Read/Edit, 1=Read only
* @param int $allowed_content 0=filter input text, 1=render as it is
*/
function __construct($htmlname,$content,$width='',$height=200,$toolbarname='Basic',$toolbarlocation='In',$toolbarstartexpanded=false,$uselocalbrowser=true,$okforextendededitor=true,$rows=0,$cols=0,$readonly=0)
function __construct($htmlname,$content,$width='',$height=200,$toolbarname='Basic',$toolbarlocation='In',$toolbarstartexpanded=false,$uselocalbrowser=true,$okforextendededitor=true,$rows=0,$cols=0,$readonly=0,$allowed_content=0)
{
global $conf,$langs;

Expand Down Expand Up @@ -132,6 +134,7 @@ function __construct($htmlname,$content,$width='',$height=200,$toolbarname='Basi
$this->cols = (preg_match('/%/',$cols)?$cols:max(40,$cols)); // If $cols is a percent, we keep it, otherwise, we take max
$this->height = $height;
$this->width = $width;
$this->allowed_content = $allowed_content;
}

}
Expand Down Expand Up @@ -163,16 +166,14 @@ function Create($noprint=0,$morejs='')
$out.= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" rows="'.$this->rows.'"'.(preg_match('/%/',$this->cols)?' style="width: '.$this->cols.'"':' cols="'.$this->cols.'"').' class="flat">';
$out.= $this->content;
$out.= '</textarea>';

if ($this->tool == 'ckeditor')
{
if (! defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR','1');

//$skin='kama';
$skin='moono'; // default with cdeditor 4

$htmlencode_force=preg_match('/_encoded$/',$this->toolbarname)?'true':'false';

$out.= '<script type="text/javascript">
$(document).ready(function () {
/* if (CKEDITOR.loadFullCore) CKEDITOR.loadFullCore(); */
Expand All @@ -181,6 +182,7 @@ function Create($noprint=0,$morejs='')
{
/* property:xxx is same than CKEDITOR.config.property = xxx */
customConfig : ckeditorConfig,
allowedContent :'.($this->allowed_content?'true':'false').',
readOnly : '.($this->readonly?'true':'false').',
htmlEncodeOutput :'.$htmlencode_force.',
toolbar: \''.$this->toolbarname.'\',
Expand Down
16 changes: 14 additions & 2 deletions htdocs/core/class/html.formmail.class.php
Expand Up @@ -582,7 +582,12 @@ function get_form($addfileaction='addfile',$removefileaction='removefile')
if (! empty($this->withbody))
{
$defaultmessage="";
if (count($arraydefaultmessage) > 0 && $arraydefaultmessage['content']) $defaultmessage=$arraydefaultmessage['content'];
$from_template=false;
if (count($arraydefaultmessage) > 0 && $arraydefaultmessage['content']) {
$defaultmessage=$arraydefaultmessage['content'];
$from_template=true;

}
elseif (! is_numeric($this->withbody)) $defaultmessage=$this->withbody;

// Complete substitution array
Expand Down Expand Up @@ -611,6 +616,13 @@ function get_form($addfileaction='addfile',$removefileaction='removefile')
$this->substit['__SIGNATURE__'] = dol_nl2br($this->substit['__SIGNATURE__']);
} else if(!dol_textishtml($defaultmessage) && dol_textishtml($this->substit['__SIGNATURE__'])) {
$defaultmessage = dol_nl2br($defaultmessage);
}

if (dol_textishtml($defaultmessage) && $from_template) {
$allow_content=1;
var_dump($allow_content);
} else {
$allow_content=0;
}


Expand Down Expand Up @@ -643,7 +655,7 @@ function get_form($addfileaction='addfile',$removefileaction='removefile')
else $this->withfckeditor=0;
}

$doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,72);
$doleditor=new DolEditor('message',$defaultmessage,'',280,$this->ckeditortoolbar,'In',true,true,$this->withfckeditor,8,72,0,$allow_content);
$out.= $doleditor->Create(1);
}
$out.= "</td></tr>\n";
Expand Down

0 comments on commit 7f5e4aa

Please sign in to comment.