<?php


defined('_IN_JOHNADM') or die('Error: restricted access');

/** @var Psr\Container\ContainerInterface $container */
$container = App::getContainer();

/** @var Johncms\Api\UserInterface $systemUser */
$systemUser = $container->get(Johncms\Api\UserInterface::class);

$config = $container->get('config')['johncms'];
if ($systemUser->id !== '1') {
    header('Location: ../?err');
    exit;
}
echo '<div class="mainblok">';
echo '<div class="phdr"><a href="index.php"><b>' . _t('Admin Panel') . '</b></a> | LoadPage</div>';

if (isset($_POST['submit'])) {
    $config['LoadPage'] = isset($_POST['a']) ? intval($_POST['a']) : 0;
    $config['Lskin'] = isset($_POST['b']) ? trim($_POST['b']) : 'blue';
    $config['Tskin'] = isset($_POST['c']) ? trim($_POST['c']) : 'simple';

    $configFile = "<?php\n\n" . 'return ' . var_export(['johncms' => $config], true) . ";\n";

    if (!file_put_contents(ROOT_PATH . 'system/config/system.local.php', $configFile)) {
        echo 'ERROR: Can not write system.local.php</body></html>';
        exit;
    }

    echo '<div class="rmenu">' . _t('Settings are saved successfully') . '</div>';

    if (function_exists('opcache_reset')) {
        opcache_reset();
    }
} 






echo '<form method="post" action="index.php?act=LoadPage">';

echo '<div class="menu">';
echo '<p>' .
    '<h3>&#160;PageLoader</h3>' .
    '<div style="font-size: x-small">' .
    '<input type="radio" value="1" name="a" ' . ($config['LoadPage'] == 1 ? 'checked="checked"' : '') . '/>&#160;Default <font color="red"><i>(refresh page and select type)</i></font><br>' .
    '<input type="radio" value="2" name="a" ' . ($config['LoadPage'] == 2 ? 'checked="checked"' : '') . '/>&#160;Windows8<br>' .
    '<input type="radio" value="3" name="a" ' . ($config['LoadPage'] == 3 ? 'checked="checked"' : '') . '/>&#160;Ajax Loading<br>' .
    '<input type="radio" value="4" name="a" ' . ($config['LoadPage'] == 4 ? 'checked="checked"' : '') . '/>&#160;Slow Loading<br>' .
    '<input type="radio" value="0" name="a" ' . (!$config['LoadPage'] ? 'checked="checked"' : '') . '/>&#160;OFF</div></p>';

if ($config['LoadPage'] == '1') { 
echo '<p>' .
    '<h3>&#160;PageLoader Color</h3>' .
    '<div style="font-size: x-small">' .
    '<input type="radio" value="blue" name="b" ' . ($config['Lskin'] == 'blue' ? 'checked="checked"' : '') . '/>&#160;Blue<br>' .
    '<input type="radio" value="red" name="b" ' . ($config['Lskin'] == 'red' ? 'checked="checked"' : '') . '/>&#160;Red<br>' .
    '<input type="radio" value="green" name="b" ' . ($config['Lskin'] == 'green' ? 'checked="checked"' : '') . '/>&#160;Green</div></p>';

echo '<p>' .
    '<h3>&#160;PageLoader Type</h3>' .
    '<div style="font-size: x-small">' .
 '<input type="radio" value="atom" name="c" ' . ($config['Tskin'] == 'atom' ? 'checked="checked"' : '') . '/>&#160;Atom<br>' .
 '<input type="radio" value="bounce" name="c" ' . ($config['Tskin'] == 'bounce' ? 'checked="checked"' : '') . '/>&#160;Bounce<br>' .
 '<input type="radio" value="circle" name="c" ' . ($config['Tskin'] == 'circle' ? 'checked="checked"' : '') . '/>&#160;Circle<br>' .
 '<input type="radio" value="loading" name="c" ' . ($config['Tskin'] == 'loading' ? 'checked="checked"' : '') . '/>&#160;Loading<br>' .
 '<input type="radio" value="radar" name="c" ' . ($config['Tskin'] == 'radar' ? 'checked="checked"' : '') . '/>&#160;Radar<br>' .
 '<input type="radio" value="shop" name="c" ' . ($config['Tskin'] == 'shop' ? 'checked="checked"' : '') . '/>&#160;Shop<br>' .
 '<input type="radio" value="simple" name="c" ' . ($config['Tskin'] == 'simple' ? 'checked="checked"' : '') . '/>&#160;Simple<br>' .
 '<input type="radio" value="fill" name="c" ' . ($config['Tskin'] == 'fill' ? 'checked="checked"' : '') . '/>&#160;fill<br>' .
 '<input type="radio" value="flash" name="c" ' . ($config['Tskin'] == 'flash' ? 'checked="checked"' : '') . '/>&#160;Flash<br>' .
 '<input type="radio" value="flat" name="c" ' . ($config['Tskin'] == 'flat' ? 'checked="checked"' : '') . '/>&#160;Flat<br>' .
 '<input type="radio" value="indicator" name="c" ' . ($config['Tskin'] == 'indicator' ? 'checked="checked"' : '') . '/>&#160;Indicator<br>' .
 '<input type="radio" value="osx" name="c" ' . ($config['Tskin'] == 'osx' ? 'checked="checked"' : '') . '/>&#160;Osx<br>' .
 '<input type="radio" value="counter" name="c" ' . ($config['Tskin'] == 'counter' ? 'checked="checked"' : '') . '/>&#160;Counter</div></p>';
}

echo '</div>';
echo '<div class="phdr"><small>Load Page Progress By Aan Gabriel Elfha Gymkhana<br/>You select color: '.$config['Lskin'].' And Type: '.$config['Tskin'].'</small></div>' .
    '<div class="topmenu">' .
    '<p><input type="submit" name="submit" id="button" value="' . _t('Save') . '" /></p>' .
    '<p><a href="index.php">' . _t('Admin Panel') . '</a></p></div></form>';
echo '</div>';







