api/listlangs.php

79 lines
2.1 KiB
PHP
Raw Permalink Normal View History

<?php
/*
Copyright 2019 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';
function uupListLangs($updateId = 0) {
if($updateId) {
$info = uupUpdateInfo($updateId);
}
if(isset($info['info'])) {
$info = $info['info'];
2020-07-22 08:04:20 +02:00
unset($info['files']);
}
if(isset($info['build'])) {
$build = explode('.', $info['build']);
$build = $build[0];
} else {
$build = 15063;
}
if(!isset($info['arch'])) {
$info['arch'] = null;
}
$genPack = uupGetGenPacks($build, $info['arch'], $updateId);
$fancyTexts = uupGetInfoTexts();
$fancyLangNames = $fancyTexts['fancyLangNames'];
$langList = array();
$langListFancy = array();
2019-02-17 18:39:18 +01:00
foreach($genPack as $key => $val) {
if(!count(array_diff(array_keys($val), array('LXP')))) {
continue;
}
if(isset($fancyLangNames[$key])) {
$fancyName = $fancyLangNames[$key];
} else {
2019-02-17 18:39:18 +01:00
$fancyName = $key;
}
2019-02-17 18:39:18 +01:00
$langList[] = $key;
$langListFancy[$key] = $fancyName;
}
if(isset($info)) {
return array(
'apiVersion' => uupApiVersion(),
'langList' => $langList,
'langFancyNames' => $langListFancy,
'updateInfo' => $info
);
} else {
return array(
'apiVersion' => uupApiVersion(),
'langList' => $langList,
'langFancyNames' => $langListFancy
);
}
}