2020-08-06 18:27:25 +02:00
|
|
|
<?PHP
|
|
|
|
/**
|
|
|
|
* Parent class for controlled lists of available values at md.
|
|
|
|
*
|
|
|
|
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
|
|
|
*/
|
2020-08-07 00:12:49 +02:00
|
|
|
declare(strict_types = 1);
|
2020-08-06 18:27:25 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generic class for value sets.
|
|
|
|
*/
|
|
|
|
class MDValueSet {
|
|
|
|
/**
|
2020-08-07 10:18:10 +02:00
|
|
|
* Gets an unsorted array based on provided keys and their translations.
|
2020-08-06 18:27:25 +02:00
|
|
|
*
|
|
|
|
* @param MDTlLoader $tlLoader Translation loader.
|
|
|
|
* @param array<string> $keyList List of keys to get translations for.
|
|
|
|
* @param string $tlFileName Name of the translation file.
|
|
|
|
* @param string $tlVarName Variable of the translation.
|
|
|
|
*
|
|
|
|
* @return array<string>
|
|
|
|
*/
|
2020-08-07 10:18:10 +02:00
|
|
|
public static function getTlUnsortedList(MDTlLoader $tlLoader, array $keyList, string $tlFileName, string $tlVarName):array {
|
2020-08-06 18:27:25 +02:00
|
|
|
|
|
|
|
$output = [];
|
|
|
|
foreach ($keyList as $tID) {
|
2021-02-06 20:10:17 +01:00
|
|
|
if ($tID === "") {
|
|
|
|
$output[$tID] = "";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$output[$tID] = $tlLoader->tl($tlFileName, $tlVarName, $tID);
|
|
|
|
}
|
2020-08-06 18:27:25 +02:00
|
|
|
}
|
|
|
|
|
2020-08-07 10:18:10 +02:00
|
|
|
return $output;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a list of entries in a translated version.
|
|
|
|
*
|
|
|
|
* @param MDTlLoader $tlLoader Translation loader.
|
|
|
|
* @param array<string> $keyList List of keys to get translations for.
|
|
|
|
* @param string $tlFileName Name of the translation file.
|
|
|
|
* @param string $tlVarName Variable of the translation.
|
|
|
|
*
|
|
|
|
* @return array<string>
|
|
|
|
*/
|
|
|
|
public static function getTlSortedList(MDTlLoader $tlLoader, array $keyList, string $tlFileName, string $tlVarName):array {
|
|
|
|
|
|
|
|
$output = self::getTlUnsortedList($tlLoader, $keyList, $tlFileName, $tlVarName);
|
2020-08-06 18:27:25 +02:00
|
|
|
asort($output);
|
|
|
|
return $output;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|