Fix: Pb with fckeditor

This commit is contained in:
Laurent Destailleur 2009-01-31 02:55:32 +00:00
parent 6cb32ff8c1
commit 678ab5b931
3 changed files with 32 additions and 28 deletions

View File

@ -38,6 +38,7 @@ $langs->load("members");
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
if (! defined("MAIN_MOTD")) define("MAIN_MOTD",""); if (! defined("MAIN_MOTD")) define("MAIN_MOTD","");
$dirtheme = "../theme"; $dirtheme = "../theme";

View File

@ -55,7 +55,9 @@ class DolEditor
require_once(DOL_DOCUMENT_ROOT."/includes/fckeditor/fckeditor.php"); require_once(DOL_DOCUMENT_ROOT."/includes/fckeditor/fckeditor.php");
$content=dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML. $content=dol_htmlentitiesbr($content); // If content is not HTML, we convert to HTML.
//print "\n".$conf->global->MAIN_MOTD."\n".$content;exit;
$this->editor = new FCKeditor($htmlname); $this->editor = new FCKeditor($htmlname);
$this->editor->BasePath = DOL_URL_ROOT.'/includes/fckeditor/' ; $this->editor->BasePath = DOL_URL_ROOT.'/includes/fckeditor/' ;

View File

@ -2457,7 +2457,8 @@ function dol_nl2br($stringtoencode,$nl2brmode=0)
} }
/** /**
* \brief This function is called to encode a string into a HTML string. All entities except <> are converted. * \brief This function is called to encode a string into a HTML string.
* All entities except &,<,> are converted. This permits to encode special chars to entities with no double encoded for already encoded HTML strings.
* This function also remove last CR/BR. * This function also remove last CR/BR.
* \param stringtoencode String to encode * \param stringtoencode String to encode
* \param nl2brmode 0=Adding br before \n, 1=Replacing \n by br (for use with FPDF writeHTMLCell function for example) * \param nl2brmode 0=Adding br before \n, 1=Replacing \n by br (for use with FPDF writeHTMLCell function for example)
@ -2474,9 +2475,9 @@ function dol_htmlentitiesbr($stringtoencode,$nl2brmode=0,$pagecodefrom='UTF-8')
//$trans = get_html_translation_table(HTML_ENTITIES, ENT_COMPAT); var_dump($trans); //$trans = get_html_translation_table(HTML_ENTITIES, ENT_COMPAT); var_dump($trans);
$newstring=eregi_replace('<br( [ a-zA-Z_="]*)?/?>','<br>',$stringtoencode); // Replace "<br type="_moz" />" by "<br>". It's same and avoid pb with FPDF. $newstring=eregi_replace('<br( [ a-zA-Z_="]*)?/?>','<br>',$stringtoencode); // Replace "<br type="_moz" />" by "<br>". It's same and avoid pb with FPDF.
$newstring=eregi_replace('<br>$','',$newstring); // Replace "<br type="_moz" />" by "<br>". It's same and avoid pb with FPDF. $newstring=eregi_replace('<br>$','',$newstring); // Replace "<br type="_moz" />" by "<br>". It's same and avoid pb with FPDF.
$newstring=strtr($newstring,array('<'=>'__lt__','>'=>'__gt__')); $newstring=strtr($newstring,array('&'=>'__and__','<'=>'__lt__','>'=>'__gt__','"'=>'__dquot__'));
$newstring=@htmlentities($newstring,ENT_COMPAT,$pagecodefrom); // Make entity encoding $newstring=@htmlentities($newstring,ENT_COMPAT,$pagecodefrom); // Make entity encoding
$newstring=strtr($newstring,array('__lt__'=>'<','__gt__'=>'>')); $newstring=strtr($newstring,array('__and__'=>'&','__lt__'=>'<','__gt__'=>'>','__dquot__'=>'"'));
// If already HTML, CR should be <br> so we don't change \n // If already HTML, CR should be <br> so we don't change \n
} }
else { else {