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 <?php
// render config variables array // 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;"> <div style="padding-left: <?= $indent ?>px; padding-bottom: 20px;">
<?php <?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="row mb-1" style="padding-left: <?= $indent ?>px;">
<div class="col-md-4 text-end"> <div class="col-md-4 text-end">
<?= htmlspecialchars($config_item) ?>: <?= htmlspecialchars($config_item) ?>:
</div> </div>
<?php <?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 <?php
// here we render recursively nested arrays // we don't delete the last platform
$indent = $indent + 50; if (count($config) <= 1) { ?>
renderConfig($config_value, $indent); <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>
$indent = 0; <?php } else { ?>
} else { <a class="btn btn-danger" style="padding: 2px;" href="<?= $app_root ?>?platform=<?= htmlspecialchars($config_item) ?>&page=config&action=delete">delete</a>
// if it's not array, just display it <?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"> <div class="border col-md-8 text-start">
<?= htmlspecialchars($config_value ?? '')?> <?= htmlspecialchars($config_value ?? '')?>
<?= $platform ?>
</div> </div>
<?php <?php
} }
?> ?>
</div> </div>
<?php <?php
} }
echo '</div>'; echo '</div>';
} }
?> ?>

View File

@ -17,6 +17,7 @@
</div> </div>
<?php } ?> <?php } ?>
<br />&nbsp;<br /> <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" /> <input type="submit" class="btn btn-primary" value="Save" />
</form> </form>
</div> </div>

View File

@ -1,6 +1,6 @@
<!-- widget "config" --> <!-- 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> <p class="h4 card-header">Jilo web configuration</p>
<div class="card-body"> <div class="card-body">
<p class="card-text">platform variables</p> <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> <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']) ) { ?> <?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"> <a style="background-color: #111;" href="?platform=<?= htmlspecialchars(array_keys($config['platforms'])[$platform_id]) ?>&page=front">
<?= htmlspecialchars($config['platforms'][$platform_id]['name']) ?> <?= htmlspecialchars($config['platforms'][$platform_id]['name']) ?>
</a> </a>
</li> </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 } ?> <?php } ?>
</ul> </ul>