jdarwood007

jdarwood007 commited on 2023-02-24 19:15:52
Showing 6 changed files, with 17 additions and 5 deletions.

... ...
@@ -216,8 +216,8 @@ class DevToolsHooks
216 216
 					'data' => [
217 217
 						'function' => function($data) {
218 218
 							if (is_null($data['instance']))
219
-								return '<input type="submit" value="' . $this->dt->txt('search') . '" />';
220
-							return '<button name="edit" value="' . $data['key'] . '">' . $this->dt->txt('edit') . '</button>';
219
+								return '<input type="submit" value="' . $this->dt->txt('search') . '" class="button" />';
220
+							return '<button name="edit" value="' . $data['key'] . '" class="button">' . $this->dt->txt('edit') . '</button>';
221 221
 						},
222 222
 					],
223 223
 				],
... ...
@@ -507,6 +507,9 @@ class DevToolsHooks
507 507
 	private function getHookData(string $hookID): array
508 508
 	{
509 509
 		$hooks = $this->getRawHooks();
510
+		$hook = [];
511
+
512
+		if ($hookID !== '')
510 513
 			$hook = array_filter(
511 514
 				$hooks,
512 515
 				function($value) use ($hookID) {
... ...
@@ -34,6 +34,10 @@ function devtools_formhandler(e) {
34 34
 	e.stopPropagation();
35 35
 
36 36
 	let form = $(e.data.form ?? "div#devtools_menu #frmLogin");
37
+	let formData = form.serializeArray();
38
+
39
+	/* Inject the button/input that was clicked */
40
+	formData.push({ name: e.originalEvent.submitter.name, value: e.originalEvent.submitter.value });
37 41
 
38 42
 	$.ajax({
39 43
 		url: form.prop("action") + ";ajax",
... ...
@@ -44,7 +48,7 @@ function devtools_formhandler(e) {
44 48
 		xhrFields: {
45 49
 			withCredentials: typeof allow_xhjr_credentials !== "undefined" ? allow_xhjr_credentials : false
46 50
 		},
47
-		data: form.serialize(),
51
+		data: formData,
48 52
 		success: function(data, status, xhr) {
49 53
 			if (e.data.frame.length > 0) {
50 54
 				$(document).find(e.data.frame).html($(data).html());
... ...
@@ -26,9 +26,11 @@ class DevTools
26 26
 	private string $scripturl;
27 27
 	private array $context;
28 28
 	private array $smcFunc;
29
-	private array $modSettings;
29
+	/* This is array in "theory" only.  SMF sometimes will null this when pulling from cache and causes an error */
30
+	private ?array $modSettings;
30 31
 	private array $txt;
31
-	private bool $db_show_debug;
32
+	/* Sometimes in SMF, this is null, which is unusal for a boolean */
33
+	private ?bool $db_show_debug;
32 34
 
33 35
 	/*
34 36
 	 * Builds the main DevTools object.  This also loads a few globals into easy to access properties, some by reference so we can update them
... ...
@@ -8,3 +8,6 @@ This gives a popup window for you to work with a package to do actions such as:
8 8
 
9 9
 This is intended for development purposes, not production uses.
10 10
 This customization is intended to only be used with customizations that do not modify SMF sources (boardmod or xml) and are hook only.
11
+To use this, your customization must be in the folder format, not in a compressed archive (.tar.gz or .zip) inside the Packages folder.
12
+Extended information on how to use this tool can be found here: https://github.com/jdarwood007/smfmod_devtools/wiki
13
+