listeditions.php cleanup

This commit is contained in:
Kaenbyou Rin 2023-10-28 23:17:34 +02:00
parent 954547ea84
commit 5777ff09b6

View File

@ -1,6 +1,6 @@
<?php <?php
/* /*
Copyright 2022 UUP dump API authors Copyright 2023 UUP dump API authors
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -17,60 +17,35 @@ limitations under the License.
require_once dirname(__FILE__).'/shared/main.php'; require_once dirname(__FILE__).'/shared/main.php';
require_once dirname(__FILE__).'/shared/packs.php'; require_once dirname(__FILE__).'/shared/packs.php';
require_once dirname(__FILE__).'/updateinfo.php';
function uupListEditions($lang = 'en-us', $updateId = 0) { function uupListEditions($lang = 'en-us', $updateId = 0) {
if($updateId) {
$info = uupUpdateInfo($updateId, false, true);
}
if(!$lang) { if(!$lang) {
return array('error' => 'UNSUPPORTED_LANG'); return array('error' => 'UNSUPPORTED_LANG');
} }
if(isset($info['info'])) $info = $info['info']; $lang = strtolower($lang);
$genPack = uupApiGetPacks($updateId);
$fancyEditionNames = uupGetInfoTexts()['fancyEditionNames'];
if(isset($info['build'])) { if(!isset($genPack[$lang])) {
$build = explode('.', $info['build']); return array('error' => 'UNSUPPORTED_LANG');
$build = $build[0];
} else {
$build = 15063;
} }
if(!isset($info['arch'])) { $editionList = [];
$info['arch'] = null; $editionListFancy = [];
}
$genPack = uupGetGenPacks($build, $info['arch'], $updateId);
$fancyTexts = uupGetInfoTexts();
$fancyEditionNames = $fancyTexts['fancyEditionNames'];
if($lang) {
$lang = strtolower($lang);
if(!isset($genPack[$lang])) {
return array('error' => 'UNSUPPORTED_LANG');
}
}
$editionList = array();
$editionListFancy = array();
foreach(array_keys($genPack[$lang]) as $edition) { foreach(array_keys($genPack[$lang]) as $edition) {
if($edition == 'LXP') continue; if(in_array($edition, ['LXP', 'FOD'])) continue;
if($edition == 'FOD') continue;
if(isset($fancyEditionNames[$edition])) { $fancyName = isset($fancyEditionNames[$edition]) ? $fancyEditionNames[$edition] : $edition;
$fancyName = $fancyEditionNames[$edition];
} else {
$fancyName = $edition;
}
$editionList[] = $edition; $editionList[] = $edition;
$editionListFancy[$edition] = $fancyName; $editionListFancy[$edition] = $fancyName;
} }
return array( return [
'apiVersion' => uupApiVersion(), 'apiVersion' => uupApiVersion(),
'editionList' => $editionList, 'editionList' => $editionList,
'editionFancyNames' => $editionListFancy, 'editionFancyNames' => $editionListFancy,
); ];
} }