<@tools.fileExist type='file' path=path><#assign exists=object></@tools.fileExist>
<#if path?has_content>
    <#assign
        editorType={'css':'css','js':'javascript','xml':'xml'}
        fileType=path?keep_after_last('.')?lower_case
    />
</#if>
<#assign safeFileTypes=[]/>
<form method="post" autocomplete="off" action="cmsWebFile/save<#if !exists>?callbackType=closeCurrent&navTabId=cmsWebFile/list</#if>" class="pageForm required-validate" onsubmit="return validateCallback(this, navTabAjaxDone);">
    <input type="hidden" name="_csrf" value="<@tools.csrfToken admin=true/>"/>
    <div class="formBar card">
        <ul>
            <#if exists>
                <li><a class="button" href="cmsWebFile/delete?paths=${(path?url)!}&callbackType=closeCurrent&navTabId=cmsWebFile/list&_csrf=<@tools.csrfToken admin=true/>" title="<@t.page 'confirm.delete_file'/>" target="ajaxTodo"><i class="icon-trash icon-large"></i><@t.page 'button.delete'/></a></li>
            </#if>
            <li><button type="submit" class="buttonActive" title="ctrl+s"<#if path?has_content> lock-url="common/lock?itemType=file&itemId=${(path?url)!}" close-url="common/unlock?itemType=file&itemId=${(path?url)!}"</#if>><@t.page 'button.save'/></button></li>
        </ul>
    </div>
    <div class="card">
        <h2 class="contentTitle">
            <a class="button" href="cmsWebFile/lookup.html?fullPath=true" target="dialog" mask="true"><@t.page 'webfile'/></a>
            <a class="button" href="cmsFileHistory/list.html?type=file&path=${(path?url)!}" lookupGroup=""><@t.page 'history'/></a>
            <#if getAiChatEnable?? && getDictEnable?is_method && getAiChatEnable()>
                <a class="button" href="simpleAi/chat.html?field=content&scene=html" lookupGroup="" width="800" height="500">AI</a>
            </#if>
            <div class="float-right">
                <select class="combox codeTheme">
                <#list codeTheme as k,a>
                    <option value="${k}">${a}</option>
                </#list>
                </select>
            </div>
        </h2>
        <div class="pageFormContent" layoutH>
            <div class="clearfix">
                <label><@t.page 'path'/>:</label>
                <input name="path" class="required" type="text" maxlength="500" size="50" value="${(path)!}<#if !exists>/filename.html<#assign fileType='html'/></#if>"/>
                <@sys.configData code="safe"><#assign safeFileTypes=(object.allow_files?split(','))![]/></@sys.configData>
                <span class="info warning<#if !fileType?has_content || safeFileTypes?has_content && safeFileTypes?seq_contains('.'+fileType)> hide</#if>">
                    <@t.message "verify.custom.fileType"/>
                    <a href="sysConfigData/edit.html?code=safe" target="navTab" rel="sysConfigData/edit"><i class="icon-edit"></i><@t.page 'config_data.edit'/></a>
                </span>
            </div>
            <div>
                <textarea name="content" class="code" escape="true" mode="${(editorType[fileType])?has_content?then(editorType[fileType],'htmlmixed')}"><@tools.fileContent type='file' path=path>${object!}</@tools.fileContent></textarea>
            </div>
        </div>
    </div>
</form>
<script>
$('input[name=path]',navTab.getCurrentPanel()).on("keyup change",function(){
    if($(this).val() && -1 == $.inArray($(this).val().substring($(this).val().lastIndexOf(".")) , [<#list safeFileTypes as type>"${type}"<#sep>,</#list>])){
        $('.warning', navTab.getCurrentPanel()).show();
    }else{
        $('.warning', navTab.getCurrentPanel()).hide();
    }
});
</script>