forked from icecoder/ICEcoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditor.php
295 lines (275 loc) · 13.1 KB
/
editor.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
<?php include("lib/settings.php");?>
<!DOCTYPE html>
<html style="margin: 0" onMouseDown="top.ICEcoder.mouseDown=true" onMouseUp="top.ICEcoder.mouseDown=false; if (!top.ICEcoder.overCloseLink) {top.ICEcoder.tabDragEnd()}" onMouseMove="if(top.ICEcoder) {top.ICEcoder.getMouseXY(event,'editor');top.ICEcoder.canResizeFilesW()}">
<head>
<title>ICEcoder v <?php echo $ICEcoder["versionNo"];?> editor</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="robots" content="noindex, nofollow">
<link rel="stylesheet" href="<?php echo $ICEcoder["codeMirrorDir"]; ?>/lib/codemirror.css">
<link rel="stylesheet" href="<?php echo $ICEcoder["codeMirrorDir"]; ?>/addon/hint/show-hint.css">
<link rel="stylesheet" href="<?php echo $ICEcoder["codeMirrorDir"]; ?>/addon/lint/lint.css">
<!--
codemirror-compressed.js
incls: codemirror
modes: clike, coffeescript, css, htmlmixed, javascript, less, markdown, php, python, ruby & xml
addon: brace-fold, closetag, html-hint, javascript-hint, javascript-lint, lint, match-highlighter, searchcursor, show-hint, trailingspace, xml-fold
//-->
<script src="<?php echo $ICEcoder["codeMirrorDir"]; ?>/lib/codemirror-compressed.js"></script>
<script src="jshint/jshint-2.1.4.min.js"></script>
<script src="lib/mmd.js"></script>
<script src="lib/foldcode.js"></script>
<?php
if (file_exists(dirname(__FILE__)."/plugins/emmet/emmet.min.js")) {
echo '<script src="plugins/emmet/emmet.min.js"></script>';
};?>
<link rel="stylesheet" href="<?php
if ($ICEcoder["theme"]=="default") {echo 'lib/editor.css';} else {echo $ICEcoder["codeMirrorDir"].'/theme/'.$ICEcoder["theme"].'.css';};
$activeLineBG = array_search($ICEcoder["theme"],array("eclipse","elegant","neat","solarized","xq-light")) !== false ? "#ccc" : "#000";
?>">
<style type="text/css">
/* Make sure this next one remains the 1st item, updated with JS */
.CodeMirror {position: absolute; top: 0; width: 100%; font-size: <?php echo $ICEcoder["fontSize"];?>; z-index: 1}
.CodeMirror-scroll {} /* was: height: auto; overflow: visible */
/* Make sure this next one remains the 3rd item, updated with JS */
.cm-s-activeLine {background: <?php echo $activeLineBG;?> !important}
.cm-matchhighlight, .CodeMirror-focused .cm-matchhighlight {color: #fff !important; background: #06c !important}
/* Make sure this next one remains the 5th item, updated with JS */
.cm-tab:after {position: relative; display: inline-block; width: 0; left: -1.4em; overflow: visible; color: #aaa; content: "<?php if($ICEcoder["visibleTabs"]) {echo '\\21e5';};?>";}
.cm-trailingspace {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAACCAYAAAB/qH1jAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QUXCToH00Y1UgAAACFJREFUCNdjPMDBUc/AwNDAAAFMTAwMDA0OP34wQgX/AQBYgwYEx4f9lQAAAABJRU5ErkJggg==);
background-position: bottom left;
background-repeat: repeat-x;
}
.CodeMirror-foldmarker {font-family: arial; line-height: .3; color: #b00; cursor: pointer;
text-shadow: #fff 1px 1px 2px, #fff -1px -1px 2px, #fff 1px -1px 2px, #fff -1px 1px 2px;
}
.folds {display: inline-block; width: 13px}
.fold {position: absolute; display: inline-block; width: 13px; height: 13px; font-size: 14px; text-align: center; cursor: pointer}
.foldOn {background: #800; color: #ddd}
.foldOff {background: rgba(255,255,255,0.04); color: #666}
.demoArrow {position: absolute; display: inline-block; width: 99px; height: 50px; top: 0; right: 30px; background: url('images/big-arrow.gif') 0 -10px no-repeat; text-align: center; font-family: arial; font-size: 10px; padding-top: 60px}
h2 {color: rgba(0,198,255,0.7)}
.heading {color:#888}
</style>
<link rel="stylesheet" href="lib/file-types.css">
</head>
<body style="color: #fff; margin: 0" onKeyDown="return top.ICEcoder.interceptKeys('content', event);" onKeyUp="top.ICEcoder.resetKeys(event);">
<?php if ($ICEcoder['demoMode']) {?>
<div class="demoArrow"><b>Click icons<br>for help &<br>usage info</b></div>
<?php ;}; ?>
<div style="display: none; margin: 32px 43px 0 43px; padding: 10px; width: 500px; font-family: arial; font-size: 10px; color: #ddd; background: #333" id="dataMessage"></div>
<div style="margin: 20px 43px 32px 43px; font-family: arial; font-size: 10px; color: #ddd">
<div style="float: left; margin-right: 50px">
<h2>server</h2>
<span class="heading">Server name, OS & IP:</span><br>
<?php echo $_SERVER['SERVER_NAME']."   ".$_SERVER['SERVER_SOFTWARE']."   ".$_SERVER['SERVER_ADDR'];?><br><br>
<span class="heading">Root:</span><br>
<?php echo $docRoot;?><br><br>
<span class="heading">ICEcoder root:</span><br>
<?php echo $docRoot.$iceRoot;?><br><br>
<span class="heading">PHP version:</span><br>
<?php echo phpversion();?><br><br>
<span class="heading">Date & time:</span><br>
<span id="serverDT"></span><br><br><br>
</div>
<div style="float: left">
<h2>files</h2>
<span class="heading">Last 10 files opened:</span><br>
<ul class="fileManager" style="margin-left: 0; line-height: 20px">
<?php
$last10FilesArray = explode(",",$ICEcoder["last10Files"]);
for ($i=0;$i<count($last10FilesArray);$i++) {
if ($ICEcoder["last10Files"]=="") {
echo '<div style="display: inline-block; margin-left: -39px; margin-top: -18px">[none]</div><br><br>';
} else {
$fileFolderName = str_replace("\\","/",$last10FilesArray[$i]);
// Get extension (prefix 'ext-' to prevent invalid classes from extensions that begin with numbers)
$ext = "ext-".pathinfo($docRoot.$iceRoot.$fileFolderName, PATHINFO_EXTENSION);
echo '<li class="pft-file '.strtolower($ext).'" style="margin-left: -21px">';
echo '<a style="cursor:pointer" onClick="top.ICEcoder.openFile(\''.str_replace("|","/",$last10FilesArray[$i]).'\')">';
echo str_replace($docRoot,"",str_replace("|","/",$last10FilesArray[$i]));
echo '</a></li>'.PHP_EOL;
if ($i==count($last10FilesArray)-1) {echo '<br>'.PHP_EOL;};
}
}
;?>
</ul>
</div>
<div style="clear: both">
<h2>your device</h2>
<span class="heading">Browser:</span><br>
<?php echo $_SERVER['HTTP_USER_AGENT'];?><br><br>
<span class="heading">Your IP:</span><br>
<?php echo $_SERVER['REMOTE_ADDR'];?>
</div>
<script>
var nDT=<?php echo time()*1000;?>;
setInterval(function(){
var s=(new Date(nDT+=1e3)+'').split(' '),
d=s[2]*1,
t=s[4].split(':'),
p=t[0]>11?'pm':'am',
e=d%20==1|d>30?'st':d%20==2?'nd':d%20==3?'rd':'th';
t[0]=--t[0]%12+1;
if (document.getElementById('serverDT')) {
document.getElementById('serverDT').innerHTML=[s[0],d+e,s[1],s[3],t.join(':')+p].join(' ');
}
},1000);
</script>
<?php if(is_dir('test') && !$ICEcoder['demoMode']) {?>
<div style="float: left; margin-right: 50px">
<br><br>
<h2>test suite</h2>
<span class="heading">Run unit tests:</span><br>
<a href="javascript:top.ICEcoder.filesFrame.contentWindow.frames['testControl'].location.href = 'test'" style="color: #fff">Run unit tests</a><div id="unitTestResults"></div>
</div>
<?php
;};
if($ICEcoder['devMode']) {?>
<div style="float: left">
<br><br>
<h2>dev mode on</h2>
<span class="heading">Status:</span><br>
Using ice-coder.js
</div>
<?php ;};?>
<div style="clear: both"></div>
</div>
<script>
CodeMirror.keyMap.ICEcoder = {
// "Tab": "defaultTab", **Now used by Emmet**
"Shift-Tab": "indentLess",
"Ctrl-Space": "autocomplete",
fallthrough: ["default"]
};
CodeMirror.commands.autocomplete = function(cm) {
CodeMirror.showHint(cm, top.ICEcoder.caretLocType=="JavaScript"
? CodeMirror.hint.javascript
: CodeMirror.hint.html
);
}
function createNewCMInstance(num) {
var fileName = top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1];
window['cM'+num] = CodeMirror(document.body, {
mode: "application/x-httpd-php",
lineNumbers: true,
gutters: ["folds","CodeMirror-lint-markers","CodeMirror-linenumbers"],
lineWrapping: top.ICEcoder.lineWrapping,
indentWithTabs: top.ICEcoder.indentWithTabs,
indentUnit: top.ICEcoder.indentSize,
tabSize: top.ICEcoder.indentSize,
electricChars: false,
autoCloseTags: true,
highlightSelectionMatches: true,
showTrailingSpace: true,
lintWith: <?php if ($ICEcoder['codeAssist']) {echo 'fileName && fileName.indexOf(".js")>-1 ? CodeMirror.javascriptValidator : ';};?>false,
keyMap: "ICEcoder",
onKeyEvent: function(thisCM, e) {
top.ICEcoder.redoChangedContent(e);
top.ICEcoder.findReplace(top.document.getElementById('find').value,true,false);
top.ICEcoder.getCaretPosition();
top.ICEcoder.updateCharDisplay();
top.ICEcoder.updateByteDisplay();
tok = thisCM.getTokenAt(thisCM.getCursor());
}
});
window['cM'+num].on("cursorActivity", function(thisCM) {
top.ICEcoder.getCaretPosition();
top.ICEcoder.updateCharDisplay();
top.ICEcoder.updateByteDisplay();
window['cM'+num].removeLineClass(top.ICEcoder['cMActiveLine'+num], "background");
if(window['cM'+num].getCursor('start').line == window['cM'+num].getCursor().line) {
top.ICEcoder['cMActiveLine'+num] = window['cM'+num].addLineClass(window['cM'+num].getCursor().line, "background","cm-s-activeLine");
}
if (top.ICEcoder.caretLocType=="CSS") {
top.ICEcoder.cssColorPreview();
}
}
);
window['cM'+num].on("change", function(thisCM, changeObj) {
// If we're not loading the file, it's a change, so update tab
if (!top.ICEcoder.loadingFile) {
top.ICEcoder.changedContent[top.ICEcoder.selectedTab-1] = thisCM.historySize().undo > 0 ? 1 : 0;
top.ICEcoder.redoTabHighlight(top.ICEcoder.selectedTab);
}
top.ICEcoder.getCaretPosition();
top.ICEcoder.dontUpdateNest = false;
top.ICEcoder.updateCharDisplay();
top.ICEcoder.updateByteDisplay();
top.ICEcoder.updateNestingIndicator();
if (top.ICEcoder.findMode) {
top.ICEcoder.results.splice(top.ICEcoder.findResult,1);
top.document.getElementById('results').innerHTML = top.ICEcoder.results.length + " results";
top.ICEcoder.findMode = false;
}
var filepath = top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1];
if (filepath) {
var filename = filepath.substr(filepath.lastIndexOf("/")+1);
var fileExt = filename.substr(filename.lastIndexOf(".")+1);
for (var i=changeObj.from.line; i<changeObj.from.line+changeObj.text.length; i++) {
top.ICEcoder.content.contentWindow.CodeMirror.newFoldFunction(top.ICEcoder.content.contentWindow.CodeMirror[
window['cM'+num].getLine(i).indexOf("{")>-1
? "braceRangeFinder"
: "tagRangeFinder"
],null,"+","-",true)(thisCM, i);
}
if (changeObj.text[0] == "}" || changeObj.removed && changeObj.removed[0] == "}") {
cursor = window['cM'+num].getSearchCursor("{",window['cM'+num].getCursor(),false);
cursor.findPrevious();
for (var i=cursor.from().line; i<window['cM'+num].getCursor().line; i++) {
top.ICEcoder.content.contentWindow.CodeMirror.newFoldFunction(top.ICEcoder.content.contentWindow.CodeMirror[
window['cM'+num].getLine(i).indexOf("{")>-1
? "braceRangeFinder"
: "tagRangeFinder"
],null,"+","-",true)(thisCM, i);
}
}
}
// Update HTML edited files live
if (filepath && top.ICEcoder.previewWindow.location) {
if (top.ICEcoder.previewWindow.location.pathname==filepath) {
if (["htm","html","txt"].indexOf(fileExt) > -1) {
top.ICEcoder.previewWindow.document.documentElement.innerHTML = window['cM'+num].getValue();
} else if (["md"].indexOf(fileExt) > -1) {
top.ICEcoder.previewWindow.document.documentElement.innerHTML = mmd(window['cM'+num].getValue());
}
} else if (["css"].indexOf(fileExt) > -1) {
if (top.ICEcoder.previewWindow.document.documentElement.innerHTML.indexOf(filename) > -1) {
var css = window['cM'+num].getValue();
var style = document.createElement('style');
style.type = 'text/css';
style.id = "ICEcoder"+filepath.replace(/\//g,"_");
if (style.styleSheet){
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
if (top.ICEcoder.previewWindow.document.getElementById(style.id)) {
top.ICEcoder.previewWindow.document.documentElement.removeChild(top.ICEcoder.previewWindow.document.getElementById(style.id));
}
top.ICEcoder.previewWindow.document.documentElement.appendChild(style);
}
}
}
}
);
window['cM'+num].on("scroll", function(thisCM) {
top.ICEcoder.mouseDown=false;
}
);
window['cM'+num].on("gutterClick", function(thisCM, line, gutter, clickEvent) {
var filepath = top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1];
var fileExt = filepath.substr(filepath.lastIndexOf(".")+1);
window['cM'+num].getLine(line).indexOf("{")>-1
? codeFoldBrace(window['cM'+num], line) : codeFoldTag(window['cM'+num], line);
}
);
// Now create the active line for this CodeMirror object
top.ICEcoder['cMActiveLine'+num] = window['cM'+num].addLineClass(0, "background", "cm-s-activeLine");
};
var codeFoldTag = CodeMirror.newFoldFunction(CodeMirror.tagRangeFinder,null,"+","-",false);
var codeFoldBrace = CodeMirror.newFoldFunction(CodeMirror.braceRangeFinder,null,"+","-",false);
</script>
<div style="position: absolute; display: none; width: 5px; height: 100%; top: 0; right: 0; background: rgba(255,255,255,0.1); overflow: hidden; z-index: 2" id="resultsBar"></div>
</body>
</html>