Replaced uses of the compact() function.

This commit is contained in:
flash 2024-01-28 04:03:42 +00:00
parent 982ee10c1a
commit 71ba6d6326

View file

@ -121,26 +121,27 @@ if(preg_match('#^/sounds2(\.[a-f0-9]{8})?.json$#', $reqPath)) {
etag_data('sounds2', $sndLibData . $sndPackData); etag_data('sounds2', $sndLibData . $sndPackData);
$sounds = new stdClass;
$sndLib = parse_ini_string($sndLibData, true, INI_SCANNER_TYPED); $sndLib = parse_ini_string($sndLibData, true, INI_SCANNER_TYPED);
$sndPacks = parse_ini_string($sndPackData, true, INI_SCANNER_TYPED); $sndPacks = parse_ini_string($sndPackData, true, INI_SCANNER_TYPED);
$library = []; $sounds->library = [];
foreach($sndLib as $name => $info) foreach($sndLib as $name => $info)
$library[] = [ $sounds->library[] = [
'name' => $name, 'name' => $name,
'title' => $info['title'], 'title' => $info['title'],
'sources' => $info['sources'], 'sources' => $info['sources'],
]; ];
$packs = []; $sounds->packs = [];
foreach($sndPacks as $name => $info) foreach($sndPacks as $name => $info)
$packs[] = [ $sounds->packs[] = [
'name' => $name, 'name' => $name,
'title' => $info['title'], 'title' => $info['title'],
'events' => $info['events'], 'events' => $info['events'],
]; ];
json_out(compact('library', 'packs')); json_out($sounds);
} }
if(preg_match('#^/sounds(\.[a-f0-9]{8})?.json$#', $reqPath)) { if(preg_match('#^/sounds(\.[a-f0-9]{8})?.json$#', $reqPath)) {
@ -149,10 +150,11 @@ if(preg_match('#^/sounds(\.[a-f0-9]{8})?.json$#', $reqPath)) {
etag_data('sounds', $sndLibData . $sndPackData); etag_data('sounds', $sndLibData . $sndPackData);
$sounds = new stdClass;
$sndLib = parse_ini_string($sndLibData, true, INI_SCANNER_TYPED); $sndLib = parse_ini_string($sndLibData, true, INI_SCANNER_TYPED);
$sndPacks = parse_ini_string($sndPackData, true, INI_SCANNER_TYPED); $sndPacks = parse_ini_string($sndPackData, true, INI_SCANNER_TYPED);
$library = []; $sounds->library = [];
foreach($sndLib as $name => $info) { foreach($sndLib as $name => $info) {
$sources = []; $sources = [];
foreach($info['sources'] as $type => $path) { foreach($info['sources'] as $type => $path) {
@ -162,22 +164,22 @@ if(preg_match('#^/sounds(\.[a-f0-9]{8})?.json$#', $reqPath)) {
]; ];
} }
$library[] = [ $sounds->library[] = [
'id' => $name, 'id' => $name,
'name' => $info['title'], 'name' => $info['title'],
'sources' => $sources, 'sources' => $sources,
]; ];
} }
$packs = []; $sounds->packs = [];
foreach($sndPacks as $name => $info) foreach($sndPacks as $name => $info)
$packs[] = [ $sounds->packs[] = [
'id' => $name, 'id' => $name,
'name' => $info['title'], 'name' => $info['title'],
'events' => $info['events'], 'events' => $info['events'],
]; ];
json_out(compact('library', 'packs')); json_out($sounds);
} }
if(preg_match('#^/texttriggers(\.[a-f0-9]{8})?.json$#', $reqPath)) { if(preg_match('#^/texttriggers(\.[a-f0-9]{8})?.json$#', $reqPath)) {