Fix source code editor
This commit is contained in:
parent
cfe7216577
commit
6db2aeff20
@ -243,32 +243,45 @@ class DolEditor
|
|||||||
filebrowserImageWindowHeight : \'500\'';
|
filebrowserImageWindowHeight : \'500\'';
|
||||||
}
|
}
|
||||||
$out.= ' })'.$morejs;
|
$out.= ' })'.$morejs;
|
||||||
$out.= '});
|
$out.= '});'."\n";
|
||||||
</script>';
|
$out.= '</script>'."\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Output editor ACE
|
||||||
|
// Warning: ace.js and ext-statusbar.js must be loaded by the parent page.
|
||||||
if (preg_match('/^ace/', $this->tool))
|
if (preg_match('/^ace/', $this->tool))
|
||||||
{
|
{
|
||||||
$found=1;
|
$found=1;
|
||||||
$format=(GETPOST('format','aZ09')?GETPOST('format','aZ09'):'php');
|
$format=(GETPOST('format','aZ09')?GETPOST('format','aZ09'):'php');
|
||||||
|
|
||||||
print '<pre id="'.$this->htmlname.'aceeditorid" style="'.($this->width?'width: '.$this->width.'px; ':'').($this->height?' height: '.$this->height.'px; ':'').'">';
|
$out.= '<!-- Output Ace editor -->'."\n";
|
||||||
print preg_replace(array('/^<\?php/','/\?>$/'), array('<?php','?>'), $this->content);
|
$out.= '<div id="statusBar"></div>';
|
||||||
print '</pre>';
|
$out.= '<pre id="'.$this->htmlname.'aceeditorid" style="'.($this->width?'width: '.$this->width.'px; ':'').($this->height?' height: '.$this->height.'px; ':'').'">';
|
||||||
print '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" style="width:0px; height: 0px; display: none;">';
|
/*$out.= preg_replace(array('/^<\?php/','/\?>$/'), array('<?php','?>'), $this->content); */
|
||||||
print $this->content;
|
$out.= htmlentities($this->content);
|
||||||
print '</textarea>';
|
$out.= '</pre>';
|
||||||
|
$out.= '<textarea id="'.$this->htmlname.'" name="'.$this->htmlname.'" style="width:0px; height: 0px; display: none;">';
|
||||||
|
$out.= htmlentities($this->content);
|
||||||
|
$out.= '</textarea>';
|
||||||
|
|
||||||
|
$out.= '<script type="text/javascript" language="javascript">'."\n";
|
||||||
|
$out.= 'var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid");
|
||||||
|
|
||||||
|
// Init status bar. Need lib ext-statusbar
|
||||||
|
//var StatusBar = ace.require("ace/ext/statusbar").StatusBar;
|
||||||
|
//var statusBar = new StatusBar(aceEditor, document.getElementById("statusBar"));
|
||||||
|
|
||||||
print '<script type="text/javascript" language="javascript">'."\n";
|
|
||||||
print 'var aceEditor = window.ace.edit("'.$this->htmlname.'aceeditorid");
|
|
||||||
aceEditor.session.setMode("ace/mode/'.$format.'");
|
aceEditor.session.setMode("ace/mode/'.$format.'");
|
||||||
aceEditor.setOptions({
|
aceEditor.setOptions({
|
||||||
//enableBasicAutocompletion: false, // the editor completes the statement when you hit Ctrl + Space
|
enableBasicAutocompletion: true, // the editor completes the statement when you hit Ctrl + Space. Need lib ext-language_tools.js
|
||||||
//enableLiveAutocompletion: false, // the editor completes the statement while you are typing
|
enableLiveAutocompletion: false, // the editor completes the statement while you are typing. Need lib ext-language_tools.js
|
||||||
//showPrintMargin: true, // hides the vertical limiting strip
|
showPrintMargin: false, // hides the vertical limiting strip
|
||||||
|
minLines: 10,
|
||||||
//maxLines: 34,
|
//maxLines: 34,
|
||||||
fontSize: "100%" // ensures that the editor fits in the environment
|
fontSize: "100%" // ensures that the editor fits in the environment
|
||||||
});
|
});
|
||||||
|
|
||||||
// defines the style of the editor
|
// defines the style of the editor
|
||||||
aceEditor.setTheme("ace/theme/chrome");
|
aceEditor.setTheme("ace/theme/chrome");
|
||||||
// hides line numbers (widens the area occupied by error and warning messages)
|
// hides line numbers (widens the area occupied by error and warning messages)
|
||||||
@ -277,14 +290,15 @@ class DolEditor
|
|||||||
//aceEditor.getSession().setMode("ace/mode/javascript_expression");
|
//aceEditor.getSession().setMode("ace/mode/javascript_expression");
|
||||||
'."\n";
|
'."\n";
|
||||||
|
|
||||||
print 'jQuery(document).ready(function() {
|
$out.= 'jQuery(document).ready(function() {
|
||||||
jQuery("#savefile").click(function() {
|
jQuery("#savefile").click(function() {
|
||||||
|
console.log("We click on savefile button");
|
||||||
jQuery("#'.$this->htmlname.'").val(aceEditor.getSession().getValue());
|
jQuery("#'.$this->htmlname.'").val(aceEditor.getSession().getValue());
|
||||||
if (strlen(jQuery("#'.$this->htmlname.'").html()) > 0) return true;
|
if (strlen(jQuery("#'.$this->htmlname.'").html()) > 0) return true;
|
||||||
else return false;
|
else return false;
|
||||||
});
|
});
|
||||||
})';
|
})';
|
||||||
print '</script>'."\n";
|
$out.= '</script>'."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($found))
|
if (empty($found))
|
||||||
|
|||||||
@ -611,8 +611,34 @@ if (! dol_is_dir($dirins))
|
|||||||
}
|
}
|
||||||
$dirins_ok=(dol_is_dir($dirins));
|
$dirins_ok=(dol_is_dir($dirins));
|
||||||
|
|
||||||
|
$head='<style type="text/css" media="screen">
|
||||||
llxHeader('', $langs->trans("ModuleBuilder"), "", '', 0, 0, array('/includes/ace/ace.js'), array());
|
.ace_editor {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
#statusBar {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
height: 20px;
|
||||||
|
background-color: rgb(245, 245, 245);
|
||||||
|
color: gray;
|
||||||
|
}
|
||||||
|
.ace_status-indicator {
|
||||||
|
color: gray;
|
||||||
|
position: relative;
|
||||||
|
right: 0;
|
||||||
|
border-left: 1px solid;
|
||||||
|
}
|
||||||
|
</style>';
|
||||||
|
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");
|
$text=$langs->trans("ModuleBuilder");
|
||||||
@ -1302,7 +1328,7 @@ elseif (! empty($module))
|
|||||||
print $doleditor->Create(1, '', false);
|
print $doleditor->Create(1, '', false);
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print '<center>';
|
print '<center>';
|
||||||
print '<input type="submit" class="button id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
|
print '<input type="submit" class="button" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
|
||||||
print ' ';
|
print ' ';
|
||||||
print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
|
print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
|
||||||
print '</center>';
|
print '</center>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user