<ul class="layui-tab-title layui-bg-cyan ct-tab-title">
	<li class="layui-this">数据更新</li>
    <li>翻译配置</li>
    <li>动态渲染配置</li>
	<li>授权码配置</li>
</ul>
<div class="layui-hide" id="public_table" table=""></div>
<!--<form class="layui-form ct-form" table="config">-->
<div class="layui-tab-content ct-tab-content layui-form ct-form" table="config">

    <!-- 数据更新 -->
	<div class="layui-tab-item layui-show">
		<fieldset class="layui-elem-field layui-field-title"><legend>数据更新方式</legend></fieldset>
        <div class="layui-form-item">
            <label class="layui-form-label">更新方式</label>
            <div class="layui-input-block">
                <select name="update_mode" lay-filter="update_mode" lay-verify="required" lay-verType="tips">
                    <option <?php selected( 0, CTSPIDER_CONFIG_DATA['update_mode'] ); ?> value="0">手动更新</option>
                    <option <?php selected( 1, CTSPIDER_CONFIG_DATA['update_mode'] ); ?> value="1">使用Cron计划任务自动更新 (推荐)</option>
                </select>
                <br>
                <div class="layui-form-mid layui-word-aux
                <?php
                    if( empty(selected(1, CTSPIDER_CONFIG_DATA['update_mode'] )) ) {
                        echo 'layui-hide';
                    }
                ?>
                ">
                    <p>如果需要使用<code>Cron计划任务</code>，可以定时向该地址发送请求实现自动检测更新</p>
                    <hr>
                    <p>例如，在cron计划表中添加如下指令：</p>
                    <pre style="font-size: 1.0em"><code>*/10 * * * * curl <?php echo home_url().'?ctspider=auto' ?></code></pre>
                    <hr>
                    <p>将会每10分钟检测一次已启用的任务中是否有新文章可以更新。</p>
                </div>
            </div>
        </div>
	</div>


    <!-- 翻译配置 -->
    <div class="layui-tab-item">
        <fieldset class="layui-elem-field layui-field-title"><legend>百度翻译API配置</legend></fieldset>
        <div class="layui-form-item">
            <label class="layui-form-label">APP ID</label>
            <div class="layui-input-block">
                <input type="text" name="baidu_translate_api" value="<?php echo CTSPIDER_CONFIG_DATA['baidu_translate_api']; ?>" placeholder="" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密 匙</label>
            <div class="layui-input-block">
                <input type="text" name="baidu_translate_key" value="<?php echo CTSPIDER_CONFIG_DATA['baidu_translate_key']; ?>" placeholder="" autocomplete="off" class="layui-input">
                <div class="layui-form-mid layui-word-aux"><a href="https://www.ctspider.com/68.html">如何申请百度翻译API Key <i class="layui-icon layui-icon-help"></i></a></div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">原文语言</label>
            <div class="layui-input-inline">
                <select name="baidu_translate_from">
                    <?php
                        $language = CTbaidu_translate::language();
                        foreach ($language as $key => $value) {
                            echo '<option value="'.$key.'">'.$value.'</option>';
                        }
                    ?>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
                <textarea name="baidu_translate_textdemo" id="baidu_translate_textdemo" class="layui-textarea">Hello world!</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">翻译语言</label>
            <div class="layui-input-inline">
                <select name="baidu_translate_to">
                    <?php
                        foreach ($language as $key => $value) {
                            if ($key != 'auto') {
                                echo '<option value="'.$key.'">'.$value.'</option>';
                            }
                        }
                    ?>
                </select>
                <br><br>
                <button type="button" class="layui-btn layui-btn-normal" lay-filter="baidu_translate_test" >检测</button>
            </div>
        </div>
    </div>


    <!-- 动态渲染配置 -->
    <div class="layui-tab-item">
        <fieldset class="layui-elem-field layui-field-title"><legend>动态渲染配置</legend></fieldset>
        <div class="layui-form-item">
            <label class="layui-form-label">系统选择</label>
            <div class="layui-input-block" style="width: 80%;">
                <input type="radio" name="dynamic_type" value="linux_64" title="Linux 64位" <?php checked('linux_64',CTSPIDER_CONFIG_DATA['dynamic_type']) ?> >
                <input type="radio" name="dynamic_type" value="linux_32" title="Linux 32位" <?php checked('linux_32',CTSPIDER_CONFIG_DATA['dynamic_type']) ?> >
                <input type="radio" name="dynamic_type" value="windows" title="Windows" <?php checked('windows',CTSPIDER_CONFIG_DATA['dynamic_type']) ?> >
            </div>
            <br>
            <div class="layui-form-mid layui-word-aux">
                请在官网下载对应版本的渲染组件即可使用。<a target="_blank" href="https://www.ctspider.com/164.html"><i class="layui-icon layui-icon-component"></i> 立即下载</a>
                <br>
                <br>
                下载对应的系统组件,上传至插件目录下/dynamic/即可
            </div>
            <br>
        </div>
    </div>


    <!-- 授权码 -->
    <div class="layui-tab-item">
        <fieldset class="layui-elem-field layui-field-title"><legend>授权码配置</legend></fieldset>
        <div class="layui-form-item">
            <label class="layui-form-label">授权码</label>
            <div class="layui-input-block">
                <input type="text" lay-vertype="tips" name="token" value="<?php echo CTSPIDER_CONFIG_DATA['token']; ?>" placeholder="填写授权码" autocomplete="off" class="layui-input">
                <br>
                <button type="button" class="layui-btn layui-btn-normal" lay-filter="authority" ><i class="layui-icon layui-icon-loading-1 layui-icon layui-anim layui-anim-rotate layui-anim-loop layui-hide"></i> 授权验证</button>
                <br>
                <div class="layui-form-mid layui-word-aux">Ps: 请先点击保存授权码后，在验证授权。</div>
            </div>
            <?php
                $authority = CTSPIDER_CONFIG_DATA['authority'] ? '已授权' : '未授权';
                $btnclass = CTSPIDER_CONFIG_DATA['authority'] ? '' : 'layui-btn-danger';
            ?>
            <button type="button" class="layui-btn <?php echo $btnclass; ?>" lay-filter="authority-text" disabled><i class="layui-icon layui-icon-auz"></i> <span><?php echo $authority; ?></span></button>
        </div>
    </div>

    <br><br>
    <hr>
    <button type="button" class="layui-btn" lay-submit lay-filter="config" >保存更改</button>

</div>
<!--</form>-->