*/ declare(strict_types = 1); require __DIR__ . '/../provide_env.php'; function generateStyle():string { return ' '; } /** * Generates the links to other available langauges. * * @param int|null $id ID of the current page. * * @return string */ function generateHeader(?int $id = null):string { $output = ''; foreach (AVAILABLE_LANGS as $tLang) { $output .= ' ' . $tLang . ' '; } $output .= '
'; return $output; } /** * Generates a list page. * * @param string $lang Currently used language. * @param array $eventTypes List of available event types. * * @return string */ function generateListPage(string $lang, array $eventTypes):string { $output = generateStyle(); $output .= generateHeader(); $output .= '

Event types

'; foreach ($eventTypes as $type) { $output .= '

' . $type['ereignistyp_id'] . ': ' . $type['ereignistyp_name'] . '

' . $type['ereignistyp_explica'] . '


'; } return $output; } /** * Generates a list page. * * @param string $lang Currently used language. * @param array{ereignistyp_id: int, ereignistyp_name: string, ereignistyp_explica: string} $eventType List of available event types. * * @return string */ function generateEventTypePage(string $lang, array $eventType):string { $output = generateStyle(); $output .= generateHeader($eventType['ereignistyp_id']); $output .= '

' . $eventType['ereignistyp_name'] . '

ID
' . $eventType['ereignistyp_id'] . '
-
' . $eventType['ereignistyp_explica'] . '

x '; return $output; } // Bootstrap define('AVAILABLE_LANGS', MD_STD::scandir(__DIR__ . "/../l10n/translation-musdb")); if (!is_dir(__DIR__ . '/../public')) { mkdir(__DIR__ . '/../public'); } foreach (AVAILABLE_LANGS as $lang) { $tlLoader = new MDTlLoader("ereignis_auswahl", $lang); $eventTypes = []; foreach (MDEventsSet::EVENT_IDS as $j) { $eventTypes[$j] = [ 'ereignistyp_id' => (int)$j, 'ereignistyp_name' => $tlLoader->tl("eventtype_name", "eventname", $j), 'ereignistyp_explica' => $tlLoader->tl("eventtype_explica", "ereignistyp_explica", $j), ]; } $langDir = __DIR__ . '/../public/' . $lang; if (!is_dir($langDir)) mkdir($langDir); file_put_contents($langDir . '/index.htm', generateListPage($lang, $eventTypes)); foreach ($eventTypes as $id => $eventType) { file_put_contents($langDir . '/' . $id . '.htm', generateEventTypePage($lang, $eventType)); } }