{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==2}active{/if}">
                    <a href="#tab_2" data-toggle="tab" onclick="$('#dr_page').val('2')"> <i class="fa fa-user"></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-photo"></i> {dr_lang('[%s]缩略图', SITE_NAME)} </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_ATTACHMENT_DB]" value="1" {if $data['SYS_ATTACHMENT_DB']}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 hide">
                            <label class="col-md-2 control-label">{dr_lang('栏目缩略图')}</label>
                            <div class="col-md-9">
                                <label><select class="form-control" name="data[SYS_FIELD_THUMB_ATTACH]">
                                    <option value="0"> {dr_lang('本地存储')} </option>
                                    {loop $remote $i $t}
                                    <option value="{$i}" {php echo ($i == $data['SYS_FIELD_THUMB_ATTACH'] ? 'selected' : '');}> {dr_lang($t['name'])} </option>
                                    {/loop}
                                </select></label>
                                <span class="help-block">{dr_lang('适用于栏目缩略图的存储策略')}</span>
                            </div>
                        </div>

                        <div class="form-group hide">
                            <label class="col-md-2 control-label">{dr_lang('栏目编辑器')}</label>
                            <div class="col-md-9">
                                <label><select class="form-control" name="data[SYS_FIELD_CONTENT_ATTACH]">
                                    <option value="0"> {dr_lang('本地存储')} </option>
                                    {loop $remote $i $t}
                                    <option value="{$i}" {php echo ($i == $data['SYS_FIELD_CONTENT_ATTACH'] ? 'selected' : '');}> {dr_lang($t['name'])} </option>
                                    {/loop}
                                </select></label>
                                <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" onclick="$('.dr_attachment_type').hide()" name="data[SYS_ATTACHMENT_SAVE_TYPE]" value="0" {if empty($data['SYS_ATTACHMENT_SAVE_TYPE'])}checked{/if} /> {dr_lang('默认')} <span></span></label>
                                    <label class="mt-radio mt-radio-outline"><input type="radio" onclick="$('.dr_attachment_type').show()" name="data[SYS_ATTACHMENT_SAVE_TYPE]" value="1" {if $data['SYS_ATTACHMENT_SAVE_TYPE']}checked{/if} /> {dr_lang('自定义')} <span></span></label>
                                </div>
                                <span class="help-block">{dr_lang('默认存储目录为：/年月/文件名')}</span>
                            </div>
                        </div>

                        <div class="form-group dr_attachment_type" {if empty($data['SYS_ATTACHMENT_SAVE_TYPE'])}style="display: none"{/if}>
                            <label class="col-md-2 control-label">{dr_lang('存储目录格式')}</label>
                            <div class="col-md-9">
                                <label><input class="form-control input-xlarge" type="text" name="data[SYS_ATTACHMENT_SAVE_DIR]" value="{htmlspecialchars($data['SYS_ATTACHMENT_SAVE_DIR'])}" ></label>
                                <span class="help-block">{dr_lang('留空表示不要目录存储，可填参数格式：{y}表示年，{m}表示月，{d}表示日，/表示目录，不要填写其他特殊符号')}</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-2 control-label">{dr_lang('附件上传目录')}</label>
                            <div class="col-md-9">
                                <div class="input-group input-xlarge">
                                    <input class="form-control " type="text" id="dr_attachment_dir" name="data[SYS_ATTACHMENT_PATH]" value="{htmlspecialchars($data['SYS_ATTACHMENT_PATH'])}" >
                                    <span class="input-group-btn">
                                            <button class="btn blue" onclick="dr_test_domain_dir('dr_attachment_dir')" type="button"><i class="fa fa-code"></i> {dr_lang('测试')}</button>
                                        </span>
                                </div>
                                <span class="help-block">{dr_lang('此目录必须有读写权限，绝对路径请以“/”开头')}</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label">{dr_lang('附件URL地址')}</label>
                            <div class="col-md-9">
                                <div class="input-group input-xlarge">
                                    <input class="form-control " type="text" name="data[SYS_ATTACHMENT_URL]" value="{htmlspecialchars($data['SYS_ATTACHMENT_URL'])}" >
                                    <span class="input-group-btn">
                                            <button class="btn blue" onclick="dr_test_domain()" type="button"><i class="fa fa-wrench"></i> {dr_lang('检测')}</button>
                                        </span>
                                </div>
                                <span class="help-block">{dr_lang('当设置了附件上传目录后，必须为该目录指定域名，用于分离附件，留空表示默认本站地址（站外保存时必须指定域名）')}</span>
                            </div>
                        </div>
                        <div class="form-group" style="display: none" id="dr_test_domain">
                            <label class="col-md-2 control-label">{dr_lang('目录检测结果')}</label>
                            <div class="col-md-9" style="padding-top: 3px; line-height: 25px; color:green" id="dr_test_domain_result">

                            </div>
                        </div>

                    </div>
                </div>

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



                        <div class="form-group">
                            <label class="col-md-2 control-label">{dr_lang('缩略图存储目录')}</label>
                            <div class="col-md-9">
                                <div class="input-group input-xlarge">
                                    <input class="form-control " type="text" id="dr_cache_dir" name="image[cache_path]" value="{htmlspecialchars($image['cache_path'])}" >
                                    <span class="input-group-btn">
                                            <button class="btn blue" onclick="dr_test_domain_dir('dr_cache_dir')" type="button"><i class="fa fa-code"></i> {dr_lang('测试')}</button>
                                        </span>
                                </div>
                                <span class="help-block">{dr_lang('绝对路径请以“/”开头，默认uploadfile/thumb/')}</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-2 control-label">{dr_lang('缩略图访问URL地址')}</label>
                            <div class="col-md-9">
                                <div class="input-group input-xlarge">
                                    <input class="form-control " id="dr_cache_url" type="text" name="image[cache_url]" value="{htmlspecialchars($image['cache_url'])}" >
                                    <span class="input-group-btn">
                                            <button class="btn blue" onclick="dr_test_thumb_domain()" type="button"><i class="fa fa-wrench"></i> {dr_lang('检测')}</button>
                                        </span>
                                </div>

                                <span class="help-block">{dr_lang('缩略图文件访问地址，可单独指定域名，默认/uploadfile/thumb/')}</span>
                            </div>
                        </div>

                        <div class="form-group" style="display: none" id="dr_test_thumb_domain">
                            <label class="col-md-2 control-label">{dr_lang('目录检测结果')}</label>
                            <div class="col-md-9" style="padding-top: 3px; line-height: 25px; color:green" id="dr_test_thumb_domain_result">

                            </div>
                        </div>



                    </div>
                </div>


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


                        <div class="form-group">
                            <label class="col-md-2 control-label">{dr_lang('头像存储目录')}</label>
                            <div class="col-md-9">

                                <div class="input-group input-xlarge">
                                    <input class="form-control " type="text" id="dr_avatar_dir" name="image[avatar_path]" value="{htmlspecialchars($image['avatar_path'])}" >
                                    <span class="input-group-btn">
                                            <button class="btn blue" onclick="dr_test_domain_dir('dr_avatar_dir')" type="button"><i class="fa fa-code"></i> {dr_lang('测试')}</button>
                                        </span>
                                </div>
                                <span class="help-block">{dr_lang('绝对路径请以“/”开头，默认api/member/')}</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label">{dr_lang('头像访问URL地址')}</label>
                            <div class="col-md-9">
                                <div class="input-group input-xlarge">
                                    <input class="form-control " type="text" id="dr_avatar_url" name="image[avatar_url]" value="{htmlspecialchars($image['avatar_url'])}" >
                                    <span class="input-group-btn">
                                            <button class="btn blue" onclick="dr_test_avatar_domain()" type="button"><i class="fa fa-wrench"></i> {dr_lang('检测')}</button>
                                        </span>
                                </div>
                                <span class="help-block">{dr_lang('头像文件访问地址，可单独指定域名，默认/api/member/')}</span>
                            </div>
                        </div>

                        <div class="form-group" style="display: none" id="dr_test_avatar_domain">
                            <label class="col-md-2 control-label">{dr_lang('目录检测结果')}</label>
                            <div class="col-md-9" style="padding-top: 3px; line-height: 25px; color:green" id="dr_test_avatar_domain_result">

                            </div>
                        </div>

                    </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>
        </div>
    </div>
