2024-08-13 19:46:56 +00:00
< ? php
// render config variables array
2024-08-26 18:19:21 +00:00
function renderConfig ( $configPart , $indent , $platform = false , $parent = '' ) {
2024-08-25 10:24:48 +00:00
global $app_root ;
2024-08-26 18:19:21 +00:00
global $config ;
if ( $parent === 'platforms' ) {
2024-08-25 10:24:48 +00:00
?>
2024-08-26 18:19:21 +00:00
< div class = " col-md-8 text-start " >
< a class = " btn btn-secondary " style = " padding: 0px; " href = " <?= $app_root ?>?page=config&action=add " > add </ a >
</ div >
2024-08-25 10:24:48 +00:00
< div class = " border bg-light " style = " padding-left: <?= $indent ?>px; padding-bottom: 20px; padding-top: 20px; " >
< ? php } else {
2024-08-19 10:25:09 +00:00
?>
< div style = " padding-left: <?= $indent ?>px; padding-bottom: 20px; " >
< ? php
2024-08-25 10:24:48 +00:00
}
2024-08-26 18:19:21 +00:00
foreach ( $configPart as $config_item => $config_value ) {
if ( $parent === 'platforms' ) {
$indent = 0 ;
}
2024-08-19 10:25:09 +00:00
?>
< div class = " row mb-1 " style = " padding-left: <?= $indent ?>px; " >
< div class = " col-md-4 text-end " >
< ? = htmlspecialchars ( $config_item ) ?> :
</ div >
< ? php
2024-08-26 18:19:21 +00:00
if ( $parent === 'platforms' ) { ?>
2024-08-25 10:24:48 +00:00
< div class = " col-md-8 text-start " >
< a class = " btn btn-secondary " style = " padding: 2px; " href = " <?= $app_root ?>?platform=<?= htmlspecialchars( $config_item ) ?>&page=config&action=edit " > edit </ a >
2024-08-19 10:25:09 +00:00
< ? php
2024-08-25 10:24:48 +00:00
// we don't delete the last platform
2024-08-26 18:19:21 +00:00
if ( count ( $configPart ) <= 1 ) { ?>
2024-08-25 10:24:48 +00:00
< span class = " btn btn-light " style = " padding: 2px; " href = " # " data - toggle = " tooltip " data - placement = " right " data - offset = " 30.0 " title = " can't delete the last platform " > delete </ span >
< ? php } else { ?>
< a class = " btn btn-danger " style = " padding: 2px; " href = " <?= $app_root ?>?platform=<?= htmlspecialchars( $config_item ) ?>&page=config&action=delete " > delete </ a >
< ? php } ?>
</ div >
< ? php }
if ( is_array ( $config_value )) {
2024-08-26 18:19:21 +00:00
// here we render recursively nested arrays
$indent = $indent + 50 ;
if ( $parent === 'platforms' ) {
$indent = 100 ;
}
2024-08-25 10:24:48 +00:00
if ( $config_item === 'platforms' ) {
2024-08-26 18:19:21 +00:00
renderConfig ( $config_value , $indent , $platform , 'platforms' );
2024-08-25 10:24:48 +00:00
} else {
2024-08-26 18:19:21 +00:00
renderConfig ( $config_value , $indent , $platform );
2024-08-25 10:24:48 +00:00
}
$indent = 0 ;
} else {
// if it's not array, just display it
2024-08-19 10:25:09 +00:00
?>
< div class = " border col-md-8 text-start " >
< ? = htmlspecialchars ( $config_value ? ? '' ) ?>
2024-08-25 10:24:48 +00:00
< ? = $platform ?>
2024-08-19 10:25:09 +00:00
</ div >
< ? php
2024-08-25 10:24:48 +00:00
}
2024-08-19 10:25:09 +00:00
?>
</ div >
< ? php
2024-08-25 10:24:48 +00:00
}
echo '</div>' ;
2024-08-13 19:46:56 +00:00
}
?>