From 6db2aeff20228297efb4f430b513939d782eafa8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Jul 2017 12:00:18 +0200 Subject: [PATCH] Fix source code editor --- htdocs/core/class/doleditor.class.php | 70 ++++++++++++++++----------- htdocs/modulebuilder/index.php | 32 ++++++++++-- 2 files changed, 71 insertions(+), 31 deletions(-) diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 8f4bc50a2d4..9a9f0387309 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -146,7 +146,7 @@ class DolEditor * @param boolean $disallowAnyContent Disallow to use any content. true=restrict to a predefined list of allowed elements. * @return void|string */ - function Create($noprint=0,$morejs='',$disallowAnyContent=true) + function Create($noprint=0, $morejs='', $disallowAnyContent=true) { global $conf,$langs; @@ -243,48 +243,62 @@ class DolEditor filebrowserImageWindowHeight : \'500\''; } $out.= ' })'.$morejs; - $out.= '}); - '; + $out.= '});'."\n"; + $out.= ''."\n"; } } + + // Output editor ACE + // Warning: ace.js and ext-statusbar.js must be loaded by the parent page. if (preg_match('/^ace/', $this->tool)) { $found=1; $format=(GETPOST('format','aZ09')?GETPOST('format','aZ09'):'php'); - print '
';
-        	print preg_replace(array('/^<\?php/','/\?>$/'), array('<?php','?>'), $this->content);
-        	print '
'; - print ''; + $out.= ''."\n"; + $out.= '
'; + $out.= '
';
+        	/*$out.= preg_replace(array('/^<\?php/','/\?>$/'), array('<?php','?>'), $this->content); */
+        	$out.= htmlentities($this->content);
+        	$out.= '
'; + $out.= ''; - print ''."\n"; + $out.= ''."\n"; } if (empty($found)) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 78547dceee5..d8e1fa786a7 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -611,8 +611,34 @@ if (! dol_is_dir($dirins)) } $dirins_ok=(dol_is_dir($dirins)); - -llxHeader('', $langs->trans("ModuleBuilder"), "", '', 0, 0, array('/includes/ace/ace.js'), array()); +$head=''; +llxHeader($head, $langs->trans("ModuleBuilder"), "", '', 0, 0, + array( + '/includes/ace/ace.js', + '/includes/ace/ext-statusbar.js', + '/includes/ace/ext-language_tools.js', + //'/includes/ace/ext-chromevox.js' + ), array()); $text=$langs->trans("ModuleBuilder"); @@ -1302,7 +1328,7 @@ elseif (! empty($module)) print $doleditor->Create(1, '', false); print '
'; print '
'; - print ''; + print ''; print '   '; print ''; print '
';