From 3ec7f670b8f8fc0f0c6dde3a6c807f0f4cf8cab0 Mon Sep 17 00:00:00 2001 From: Frank Harris Date: Sat, 31 Jan 2026 12:15:53 -0600 Subject: [PATCH] rebuild the query page --- .../controllers/SteamWorkshopController.php | 56 ++++++++ .../steam_workshop/views/monitor_search.php | 120 ++++++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 modules/steam_workshop/views/monitor_search.php diff --git a/modules/steam_workshop/controllers/SteamWorkshopController.php b/modules/steam_workshop/controllers/SteamWorkshopController.php index d492295a..c4138581 100644 --- a/modules/steam_workshop/controllers/SteamWorkshopController.php +++ b/modules/steam_workshop/controllers/SteamWorkshopController.php @@ -27,6 +27,11 @@ class SteamWorkshopController return; } + if ($action === 'monitor_search') { + $this->handleMonitorSearch($userId, $isAdmin); + return; + } + echo ''; echo ''; @@ -67,6 +72,57 @@ class SteamWorkshopController $this->renderEdit($home, $config, $isAdmin, $adapterLocked); } + private function handleMonitorSearch(int $userId, bool $isAdmin): void + { + $homeId = isset($_GET['home_id']) ? (int)$_GET['home_id'] : 0; + $query = trim((string)($_GET['q'] ?? '')); + $page = isset($_GET['page']) ? max(1, (int)$_GET['page']) : 1; + $perPage = isset($_GET['per_page']) ? max(1, min(100, (int)$_GET['per_page'])) : 25; + + $error = null; + $results = []; + $request = null; + $requestSummary = null; + + if ($homeId <= 0) { + print_failure($this->lang['error_missing_home'] ?? 'Home ID missing.'); + return; + } + + $home = $this->service->getHome($homeId, $userId, $isAdmin); + if ($home === null) { + print_failure($this->lang['error_home_not_found'] ?? 'Home not found.'); + return; + } + + $gameKey = (string)($home['game_key'] ?? ''); + $appId = $gameKey !== '' ? $this->service->getSteamAppIdForGameKey($gameKey) : null; + + if ($query !== '' && $appId !== null) { + $payload = $this->service->searchWorkshopItems($gameKey, $query, $perPage, $page); + $results = $payload['results']; + $error = $payload['error']; + $request = $payload['request']; + $requestSummary = $payload['request']['summary'] ?? null; + } elseif ($query !== '' && $appId === null) { + $error = $this->lang['error_home_not_found'] ?? 'Workshop search is unavailable for this server.'; + } + + $this->render('monitor_search', [ + 'lang' => $this->lang, + 'home' => $home, + 'homeId' => $homeId, + 'query' => $query, + 'page' => $page, + 'perPage' => $perPage, + 'results' => $results, + 'error' => $error, + 'request' => $request, + 'requestSummary' => $requestSummary, + 'appId' => $appId, + ]); + } + private function handleEdit(int $userId, bool $isAdmin): void { $homeId = isset($_GET['home_id']) ? (int)$_GET['home_id'] : 0; diff --git a/modules/steam_workshop/views/monitor_search.php b/modules/steam_workshop/views/monitor_search.php new file mode 100644 index 00000000..4956fedf --- /dev/null +++ b/modules/steam_workshop/views/monitor_search.php @@ -0,0 +1,120 @@ + +
+

+ +
+

+

+ +

+ +
+
+
+
+
+
+
+
+
+
+ + +
+ +
+ + +
+ + + + + +
+ + +
+ +
+ + +
+ : +
+
+ + + +
+ +
+ + + + +
+

+

+
+ + + + + + + + + + + + + + + + + + +
+ +
+
+
+ +
+ +
+ + +
+