Enhancement to allow other editor than fckeditor

This commit is contained in:
Laurent Destailleur 2011-01-31 19:28:35 +00:00
parent 50558c334d
commit ec8870cf16
3 changed files with 19 additions and 15 deletions

View File

@ -26,6 +26,8 @@
* \version $Revision$ * \version $Revision$
*/ */
if (! defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR','1');
require("../main.inc.php"); require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
@ -154,9 +156,11 @@ foreach($modules as $const => $desc)
print '</tr>'; print '</tr>';
} }
print '</table>'; print '</table>'."\n";
print '<br>';
print '<br>'."\n";
print '<!-- Editor name = '.$conf->global->FCKEDITOR_EDITORNAME.' -->';
print_fiche_titre($langs->trans("TestSubmitForm"),'',''); print_fiche_titre($langs->trans("TestSubmitForm"),'','');
print '<form name="formtest" method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n"; print '<form name="formtest" method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
$editor=new DolEditor('formtestfield',isset($conf->global->FCKEDITOR_TEST)?$conf->global->FCKEDITOR_TEST:'Test',200,'dolibarr_notes','In', true); $editor=new DolEditor('formtestfield',isset($conf->global->FCKEDITOR_TEST)?$conf->global->FCKEDITOR_TEST:'Test',200,'dolibarr_notes','In', true);

View File

@ -29,8 +29,6 @@
* \version $Id$ * \version $Id$
*/ */
if (! defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR','1');
require("../main.inc.php"); require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'); require_once(DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php');
require_once(DOL_DOCUMENT_ROOT."/includes/modules/propale/modules_propale.php"); require_once(DOL_DOCUMENT_ROOT."/includes/modules/propale/modules_propale.php");

View File

@ -66,10 +66,11 @@ class DolEditor
dol_syslog("DolEditor::DolEditor htmlname=".$htmlname." tool=".$tool); dol_syslog("DolEditor::DolEditor htmlname=".$htmlname." tool=".$tool);
$this->tool='fckeditor'; // By default // Name of extended editor to use
$this->tool=empty($conf->global->FCKEDITOR_EDITORNAME)?'fckeditor':$conf->global->FCKEDITOR_EDITORNAME;
// Check fckeditor is ok // Check if extended editor is ok. If not we force textarea
if ($this->tool == 'fckeditor' && (empty($conf->fckeditor->enabled) || ! $okforextandededitor || $conf->global->MAIN_USE_CKEDITOR)) if (empty($conf->fckeditor->enabled) || ! $okforextandededitor)
{ {
$this->tool = 'textarea'; $this->tool = 'textarea';
} }
@ -105,7 +106,8 @@ class DolEditor
$this->editor->Config['SkinPath'] = DOL_URL_ROOT.'/theme/'.$conf->theme.'/fckeditor/'; $this->editor->Config['SkinPath'] = DOL_URL_ROOT.'/theme/'.$conf->theme.'/fckeditor/';
} }
} }
if ($this->tool == 'textarea')
if (in_array($this->tool,array('textarea','ckeditor')))
{ {
$this->content = $content; $this->content = $content;
$this->htmlname = $htmlname; $this->htmlname = $htmlname;
@ -114,6 +116,7 @@ class DolEditor
$this->height = $height; $this->height = $height;
$this->width = 600; $this->width = 600;
} }
} }
@ -131,16 +134,15 @@ class DolEditor
$found=1; $found=1;
$this->editor->Create(); $this->editor->Create();
} }
if ($this->tool == 'textarea') if (in_array($this->tool,array('textarea','ckeditor')))
{ {
$found=1; $found=1;
$cssclass='flat'; $cssclass='flat';
//if ($conf->global->MAIN_USE_CKEDITOR) $cssclass='ckeditor';
print '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" rows="'.$this->rows.'" cols="'.$this->cols.'" class="'.$cssclass.'">'; print '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" rows="'.$this->rows.'" cols="'.$this->cols.'" class="'.$cssclass.'">';
print $this->content; print $this->content;
print '</textarea>'; print '</textarea>';
if ($conf->global->MAIN_USE_CKEDITOR) if ($this->tool == 'ckeditor')
{ {
print '<script type="text/javascript">'; print '<script type="text/javascript">';
print 'CKEDITOR.replace(\''.$this->htmlname.'\', { toolbar: \'Basic\', width: '.$this->width.', height: '.$this->height.', toolbarStartupExpanded: false });'; print 'CKEDITOR.replace(\''.$this->htmlname.'\', { toolbar: \'Basic\', width: '.$this->width.', height: '.$this->height.', toolbarStartupExpanded: false });';
@ -150,7 +152,7 @@ class DolEditor
if (empty($found)) if (empty($found))
{ {
print 'Error, unknown value for tool in DolEditor constructor.'; print 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.';
} }
} }