Move the platform editing to config page

main
Yasen Pramatarov 2024-08-25 13:24:48 +03:00
parent d2213ca3e9
commit 1ba32d86f7
4 changed files with 39 additions and 24 deletions

View File

@ -1,37 +1,60 @@
<?php
// render config variables array
function renderConfig($config, $indent) {
function renderConfig($config, $indent, $platform=false) {
global $app_root;
if (isset($platform) && $platform === true) {
?>
<div class="border bg-light" style="padding-left: <?= $indent ?>px; padding-bottom: 20px; padding-top: 20px;">
<?php } else {
?>
<div style="padding-left: <?= $indent ?>px; padding-bottom: 20px;">
<?php
foreach ($config as $config_item => $config_value) {
}
foreach ($config as $config_item => $config_value) {
?>
<div class="row mb-1" style="padding-left: <?= $indent ?>px;">
<div class="col-md-4 text-end">
<?= htmlspecialchars($config_item) ?>:
</div>
<?php
if (is_array($config_value)) {
?>
if (isset($platform) && $platform === true) { ?>
<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>
<?php
// here we render recursively nested arrays
$indent = $indent + 50;
renderConfig($config_value, $indent);
$indent = 0;
} else {
// if it's not array, just display it
// we don't delete the last platform
if (count($config) <= 1) { ?>
<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)) {
if ($config_item === 'platforms') {
$platform = true;
} else {
$platform = false;
}
// here we render recursively nested arrays
$indent = $indent + 50;
renderConfig($config_value, $indent, $platform);
$indent = 0;
} else {
// if it's not array, just display it
?>
<div class="border col-md-8 text-start">
<?= htmlspecialchars($config_value ?? '')?>
<?= $platform ?>
</div>
<?php
}
}
?>
</div>
<?php
}
echo '</div>';
}
echo '</div>';
}
?>

View File

@ -17,6 +17,7 @@
</div>
<?php } ?>
<br />&nbsp;<br />
<a class="btn btn-secondary" href="<?= $app_root ?>?platform=<?= htmlspecialchars($platform_id) ?>&page=config" />Cancel</a>
<input type="submit" class="btn btn-primary" value="Save" />
</form>
</div>

View File

@ -1,6 +1,6 @@
<!-- widget "config" -->
<div class="card text-center w-50 mx-lef">
<div class="card text-center w-75 mx-lef">
<p class="h4 card-header">Jilo web configuration</p>
<div class="card-body">
<p class="card-text">platform variables</p>

View File

@ -11,21 +11,12 @@
<li class="font-weight-light text-uppercase" style="font-size: 0.5em; color: whitesmoke; margin-right: 70px; align-content: center;">version&nbsp;<?php echo $config['version']; ?></li>
<?php if ( isset($_SESSION['username']) ) { ?>
<!--li><a href="?page=config">config</a></li>
<li><a href="?page=conferences">conferences</a></li>
<li><a href="?page=participants">participants</a></li>
<li><a href="?page=components">components</a></li-->
<li style="margin-right: 0px;">
<li style="margin-right: 3px;">
<a style="background-color: #111;" href="?platform=<?= htmlspecialchars(array_keys($config['platforms'])[$platform_id]) ?>&page=front">
<?= htmlspecialchars($config['platforms'][$platform_id]['name']) ?>
</a>
</li>
<li style="margin: 0px; padding: 0px;">
<a style="background-color: #555; padding-left: 3px; padding-right: 3px;" href="?platform=<?= htmlspecialchars(array_keys($config['platforms'])[$platform_id]) ?>&page=config&action=edit">
<i class="fas fa-wrench" data-toggle="tooltip" data-placement="right" data-offset="30.0" title="configure platform &quot;<?= htmlspecialchars($config['platforms'][$platform_id]['name']) ?>&quot;"></i>
</a>
</li>
<?php } ?>
</ul>