more game details
This commit is contained in:
+12
-2
@@ -84,11 +84,14 @@ function saveGameStatus(int $igdbId, string $name, ?string $originalName, int $s
|
||||
$pdo = getDb();
|
||||
$hasCover = gameHasColumn('cover_url');
|
||||
$hasReleaseYear = gameHasColumn('release_year');
|
||||
$hasJson = gameHasColumn('json');
|
||||
$releaseYear = $GLOBALS['__release_year'] ?? null;
|
||||
$gameJson = $GLOBALS['__game_json'] ?? null;
|
||||
|
||||
$fields = ['igdb_id', 'name', 'original_name', 'status', 'note'];
|
||||
if ($hasCover) $fields[] = 'cover_url';
|
||||
if ($hasReleaseYear) $fields[] = 'release_year';
|
||||
if ($hasJson) $fields[] = 'json';
|
||||
|
||||
$placeholders = array_map(fn($f) => ':'.$f, $fields);
|
||||
$updates = [];
|
||||
@@ -115,6 +118,7 @@ function saveGameStatus(int $igdbId, string $name, ?string $originalName, int $s
|
||||
case 'note': $params[':note'] = $note; break;
|
||||
case 'cover_url': $params[':cover_url'] = $coverUrl; break;
|
||||
case 'release_year': $params[':release_year'] = $releaseYear; break;
|
||||
case 'json': $params[':json'] = $gameJson; break;
|
||||
}
|
||||
}
|
||||
$stmt->execute($params);
|
||||
@@ -483,7 +487,10 @@ if (isset($_GET['action'])) {
|
||||
$id = (int)$idParam;
|
||||
if ($id <= 0) error_response('Invalid \"id\"', 400);
|
||||
$body = sprintf(
|
||||
'fields id,name,summary,storyline,first_release_date,genres.name,platforms.name,cover.image_id,screenshots.image_id,involved_companies.company.name,websites.url,websites.category,age_ratings.rating,age_ratings.category,language_supports.language; where id = %d;',
|
||||
'fields id,name,summary,storyline,first_release_date,genres.name,platforms.name,cover.image_id,screenshots.image_id,'
|
||||
.'involved_companies.company.name,involved_companies.developer,involved_companies.publisher,'
|
||||
.'websites.url,websites.category,age_ratings.rating,age_ratings.category,language_supports.language,'
|
||||
.'game_modes.name,themes.name,player_perspectives.name,game_engines.name; where id = %d;',
|
||||
$id
|
||||
);
|
||||
$results = igdbRequest('/games', $body);
|
||||
@@ -1081,7 +1088,8 @@ try {
|
||||
loc.title AS loc_title,
|
||||
loc.summary AS loc_summary,
|
||||
loc.storyline AS loc_storyline,
|
||||
loc.locked AS loc_locked
|
||||
loc.locked AS loc_locked,
|
||||
g.json AS json
|
||||
FROM game g
|
||||
LEFT JOIN igdb_localizations loc
|
||||
ON loc.igdb_id = g.igdb_id AND loc.lang = ?
|
||||
@@ -1350,7 +1358,9 @@ try {
|
||||
$lockFlag = array_key_exists('locked', $in) ? (int)!!$in['locked'] : null;
|
||||
$coverUrl = isset($in['cover_url']) ? trim($in['cover_url']) : null;
|
||||
$releaseYear = isset($in['release_year']) ? (int)$in['release_year'] : null;
|
||||
$gameJson = isset($in['json']) ? $in['json'] : null;
|
||||
$GLOBALS['__release_year'] = $releaseYear;
|
||||
$GLOBALS['__game_json'] = $gameJson !== null ? json_encode($gameJson, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES) : null;
|
||||
if ($igdbId <= 0) fail('Invalid "igdb_id"');
|
||||
if ($name === '') fail('Missing "name"');
|
||||
if ($status < 0 || $status > 2) fail('Invalid "status" (0,1,2)');
|
||||
|
||||
Reference in New Issue
Block a user