-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.php
142 lines (140 loc) · 3.79 KB
/
main.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
<?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();
?>
<html>
<head>
<title>Editing <?= $proj->getDesc()->getName() ?> | Plugin Generator</title>
<?= INCLUDE_JQUERY ?>
<script>
$(document).ready(function(){
$(".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("apiProjPropUpdate.php", {
"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);
}
});
});
$("button.delete-cmd").click(function(){
var $this = $(this);
var cmd = $this.attr("data-cmd-name");
if(typeof cmd === typeof undefined){
return;
}
if(prompt("Please type the name of the command ("+cmd+") again to confirm!") == cmd){
$.post("apiCmdDelete.php", {
cmd: cmd
}, function(data){
if(!data.status){
alert("ERROR: " + data.error);
}else{
$("tr[data-cmd-name='" + cmd + "']").remove();
}
})
}else{
alert("Command deletion aborted.");
}
})
});
</script>
<link type="text/css" rel="stylesheet" href="style/normal.css">
</head>
<body>
<h1>Plugin Project: <i><?= htmlspecialchars($proj->getDesc()->getFullName()) ?></i></h1>
<hr>
<table>
<tr>
<th>Basic Information</th>
<th>(Click to Edit)</th>
</tr>
<tr>
<td class="left">Version:</td>
<td class="right clickable editable" id="version" data-property-type="version"><?= htmlspecialchars($proj->getDesc()->getVersion()) ?></td>
</tr>
<tr>
<td class="left">Website:</td>
<td class="right clickable editable" id="website" data-property-type="website"><?= strlen($proj->getDesc()->getWebsite()) > 0 ? htmlspecialchars($proj->getDesc()->getWebsite()) : "<span class='invalid'>(None)</span>" ?></td>
</tr>
</table>
<hr>
<h2>Commands</h2>
<table class="headers">
<tr>
<th>Name</th>
<th>Description</th>
<th>Usage</th>
<th>Aliases</th>
<th>Permission</th>
<th class="delete">Delete</th>
</tr>
<?php foreach($proj->cmds as $cmdName => $cmd): ?>
<tr data-cmd-name="<?= $cmdName ?>">
<td><a href="editCmd.php?name=<?= urlencode($cmd->name) ?>"><?= htmlspecialchars($cmd->name) ?></a></td>
<td><?= htmlspecialchars($cmd->desc) ?></td>
<td><?= htmlspecialchars($cmd->usage) ?></td>
<td><?= htmlspecialchars(implode(", ", $cmd->aliases)) ?></td>
<td><?= htmlspecialchars($cmd->permission) ?></td>
<td>
<button class="button delete-cmd" data-cmd-name="<?= $cmdName ?>">
<span class="delete">Delete</span>
</button>
</td>
</tr>
<?php endforeach; ?>
</table>
<button class="button" onclick="window.location = 'addCmd.php';">Add command</button>
<hr>
<h2>Events</h2>
<table class="headers">
<tr>
<th>Event</th>
<th>Event priority</th>
<th>Not to handle event if another plugin cancelled it?</th>
<th>Edit</th>
</tr>
<?php
foreach($proj->events as $evt):
?>
<tr>
<td></td>
</tr>
<?php endforeach; ?>
</table>
<hr>
<?php include "footer.php"; ?>
<div id="editDialog" title="Edit " class="dialogs">
<p>New value:</p>
<input type="text" id="newValueInput" class="undefined">
</div>
</body>
</html>