2018-08-20 12:58:56 -04:00
|
|
|
<?php
|
2018-09-27 16:45:12 -04:00
|
|
|
use function Aviat\AnimeClient\loadTomlByFile;
|
|
|
|
|
|
|
|
$settings = loadTomlByFile($config->get('config_dir'));
|
2018-08-20 12:58:56 -04:00
|
|
|
|
|
|
|
if ( ! $auth->isAuthenticated())
|
|
|
|
{
|
|
|
|
echo '<h1>Not Authorized</h1>';
|
2018-09-27 16:45:12 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function render_settings_form ($data, $file)
|
|
|
|
{
|
|
|
|
ob_start();
|
|
|
|
foreach ($data as $key => $value)
|
|
|
|
{
|
|
|
|
?>
|
|
|
|
<tr>
|
|
|
|
<td><label for="<?= $key ?>"><?= $key ?></label></td>
|
|
|
|
<td>
|
|
|
|
<?php if (is_scalar($value)): ?>
|
|
|
|
<input
|
|
|
|
type="text"
|
|
|
|
id="<?= $key ?>"
|
|
|
|
name="config[<?= $file ?>][<?= $key ?>]"
|
|
|
|
value="<?= $value ?>"
|
|
|
|
/>
|
|
|
|
<?php else: ?>
|
|
|
|
<table><?= render_settings_form($value, $file); ?></table>
|
|
|
|
<?php endif ?>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
|
|
|
$buffer = ob_get_contents();
|
|
|
|
ob_end_clean();
|
|
|
|
|
|
|
|
return $buffer;
|
2018-08-20 12:58:56 -04:00
|
|
|
}
|
2018-09-27 16:45:12 -04:00
|
|
|
|
2018-08-20 12:58:56 -04:00
|
|
|
?>
|
|
|
|
|
2018-09-27 16:45:12 -04:00
|
|
|
<pre><?= print_r($_POST, TRUE) ?></pre>
|
|
|
|
|
|
|
|
<?php foreach($settings as $file => $properties): ?>
|
|
|
|
<form action="<?= $_SERVER['REQUEST_URI'] ?>" method="POST">
|
|
|
|
<table class="form">
|
|
|
|
<caption><?= $file ?></caption>
|
|
|
|
<tbody>
|
|
|
|
<?= render_settings_form($properties, $file); ?>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<button type="submit">Save Changes</button>
|
|
|
|
</form>
|
|
|
|
<?php endforeach ?>
|
|
|
|
|
2018-08-20 12:58:56 -04:00
|
|
|
|
|
|
|
|
|
|
|
|