</form>

<script>
    function dr_test_domain() {
        // 延迟加载
        var loading = layer.load(2, {
            shade: [0.3,'#fff'], //0.1透明度的白色背景
            time: 5000
        });
        $('#dr_test_domain').hide();
        $.ajax({type: "POST",dataType:"json", url: admin_file+"?c=api&m=test_attach_domain", data: $('#myform').serialize(),
            success: function(json) {
                layer.close(loading);
                $('#dr_test_domain').show();
                $('#dr_test_domain_result').html(json.msg);
                return false;
            },
            error: function(HttpRequest, ajaxOptions, thrownError) {
                dr_ajax_admin_alert_error(HttpRequest, ajaxOptions, thrownError);
            }
        });
    }
    function dr_test_thumb_domain() {
        // 延迟加载
        var loading = layer.load(2, {
            shade: [0.3,'#fff'], //0.1透明度的白色背景
            time: 5000
        });
        $('#dr_test_domain').hide();
        $.ajax({type: "POST",dataType:"json", url: admin_file+"?c=api&m=test_thumb_domain", data: $('#myform').serialize(),
            success: function(json) {
                layer.close(loading);
                $('#dr_test_thumb_domain').show();
                $('#dr_test_thumb_domain_result').html(json.msg);
                return false;
            },
            error: function(HttpRequest, ajaxOptions, thrownError) {
                dr_ajax_admin_alert_error(HttpRequest, ajaxOptions, thrownError);
            }
        });
    }
    function dr_test_avatar_domain() {
        // 延迟加载
        var loading = layer.load(2, {
            shade: [0.3,'#fff'], //0.1透明度的白色背景
            time: 5000
        });
        $('#dr_test_domain').hide();
        $.ajax({type: "POST",dataType:"json", url: admin_file+"?c=api&m=test_avatar_domain", data: $('#myform').serialize(),
            success: function(json) {
                layer.close(loading);
                $('#dr_test_avatar_domain').show();
                $('#dr_test_avatar_domain_result').html(json.msg);
                return false;
            },
            error: function(HttpRequest, ajaxOptions, thrownError) {
                dr_ajax_admin_alert_error(HttpRequest, ajaxOptions, thrownError);
            }
        });
    }
    function dr_test_domain_dir(id) {
        $.ajax({type: "GET",dataType:"json", url: admin_file+"?c=api&m=test_attach_dir&v="+encodeURIComponent($("#"+id).val()),
            success: function(json) {
                dr_tips(json.code, json.msg, -1);
            },
            error: function(HttpRequest, ajaxOptions, thrownError) {
                dr_ajax_admin_alert_error(HttpRequest, ajaxOptions, thrownError)
            }
        });
    }
</script>
{template "footer.html"}