Fix: call ckeditor class if needed by doleditor function

This commit is contained in:
Regis Houssin 2011-01-31 20:59:53 +00:00
parent ef8119a70b
commit e1e6629043
3 changed files with 17 additions and 17 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2007 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -26,8 +26,6 @@
* \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");

View File

@ -43,6 +43,7 @@ class DolEditor
var $rows; var $rows;
var $cols; var $cols;
var $height; var $height;
var $width;
/** /**
@ -60,17 +61,17 @@ class DolEditor
* @param rows Size of rows for textarea tool * @param rows Size of rows for textarea tool
* @param cols Size of cols for textarea tool * @param cols Size of cols for textarea tool
*/ */
function DolEditor($htmlname,$content,$height=200,$toolbarname='Basic',$toolbarlocation='In',$toolbarstartexpanded=false,$uselocalbrowser=true,$okforextandededitor=true,$rows=0,$cols=0) function DolEditor($htmlname,$content,$height=200,$toolbarname='Basic',$toolbarlocation='In',$toolbarstartexpanded=false,$uselocalbrowser=true,$okforextendededitor=true,$rows=0,$cols=0)
{ {
global $conf,$langs; global $conf,$langs;
dol_syslog("DolEditor::DolEditor htmlname=".$htmlname." tool=".$tool); dol_syslog("DolEditor::DolEditor htmlname=".$htmlname." tool=".$tool);
// Name of extended editor to use // Name of extended editor to use
$this->tool=empty($conf->global->FCKEDITOR_EDITORNAME)?'fckeditor':$conf->global->FCKEDITOR_EDITORNAME; $this->tool=empty($conf->global->MAIN_EXTENDED_EDITOR_NAME)?'fckeditor':$conf->global->MAIN_EXTENDED_EDITOR_NAME;
// Check if extended editor is ok. If not we force textarea // Check if extended editor is ok. If not we force textarea
if (empty($conf->fckeditor->enabled) || ! $okforextandededitor) if (empty($conf->fckeditor->enabled) || ! $okforextendededitor)
{ {
$this->tool = 'textarea'; $this->tool = 'textarea';
} }
@ -119,7 +120,6 @@ class DolEditor
} }
/** /**
* Output edit area inside the HTML stream * Output edit area inside the HTML stream
*/ */
@ -137,15 +137,18 @@ class DolEditor
if (in_array($this->tool,array('textarea','ckeditor'))) if (in_array($this->tool,array('textarea','ckeditor')))
{ {
$found=1; $found=1;
$cssclass='flat'; print '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" rows="'.$this->rows.'" cols="'.$this->cols.'" class="flat">';
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 ($this->tool == 'ckeditor') if ($this->tool == 'ckeditor')
{ {
if (! defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR','1');
print '<script type="text/javascript">'; print '<script type="text/javascript">';
print 'jQuery(document).ready(function () {';
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 });';
print '});';
print '</script>'; print '</script>';
} }
} }
@ -158,5 +161,4 @@ class DolEditor
} }
?> ?>

View File

@ -886,12 +886,6 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs
{ {
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/layout/jquery.layout-latest'.$ext.'"></script>'."\n"; print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/jquery/plugins/layout/jquery.layout-latest'.$ext.'"></script>'."\n";
} }
// CKEditor
if ($conf->global->MAIN_USE_CKEDITOR && defined('REQUIRE_CKEDITOR'))
{
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/ckeditor/ckeditor.js"></script>'."\n";
}
} }
// Output module javascript // Output module javascript
@ -1573,6 +1567,12 @@ if (! function_exists("llxFooter"))
print "\n"; print "\n";
if ($foot) print '<!-- '.$foot.' -->'."\n"; if ($foot) print '<!-- '.$foot.' -->'."\n";
// CKEditor
if (defined('REQUIRE_CKEDITOR'))
{
print '<script type="text/javascript" src="'.DOL_URL_ROOT.'/includes/ckeditor/ckeditor.js"></script>'."\n";
}
if (! empty($conf->global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER."\n"; if (! empty($conf->global->MAIN_HTML_FOOTER)) print $conf->global->MAIN_HTML_FOOTER."\n";
print "</body>\n"; print "</body>\n";