From 678ab5b93132461a3e0900f04ce492fda7b604d7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 31 Jan 2009 02:55:32 +0000 Subject: [PATCH] Fix: Pb with fckeditor --- htdocs/admin/ihm.php | 37 +++++++++++++++++----------------- htdocs/lib/doleditor.class.php | 16 ++++++++------- htdocs/lib/functions.lib.php | 7 ++++--- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 3861e07477c..9838164c2b1 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -38,6 +38,7 @@ $langs->load("members"); if (!$user->admin) accessforbidden(); + if (! defined("MAIN_MOTD")) define("MAIN_MOTD",""); $dirtheme = "../theme"; @@ -60,22 +61,22 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update') dolibarr_set_const($db, "MAIN_CONFIRM_AJAX", $_POST["main_confirm_ajax"]); dolibarr_set_const($db, "MAIN_POPUP_CALENDAR", $_POST["main_popup_calendar"]); dolibarr_set_const($db, "MAIN_USE_PREVIEW_TABS", $_POST["main_use_preview_tabs"]); - + dolibarr_set_const($db, "MAIN_SHOW_BUGTRACK_LINK", $_POST["main_show_bugtrack_link"]); dolibarr_set_const($db, "MAIN_SHOW_WORKBOARD", $_POST["main_show_workboard"]); - + dolibarr_set_const($db, "MAIN_THEME", $_POST["main_theme"]); - + dolibarr_set_const($db, "MAIN_SEARCHFORM_CONTACT", $_POST["MAIN_SEARCHFORM_CONTACT"]); dolibarr_set_const($db, "MAIN_SEARCHFORM_SOCIETE", $_POST["MAIN_SEARCHFORM_SOCIETE"]); dolibarr_set_const($db, "MAIN_SEARCHFORM_PRODUITSERVICE",$_POST["MAIN_SEARCHFORM_PRODUITSERVICE"]); dolibarr_set_const($db, "MAIN_SEARCHFORM_ADHERENT",$_POST["MAIN_SEARCHFORM_ADHERENT"]); - + dolibarr_set_const($db, "MAIN_MOTD", $_POST["main_motd"]); dolibarr_set_const($db, "MAIN_HOME", $_POST["main_home"]); - + $_SESSION["mainmenu"]=""; // Le gestionnaire de menu a pu changer - + Header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); exit; } @@ -130,7 +131,7 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit') print ''.$langs->trans("DefaultMaxSizeList").''; print ' '; print ''; - + /* $var=!$var; print ''.$langs->trans("ShowBugTrackLink").''; @@ -147,7 +148,7 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit') print ''; print ' '; print ''; - + // Confirmation par popup ajax if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { @@ -159,7 +160,7 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit') print ''.$html->textwithhelp('',$langs->trans("FeatureDevelopment")).''; print ''; } - + // Desactiver le calendrier popup $var=!$var; print ''.$langs->trans("UsePopupCalendar").''; @@ -185,7 +186,7 @@ if (isset($_GET["action"]) && $_GET["action"] == 'edit') print ' '; print ''; } - + print '
'; @@ -277,7 +278,7 @@ else /* $var=!$var; - print ''.$langs->trans("ShowBugTrackLink").''; + print ''.$langs->trans("ShowBugTrackLink").''; print yn($conf->global->MAIN_SHOW_BUGTRACK_LINK).""; print ' '; print ""; @@ -285,25 +286,25 @@ else // Disable javascript/ajax $var=!$var; - print ''.$langs->trans("DisableJavascript").''; + print ''.$langs->trans("DisableJavascript").''; print yn($conf->global->MAIN_DISABLE_JAVASCRIPT).""; print ' '; print ""; - + // Confirm ajax if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { $var=!$var; - print ''.$langs->trans("ConfirmAjax").''; + print ''.$langs->trans("ConfirmAjax").''; if ($conf->global->MAIN_DISABLE_JAVASCRIPT) print $langs->trans("No").' ('.$langs->trans("JavascriptDisabled").')'; else print yn(isset($conf->global->MAIN_CONFIRM_AJAX)?$conf->global->MAIN_CONFIRM_AJAX:0).""; print ''.$html->textwithhelp('',$langs->trans("FeatureDevelopment")).''; print ""; } - + // Calendrier en popup $var=!$var; - print ''.$langs->trans("UsePopupCalendar").''; + print ''.$langs->trans("UsePopupCalendar").''; if ($conf->global->MAIN_DISABLE_JAVASCRIPT) print $langs->trans("No").' ('.$langs->trans("JavascriptDisabled").')'; else print ($conf->global->MAIN_POPUP_CALENDAR?$langs->trans("Yes"):$langs->trans("No")); print ""; @@ -319,7 +320,7 @@ else print ' '; print ""; } - + print '
'; @@ -347,7 +348,7 @@ else print ''.$langs->trans("MessageOfDay").''; print nl2br($conf->global->MAIN_MOTD); print ''; - + // Message login $var=!$var; print ''.$langs->trans("MessageLogin").''; diff --git a/htdocs/lib/doleditor.class.php b/htdocs/lib/doleditor.class.php index 4b00c8034c8..f91abb1f85c 100644 --- a/htdocs/lib/doleditor.class.php +++ b/htdocs/lib/doleditor.class.php @@ -33,15 +33,15 @@ class DolEditor { var $editor; - - + + /** \brief DolEditor \param htmlname Nom formulaire html WYSIWIG \param content Contenu édition WYSIWIG \param height Hauteur en pixel de la zone édition \param toolbarname Nom barre de menu éditeur - \param toolbarlocation Emplacement de la barre de menu : + \param toolbarlocation Emplacement de la barre de menu : 'In' chaque fenêtre d'édition a ça propre barre d'outils 'Out:nom' partage de la barre d'outils où 'nom' est le nom du DIV qui affiche la barre \param toolbarstartexpanded visible ou non au démarrage @@ -50,13 +50,15 @@ class DolEditor function DolEditor($htmlname,$content,$height=200,$toolbarname='Basic',$toolbarlocation='In',$toolbarstartexpanded=false,$uselocalbrowser=true) { global $conf,$langs; - + dolibarr_syslog("DolEditor::DolEditor modulepart=".$modulepart); - + require_once(DOL_DOCUMENT_ROOT."/includes/fckeditor/fckeditor.php"); + $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->BasePath = DOL_URL_ROOT.'/includes/fckeditor/' ; $this->editor->Value = $content; @@ -65,7 +67,7 @@ class DolEditor $this->editor->Config['AutoDetectLanguage'] = 'true'; $this->editor->Config['ToolbarLocation'] = $toolbarlocation ? $toolbarlocation : 'In'; $this->editor->Config['ToolbarStartExpanded'] = $toolbarstartexpanded; - + // Rem: Le forcage de ces 2 parametres ne semble pas fonctionner. // Dolibarr utilise toujours liens avec modulepart='fckeditor' quelque soit modulepart. // Ou se trouve donc cette valeur /viewimage.php?modulepart=fckeditor&file=' ? diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 5d442461702..1551c13e0bf 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -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. * \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) @@ -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); $newstring=eregi_replace('" by "
". It's same and avoid pb with FPDF. $newstring=eregi_replace('
$','',$newstring); // Replace "
" by "
". 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=strtr($newstring,array('__lt__'=>'<','__gt__'=>'>')); + $newstring=strtr($newstring,array('__and__'=>'&','__lt__'=>'<','__gt__'=>'>','__dquot__'=>'"')); // If already HTML, CR should be
so we don't change \n } else {