-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patheditCmd.php
91 lines (88 loc) · 2.34 KB
/
editCmd.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
<?php
/*
* pmt.mcpe.me
*
* Copyright (C) 2015 PEMapModder
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PEMapModder
*/
include_once __DIR__ . "/utils.php";
$proj = forceProject();
if(!isset($_GET["name"])){
redirect(".");
}
$name = strtolower($_GET["name"]);
if(!isset($proj->cmds[$name])){
echo "<pre>Error: Cannot find such command.</pre>";
http_response_code(404);
die;
}
$cmd = $proj->cmds[$name];
?>
<html>
<head>
<title>Edit Command | Plugin Generator</title>
<?= INCLUDE_JQUERY ?>
<script>
$(document).ready(function(){
$("#executorFrame").attr("src", "editExecutor.php?exeId=<?= $cmd->executor->getId() ?>");
$(".editable").click(function(){
var $this = $(this);
var prop = $this.attr("data-property-type");
if(typeof prop === typeof undefined){
return;
}
var value = $this.text();
if(value === "(None)"){
value = "";
}
var newValue = prompt("Please enter the new value for " + prop + ":", value);
if(newValue === value){
return;
}
$.post("apiCmdPropUpdate.php", {
"cmd": <?= json_encode($cmd->name) ?>,
"prop": prop,
"val": newValue
}, function(data){
if(data.status){
$this.html(data.newValue.length == 0 ? "<span class='invalid'>(None)</span>" : data.newValue);
}else{
alert("Error: " + data.error);
}
});
});
});
</script>
<link rel="stylesheet" type="text/css" href="style/normal.css">
</head>
<body>
<h1>Edit Command <i>/<?= $name ?></i></h1>
<hr>
<table>
<tr>
<th>Basic Information</th>
<th>(Click to Edit)</th>
</tr>
<tr>
<td class="left">Description:</td>
<td class="right clickable editable" id="descEdit" data-property-type="desc"><?= htmlspecialchars($cmd->desc) ?></td>
</tr>
<tr>
<td class="left">Usage:</td>
<td class="right clickable editable" id="usageEdit" data-property-type="usage"><?= htmlspecialchars($cmd->usage) ?></td>
</tr>
</table>
<hr>
<h2>Executor</h2>
<iframe id="executorFrame">
<a href="editExecutor.php?exeId=<?= $cmd->executor->getId() ?>">Your browser doesn't support iframe. Click this link to edit executor.</a>
</iframe>
<?php include "footer.php"; ?>
</body>
</html>