api/listlangs.php

64 lines
1.8 KiB
PHP
Raw Permalink Normal View History

<?php
/*
2023-10-28 23:03:40 +02:00
Copyright 2023 UUP dump API authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
require_once dirname(__FILE__).'/shared/main.php';
require_once dirname(__FILE__).'/shared/packs.php';
2017-12-23 19:22:34 +01:00
require_once dirname(__FILE__).'/updateinfo.php';
2023-10-28 23:03:40 +02:00
function uupListLangsInternal($updateId) {
$genPack = uupApiGetPacks($updateId);
$fancyLangNames = uupGetInfoTexts()['fancyLangNames'];
2023-10-28 23:03:40 +02:00
$langList = [];
$langListFancy = [];
2019-02-17 18:39:18 +01:00
foreach($genPack as $key => $val) {
2023-10-28 23:03:40 +02:00
if(!count(array_diff(array_keys($val), ['LXP', 'FOD']))) {
2021-12-31 11:44:02 +01:00
continue;
}
2019-02-17 18:39:18 +01:00
2023-10-28 23:03:40 +02:00
$fancyName = isset($fancyLangNames[$key]) ? $fancyLangNames[$key] : $key;
2019-02-17 18:39:18 +01:00
$langList[] = $key;
$langListFancy[$key] = $fancyName;
}
2023-10-28 23:03:40 +02:00
return [
'langList' => $langList,
'langFancyNames' => $langListFancy,
2024-06-21 13:31:41 +02:00
'appxPresent' => uupAreAppxPresent($genPack),
2023-10-28 23:03:40 +02:00
];
}
function uupListLangs($updateId = 0, $returnInfo = true) {
if($returnInfo) {
$info = uupUpdateInfo($updateId, ignoreFiles: true);
$info = isset($info['info']) ? $info['info'] : false;
}
2023-10-28 23:03:40 +02:00
$langList = uupListLangsInternal($updateId);
2024-06-19 13:29:23 +02:00
$response = array_merge(
['apiVersion' => uupApiVersion()],
$langList
);
2023-10-28 23:03:40 +02:00
if($returnInfo) $response['updateInfo'] = $info;
return $response;
}