2018-08-20 12:58:56 -04:00
|
|
|
<?php
|
|
|
|
if ( ! $auth->isAuthenticated())
|
|
|
|
{
|
|
|
|
echo '<h1>Not Authorized</h1>';
|
2018-09-27 16:45:12 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-10-05 21:32:15 -04:00
|
|
|
$sectionMapping = [
|
2018-10-08 15:45:46 -04:00
|
|
|
'anilist' => 'Anilist API Integration',
|
2018-10-05 21:32:15 -04:00
|
|
|
'config' => 'General Settings',
|
|
|
|
'cache' => 'Caching',
|
|
|
|
'database' => 'Collection Database Settings',
|
|
|
|
];
|
2018-09-27 16:45:12 -04:00
|
|
|
|
2018-10-05 21:32:15 -04:00
|
|
|
$hiddenFields = [];
|
|
|
|
$nestedPrefix = 'config';
|
2018-08-20 12:58:56 -04:00
|
|
|
?>
|
|
|
|
|
2018-10-08 15:45:46 -04:00
|
|
|
<form action="<?= $url->generate('settings-post') ?>" method="POST">
|
2018-10-09 10:11:42 -04:00
|
|
|
<main class='settings form'>
|
2018-10-05 21:32:15 -04:00
|
|
|
<button type="submit">Save Changes</button>
|
2018-10-08 16:38:08 -04:00
|
|
|
<div class="tabs">
|
|
|
|
<?php $i = 0; ?>
|
|
|
|
|
|
|
|
<?php foreach ($form as $section => $fields): ?>
|
|
|
|
<input <?= $i === 0 ? 'checked="checked"' : '' ?> type="radio" id="settings-tab<?= $i ?>"
|
|
|
|
name="settings-tabs"
|
|
|
|
/>
|
|
|
|
<label for="settings-tab<?= $i ?>"><h3><?= $sectionMapping[$section] ?></h3></label>
|
|
|
|
<section class="content">
|
2018-10-09 18:10:20 -04:00
|
|
|
<?php if ($section === 'anilist'): ?>
|
|
|
|
<?php $auth = $anilistModel->checkAuth(); ?>
|
|
|
|
<?php if (array_key_exists('errors', $auth)): ?>
|
|
|
|
<p class="static-message error">Not Authorized.</p>
|
|
|
|
<?= $helper->a(
|
|
|
|
$url->generate('anilist-redirect'),
|
|
|
|
'Link Anilist Account'
|
|
|
|
) ?>
|
|
|
|
<?php else: ?>
|
|
|
|
<?php $expires = $config->get(['anilist', 'access_token_expires']); ?>
|
|
|
|
<p class="static-message info">
|
|
|
|
Linked to Anilist. Your access token will expire around <?= date('F j, Y, g:i a T', $expires) ?>
|
|
|
|
</p>
|
2020-08-21 19:25:27 -04:00
|
|
|
<?php require __DIR__ . '/_form.php' ?>
|
2018-10-09 18:10:20 -04:00
|
|
|
<?= $helper->a(
|
2020-08-21 19:25:27 -04:00
|
|
|
$url->generate('anilist-redirect'),
|
|
|
|
'Update Access Token',
|
|
|
|
['class' => 'bracketed user-btn']
|
|
|
|
) ?>
|
2018-10-09 18:10:20 -04:00
|
|
|
<?php endif ?>
|
2020-08-21 19:25:27 -04:00
|
|
|
<?php else: ?>
|
|
|
|
<?php require __DIR__ . '/_form.php' ?>
|
2018-10-09 18:10:20 -04:00
|
|
|
<?php endif ?>
|
2018-10-08 16:38:08 -04:00
|
|
|
</section>
|
|
|
|
<?php $i++; ?>
|
|
|
|
<?php endforeach ?>
|
|
|
|
</div>
|
2018-10-09 10:11:42 -04:00
|
|
|
<br />
|
2018-10-05 21:32:15 -04:00
|
|
|
<?php foreach ($hiddenFields as $field): ?>
|
2018-10-09 18:10:20 -04:00
|
|
|
<?= $field->__toString() ?>
|
2018-10-05 21:32:15 -04:00
|
|
|
<?php endforeach ?>
|
|
|
|
<button type="submit">Save Changes</button>
|
|
|
|
</main>
|
2018-09-27 16:45:12 -04:00
|
|
|
</form>
|
|
|
|
|
2018-08-20 12:58:56 -04:00
|
|
|
|
|
|
|
|
|
|
|
|