{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-table"></i> {dr_lang('模块域名')} </a>
                </li>
                <li>
                    <a href="#tab_3" data-toggle="tab" onclick="dr_check_domain()"> <i class="fa fa-refresh"></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-4">
                                <div class="input-group" style="width: 300px;">
                                    <input type="text" {if SITE_ID == 1} readonly{/if} name="data[site_domain]" value="{$data['site_domain']}" class="form-control">
                                    <span class="input-group-btn">
                                        {if SITE_ID == 1}
                                        <a class="btn red" href="javascript:dr_iframe('{dr_lang("变更域名")}', '{dr_url("site_domain/edit")}');"><i class="fa fa-edit"></i> {dr_lang('变更')}</a>
                                        {else}
                                        <a class="btn blue" href="{SITE_URL}" target="_blank"><i class="fa fa-send"></i> {dr_lang('访问')}</a>
                                        {/if}
                                    </span>
                                </div>
                                <span class="help-block">{dr_lang('本站的域名，通常www.xxx.com')}</span>
                            </div>


                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label">{dr_lang('本站手机域名')}</label>
                            <div class="col-md-9">
                                <label><input class="form-control input-large" type="text" name="data[mobile_domain]" value="{$data['mobile_domain']}"></label>
                                <span class="help-block">{dr_lang('手机访问时的域名，通常m.xxx.com')}</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label">{dr_lang('本站其他域名')}</label>
                            <div class="col-md-9">
                                <label><textarea class="form-control input-large" style="height:150px" name="data[site_domains]">{str_replace(',',PHP_EOL, $data['site_domains'])}</textarea></label>
                                <span class="help-block">{dr_lang('当前站点支持绑定多个域名，它们将会301到主域名，域名一行一个')}</span>
                            </div>
                        </div>
                        {if SITE_ID > 1}
                        <div class="form-group">
                            <label class="col-md-2 control-label">{dr_lang('本站Web目录')}</label>
                            <div class="col-md-9">
                                <div class="input-group">
                                    <input type="text" name="data[webpath]" id="dr_html_dir" value="{$data[webpath]}" class="form-control">
                                    <span class="input-group-btn">
                                        <button class="btn blue" onclick="dr_test_html_dir('dr_html_dir')" type="button"><i class="fa fa-code"></i> {dr_lang('测试')}</button>
                                    </span>
                                </div>
                                <span class="help-block">{dr_lang('本站的网站目录，必须填写一个有效的目录，并设置可写权限')}</span>
                            </div>
                        </div>
                        {/if}
                    </div>
                </div>

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

                        {loop $module $dir $t}
                        {if !$t.share}
                        <div class="form-group">
                            <label class="col-md-2 control-label">{dr_lang('%s电脑域名', $t.name)}</label>
                            <div class="col-md-9">
                                {if $t.error}
                                <span class="help-block" style="color:#ed6b75;margin-top:7px;">{$t.error}</span>
                                {else}
                                <label><input class="form-control input-large" type="text" name="data[module_{$dir}]" value="{$data['module_'.$dir]}"></label>
                                {/if}
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label">{dr_lang('%s手机域名', $t.name)}</label>
                            <div class="col-md-9">
                                {if $t.error}
                                <span class="help-block" style="color:#ed6b75;margin-top:7px;">{$t.error}</span>
                                {else}
                                <label><input class="form-control input-large" type="text" name="data[module_mobile_{$dir}]" value="{$data['module_mobile_'.$dir]}"></label>
                                <span class="help-block">{dr_lang('如果本站绑定了手机域名，这里必须要绑定域名')}</span>
                                {/if}
                            </div>
                        </div>
                        <div class="form-group" style="margin-bottom: 30px;">
                            <label class="col-md-2 control-label">{dr_lang('%s模块Web目录', $t.name)}</label>
                            <div class="col-md-9">
                                {if $t.error}
                                <span class="help-block" style="color:#ed6b75;margin-top:7px;">{$t.error}</span>
                                {else}
                                <div class="input-group">
                                    <input type="text" name="data[webpath_{$dir}]" id="dr_html_dir_{$dir}" value="{$data['webpath_'.$dir]}" class="form-control">
                                    <span class="input-group-btn">
                                        <button class="btn blue" onclick="dr_test_html_dir('dr_html_dir_{$dir}')" type="button"><i class="fa fa-code"></i> {dr_lang('测试')}</button>
                                    </span>
                                </div>
                                <span class="help-block">{dr_lang('本模块的Web目录，必须填写一个有效的目录，并设置可写权限')}</span>
                                {/if}
                            </div>
                        </div>
                        {/if}
                        {/loop}

                    </div>
                </div>

                <div class="tab-pane " id="tab_3">
                    <div class="form-body form">

                        <div class="form-group">
                            <label class="col-md-2 control-label">{dr_lang('域名检测结果')}</label>
                            <div class="col-md-9">
                                <div id="dr_domain" style="margin-top: 8px;">

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


                    </div>
                </iv>

            </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_check_domain() {
        $.ajax({
            type: "POST",
            dataType: "text",
            url: "{dr_url('api/domain')}",
            data: $("#myform").serialize(),
            success: function(html) {
                $("#dr_domain").html(html);
            },
            error: function(HttpRequest, ajaxOptions, thrownError) {
                dr_ajax_alert_error(HttpRequest, ajaxOptions, thrownError);
            }
        });
    }

</script>

{template "footer.html"}