I am trying to add CodeMirror to the installation of WonderCMS I have setup a plugin file for it but it does not seem to work still. Also I am wondering how to include PHP in the CMS? Is this possible?
The code I have to include the script and css files is:
Code: Select all
<?php
// CODEMIRROR PLUGIN
defined('INC_ROOT') OR die('Direct access is now allowed');
fibreCMS::addListener('js', 'loadCMJS');
fibreCMS::addListener('css', 'loadCMCSS');
function loadCMJS($args) {
$args = [];
array_push($args, '<script src="'.fibreCMS::url('plugins/codemirror/codemirror.js').'"></script>', '<script src="'.fibreCMS::url('plugins/codemirror/xml-fold.js').'"></script>', '<script src="'.fibreCMS::url('plugins/codemirror/xml.js').'"></script>', '<script src="'.fibreCMS::url('plugins/codemirror/javascript.js').'"></script>', '<script src="'.fibreCMS::url('plugins/codemirror/css.js').'"></script>', '<script src="'.fibreCMS::url('plugins/codemirror/php.js').'"></script>', '<script src="'.fibreCMS::url('plugins/codemirror/active-line.js').'"></script>', '<script src="'.fibreCMS::url('plugins/codemirror/matchbrackets.js').'"></script>', '<script src="'.fibreCMS::url('plugins/codemirror/matchtags.js').'"></script>', '<script src="'.fibreCMS::url('plugins/codemirror/fullscreen.js').'"></script>', '<script src="'.fibreCMS::url('plugins/codemirror/simplescrollbars.js').'"></script>', '<script src="'.fibreCMS::url('plugins/codemirror/scrollpastend.js').'"></script>');
$script = <<<'EOT'
<script> var editor;
function activateCM()
{
if (typeof(editor) == "undefined")
{
editor = CodeMirror.fromTextArea(document.getElementsById("content"), {
lineNumbers: true,
scrollbarStyle: "simple",
theme: "brackets",
styleActiveLine: true,
mode: "text/html",
matchBrackets: true,
matchTags: {bothTags: true},
extraKeys: {
"F11": function(cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
},
"Esc": function(cm) {
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
}
}
});
}
}
function cmFullscreen()
{
var button = document.getElementById('enlargeId');
if (editor.getOption("fullScreen"))
{
editor.setOption("fullScreen",false);
button.className = button.className.replace(" shrinkClass","");
}
else
{
editor.setOption("fullScreen",true);
button.className += " shrinkClass";
}
}
</script>
EOT;
array_push($args, $script);
return $args;
}
function loadCMCSS($args) {
array_push($args[0], '<link rel="stylesheet" href="'.fibreCMS::url('plugins/codemirror/css/codemirror.css').'">', '<link rel="stylesheet" href="'.fibreCMS::url('plugins/codemirror/css/fullscreen.css').'">', '<link rel="stylesheet" href="'.fibreCMS::url('plugins/codemirror/css/brackets.css').'">', '<link rel="stylesheet" href="'.fibreCMS::url('plugins/codemirror/css/simplescrollbars.css').'">');
return $args;
}
LSmithx2