forked from jskenney/calendar-core
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcalendar_file_editor.php
More file actions
89 lines (77 loc) · 2.65 KB
/
calendar_file_editor.php
File metadata and controls
89 lines (77 loc) · 2.65 KB
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
<?php
if (!isset($_SESSION['previewmode'])) {
$_SESSION['previewmode'] = false;
}
if (isset($_REQUEST['preview'])) {
$_SESSION['previewmode'] = !$_SESSION['previewmode'];
}
if ($INSTRUCTOR) {
?>
<h5><?php echo $actual_file; ?>
<?php
if ($INSTRUCTOR && isset($_REQUEST['editor'])) {
if (file_put_contents($actual_file, $_REQUEST['editor']) === FALSE) {
echo " (<font color=red>Permission Denied</font>)";
}
$contents_clean = file_get_contents($actual_file);
}
?>
</h5>
<div class="row">
<?php if ($_SESSION['previewmode']) { ?>
<div class="six columns">
<?php
}
$contents_clean = str_ireplace('<', '<', $contents_clean);
$contents_clean = str_ireplace('>', '>', $contents_clean);
echo "<div id='htmleditor'>$contents_clean</div>";
?>
<form method="POST">
<textarea name="editor" id="myeditor" style="display: none;"></textarea>
<input type="hidden" name="key" value="<?php echo strip_tags($_REQUEST['key']); ?>">
<input type="hidden" name="type" value="<?php echo strip_tags($_REQUEST['type']); ?>">
<input type="hidden" name="event" value="<?php echo strip_tags($_REQUEST['event']); ?>">
<input type="hidden" name="edit" value="<?php echo strip_tags($_REQUEST['edit']); ?>">
<br><input type="submit" value="Save Changes"> <input type="submit" name="preview" value="Save and Toggle Side Preview Mode">
</form>
<?php if ($_SESSION['previewmode']) { ?>
</div>
<div class="six columns" id="right">
<?php
} ?>
<h5> </h5>
<div id="ace_htmleditor"></div>
<?php if ($_SESSION['previewmode']) { ?>
</div>
<?php } ?>
</div>
<script type="text/javascript">
var htmleditor = ace.edit("htmleditor");
htmleditor.setTheme("ace/theme/crimson_editor");
htmleditor.getSession().setMode("ace/mode/html_elixir");
htmleditor.renderer.setShowGutter(false);
function showHTMLInIFramehtmleditor() {
<?php if ($_SESSION['previewmode']) { ?>
$('#ace_htmleditor').html(htmleditor.getValue());
<?php } ?>
var textarea = $('textarea[name="editor"]');
textarea.val(htmleditor.getSession().getValue());
}
htmleditor.on("input", showHTMLInIFramehtmleditor);
htmleditor.setAutoScrollEditorIntoView(true);
showHTMLInIFramehtmleditor();
</script>
<style type="text/css" media="screen">
#htmleditor { height: 600px; }
#right {
height:100%;
position: absolute;
top: 0;
bottom: 0;
right: 0;
overflow-y: scroll;
}
</style>
<?php
}
?>