{template "header.html"}
<div class="note note-danger">
    <p><a href="javascript:dr_update_cache('', '');">{dr_lang('更改数据之后需要更新缓存之后才能生效')}</a></p>
</div>

<form action="" class="form-horizontal" method="post" name="myform" id="myform">
    {$form}
    <div class="portlet bordered light myfbody">
        <div class="portlet-title tabbable-line">
            <ul class="nav nav-tabs" style="float:left;">
                <li class="{if $page==0}active{/if}">
                    <a href="#tab_0" data-toggle="tab" onclick="$('#dr_page').val('0')"> <i class="fa fa-cog"></i> {dr_lang('缓存设置')} </a>
                </li>
                <li class="{if $page==1}active{/if}">
                    <a href="#tab_1" data-toggle="tab" onclick="$('#dr_page').val('1')"> <i class="fa fa-share-alt"></i> {dr_lang('站点首页静态')} </a>
                </li>
                <li class="{if $page==2}active{/if}">
                    <a href="#tab_2" data-toggle="tab" onclick="$('#dr_page').val('2')"> <i class="fa fa-th-large"></i> {dr_lang('模块首页静态')} </a>
                </li>
            </ul>
        </div>
        <div class="portlet-body">
            <div class="tab-content">

                <div class="tab-pane {if $page==0}active{/if}" id="tab_0">
                    <div class="form-body">

                        <div class="form-group">
                            <label class="col-md-2 control-label">{dr_lang('缓存开关')}</label>
                            <div class="col-md-9">
                                <input type="checkbox" name="data[SYS_CACHE]" value="1" {if $data['SYS_CACHE']}checked{/if} data-on-text="{dr_lang('开启')}" data-off-text="{dr_lang('关闭')}" data-on-color="success" data-off-color="danger" class="make-switch" data-size="small">
                                <span class="help-block">{dr_lang('推荐开启缓存功能，可以大大提高系统运行效率')}</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-2 control-label">{dr_lang('缓存方式')}</label>
                            <div class="col-md-9">
                                <div class="mt-radio-inline">
                                    <label class="mt-radio mt-radio-outline"><input type="radio" name="data[SYS_CACHE_TYPE]" value="0" {if empty($data['SITE_CLOSE'])}checked{/if} /> {dr_lang('文件')} <span></span></label>
                                    <label class="mt-radio mt-radio-outline"><input type="radio" name="data[SYS_CACHE_TYPE]" value="1" {if $data['SYS_CACHE_TYPE'] == 1}checked{/if} /> Memcached <span></span></label>
                                    <label class="mt-radio mt-radio-outline"><input type="radio" name="data[SYS_CACHE_TYPE]" value="2" {if $data['SYS_CACHE_TYPE'] == 2}checked{/if} /> Redis <span></span></label>
                                </div>
                            </div>
                        </div>

                        <input type="hidden" name="data[SYS_CACHE_SMS]" value="{intval($data['SYS_CACHE_SMS'])}">

                        {loop $cache_var $value $name}
                        <div class="form-group">
                            <label class="col-md-2 control-label">{dr_lang($name)}</label>
                            <div class="col-md-9">
                                <div class="input-inline input-medium">
                                    <div class="input-group">
                                        <input type="text" name="data[SYS_CACHE_{$value}]" value="{intval($data['SYS_CACHE_'.$value])}" class="form-control">
                                        <span class="input-group-addon">
                                            <i class="fa fa-clock-o"></i>
                                        </span>
                                    </div>
                                </div>
                                <span class="help-inline"> {dr_lang('单位小时，0表示不缓存')} </span>
                            </div>
                        </div>
                        {/loop}


                    </div>
                </div>

                <div class="tab-pane  {if $page==1}active{/if}" id="tab_1">
                    <div class="form-body">
                        {loop $ci->site_info $sid $t}
                        <?php $m = \Phpcmf\Service::M('Site')->config($sid);$t = $m['config'];?>
                        <div class="form-group">
                            <label class="col-md-2 control-label">{dr_lang(dr_strcut($t['SITE_NAME'], 10))}</label>
                            <div class="col-md-9">
                                <input type="checkbox" name="site[{$sid}][SITE_INDEX_HTML]" value="1" {if $t['SITE_INDEX_HTML']}checked{/if} data-on-text="{dr_lang('开启')}" data-off-text="{dr_lang('关闭')}" data-on-color="success" data-off-color="danger" class="make-switch" data-size="small">
                                <span class="help-block">{dr_lang('开启之后首页将会自动生成静态文件')}</span>
                            </div>
                        </div>
                        {/loop}
                    </div>
                </div>

                <div class="tab-pane  {if $page==2}active{/if}" id="tab_2">
                    <div class="form-body">
                        {loop $module $t}
                        {if !$t.share}
                        <?php $setting = dr_string2array($t['setting']);?>
                        <div class="form-group">
                            <label class="col-md-2 control-label">{dr_lang($t.name)}</label>
                            <div class="col-md-9">
                                <input type="checkbox" name="module[{$t.id}][module_index_html]" value="1" {if $setting['module_index_html']}checked{/if} data-on-text="{dr_lang('开启')}" data-off-text="{dr_lang('关闭')}" data-on-color="success" data-off-color="danger" class="make-switch" data-size="small">
                                <span class="help-block">{dr_lang('开启之后当前模块的首页将会自动生成静态文件')}</span>
                            </div>
                        </div>
                        {/if}
                        {/loop}
                    </div>
                </div>



            </div>
        </div>
    </div>

    <div class="portlet-body form myfooter">
        <div class="form-actions text-center">
            <button type="button" onclick="dr_ajax_submit('{dr_now_url()}&page='+$('#dr_page').val(), 'myform', '2000')" class="btn green"> <i class="fa fa-save"></i> {dr_lang('保存')}</button>
            <button type="button" onclick="dr_test_cache()" class="btn red"> <i class="fa fa-cloud"></i> {dr_lang('测试')}</button>
        </div>
    </div>
</form>
<script type="text/javascript">
    function dr_to_key() {
        $.get("{dr_url('api/syskey')}", function(data){
            $("#sys_key").val(data);
        });
    }  function dr_test_cache() {
        var loading = layer.load(2, {
            shade: [0.3,'#fff'], //0.1透明度的白色背景
            time: 10000
        });
        $.ajax({
            type: "GET",
            dataType: "json",
            url: "{dr_url('api/test_cache')}",
            success: function(json) {
                layer.close(loading);
                dr_tips(json.code, json.msg);
            },
            error: function(HttpRequest, ajaxOptions, thrownError) {
                dr_ajax_alert_error(HttpRequest, ajaxOptions, thrownError)
            }
        });
    }
</script>
{template "footer.html"}