This repository has been archived by the owner on Jul 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjusebce.php
141 lines (124 loc) · 4.27 KB
/
jusebce.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Uri\Uri;
defined('_JEXEC') or die;
class plgSystemJUSebCE extends CMSPlugin
{
protected $app;
/**
* plgSystemJUSebCE constructor.
*
* @param $subject
* @param $config
*/
public function __construct(&$subject, $config)
{
parent::__construct($subject, $config);
$this->doc = Factory::getDocument();
}
/**
*
* @return bool
*
* @since 1.0
*/
public function onBeforeCompileHead()
{
if($this->app->getName() === 'site')
{
return true;
}
if(!($this->app->input->getCmd('option') === 'com_cck' && $this->app->input->getCmd('view') === 'field' && $this->app->input->getCmd('tmpl') === 'component' && $this->app->input->getCmd('layout') === 'edit'))
{
return true;
}
$this->doc->addStyleSheet(Uri::root() . 'media/editors/codemirror/lib/codemirror.min.css');
$this->doc->addStyleSheet('https://fonts.googleapis.com/css?family=Source+Code+Pro');
$this->doc->addScript(Uri::root() . 'media/editors/codemirror/lib/codemirror.min.js', 'text/javascript');
$this->doc->addScript(Uri::root() . 'media/editors/codemirror/addon/edit/matchbrackets.min.js', 'text/javascript');
$this->doc->addScript(Uri::root() . 'media/editors/codemirror/mode/htmlmixed/htmlmixed.js', 'text/javascript');
$this->doc->addScript(Uri::root() . 'media/editors/codemirror/mode/xml/xml.js', 'text/javascript');
$this->doc->addScript(Uri::root() . 'media/editors/codemirror/mode/javascript/javascript.js', 'text/javascript');
$this->doc->addScript(Uri::root() . 'media/editors/codemirror/mode/css/css.js', 'text/javascript');
$this->doc->addScript(Uri::root() . 'media/editors/codemirror/mode/clike/clike.js', 'text/javascript');
$this->doc->addScript(Uri::root() . 'media/editors/codemirror/mode/php/php.js', 'text/javascript');
$css = '<style>
.CodeMirror
{
font-family: \'Source Code Pro\', monospace!important;
font-size: 14px;;
line-height: 1.2em;;
border: 1px solid #ccc;
}
.CodeMirror-fullscreen
{
z-index: 1040;
}
.CodeMirror-foldmarker
{
background: rgb(255, 128, 0);
background: rgba(255, 128, 0, .5);
box-shadow: inset 0 0 2px rgba(255, 255, 255, .5);
font-family: serif;
font-size: 90%;
border-radius: 1em;
padding: 0 1em;
vertical-align: middle;
color: white;
text-shadow: none;
}
.CodeMirror-foldgutter, .CodeMirror-markergutter { width: 1.2em; text-align: center; }
.CodeMirror-markergutter { cursor: pointer; }
.CodeMirror-markergutter-mark { cursor: pointer; text-align: center; }
.CodeMirror-markergutter-mark:after { content: "CF"; }
.CodeMirror-activeline-background { background: rgba(164, 194, 235, .5); }
.CodeMirror-matchingtag { background: rgba(250, 84, 47, .5); }
.cm-matchhighlight {background-color: rgba(250, 84, 47, .5); }
.CodeMirror-selection-highlight-scrollbar {background-color: rgba(250, 84, 47, .5); }
</style>';
$this->doc->addCustomTag($css);
$this->doc->addScriptDeclaration(<<<JS
(function () {
document.addEventListener('DOMContentLoaded', function () {
var options = {
lineNumbers: true,
matchBrackets: true,
mode: "text/x-php",
indentUnit: 4,
indentWithTabs: true
},
mixedMode = {
lineNumbers: true,
matchBrackets: true,
indentUnit: 4,
indentWithTabs: true,
name: "htmlmixed",
scriptTypes: [
{
matches: /\/x-handlebars-template|\/x-mustache/i,
mode: null
}, {
matches: /(text|application)\/(x-)?vb(a|script)/i,
mode: "vbscript"
}
]
};
addCM('json_options2_code', options);
addCM('json_options2_preparecontent', options);
addCM('json_options2_prepareform', options);
addCM('json_options2_preparestore', options);
addCM('json_options2_html', mixedMode);
function addCM(elID, options) {
var el = document.getElementById(elID);
if (typeof el !== "undefined" && el !== null) {
return CodeMirror.fromTextArea(el, options);
}
}
});
})();
JS
);
return true;
}
}