From 20c93706900dcd0a9735881623ffc4b05fa68c79 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 13 Apr 2013 16:23:05 +0200 Subject: [PATCH] New: Support the mode readonly of ckeditor --- htdocs/comm/mailing/fiche.php | 4 ++-- htdocs/core/class/doleditor.class.php | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index 954dad26cee..1129d33605c 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -1004,7 +1004,7 @@ else { // 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=new DolEditor('body',$object->body,'',320,'dolibarr_readonly','',false,true,empty($conf->global->FCKEDITOR_ENABLE_MAILING)?0:1,20,120,1); $doleditor->Create(); } else print dol_htmlentitiesbr($object->body); @@ -1130,7 +1130,7 @@ else print ''; // Editeur wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('body',$object->body,'',320,'dolibarr_mailings','',true,true,$conf->global->FCKEDITOR_ENABLE_MAILING,20,70); + $doleditor=new DolEditor('body',$object->body,'',320,'dolibarr_mailings','',true,true,$conf->global->FCKEDITOR_ENABLE_MAILING,20,120); $doleditor->Create(); print ''; diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index f608d293ee2..40bfa0ef585 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -42,6 +42,7 @@ class DolEditor var $cols; var $height; var $width; + var $readonly; /** @@ -60,8 +61,9 @@ class DolEditor * @param int $okforextendededitor True=Allow usage of extended editor tool (like fckeditor) * @param int $rows Size of rows for textarea tool * @param int $cols Size of cols for textarea tool + * @param int $readOnly 0=Read/Edit, 1=Read only */ - function __construct($htmlname,$content,$width='',$height=200,$toolbarname='Basic',$toolbarlocation='In',$toolbarstartexpanded=false,$uselocalbrowser=true,$okforextendededitor=true,$rows=0,$cols=0) + function __construct($htmlname,$content,$width='',$height=200,$toolbarname='Basic',$toolbarlocation='In',$toolbarstartexpanded=false,$uselocalbrowser=true,$okforextendededitor=true,$rows=0,$cols=0,$readonly=0) { global $conf,$langs; @@ -75,6 +77,7 @@ class DolEditor $defaulteditor='ckeditor'; $this->tool=empty($conf->global->FCKEDITOR_EDITORNAME)?$defaulteditor:$conf->global->FCKEDITOR_EDITORNAME; $this->uselocalbrowser=$uselocalbrowser; + $this->readonly=$readonly; // Check if extended editor is ok. If not we force textarea if (empty($conf->fckeditor->enabled) || ! $okforextendededitor) $this->tool = 'textarea'; @@ -156,6 +159,7 @@ class DolEditor if (in_array($this->tool,array('textarea','ckeditor'))) { $found=1; + //$out.= ''; @@ -177,7 +181,9 @@ class DolEditor /* should be editor=CKEDITOR.replace but what if serveral editors ? */ CKEDITOR.replace(\''.$this->htmlname.'\', { + /* property:xxx is same than CKEDITOR.config.property = xxx */ customConfig : ckeditorConfig, + readOnly : '.($this->readonly?'true':'false').', htmlEncodeOutput :'.$htmlencode_force.', toolbar: \''.$this->toolbarname.'\', toolbarStartupExpanded: '.($this->toolbarstartexpanded ? 'true' : 'false').',