<#assign editableSubfix=['css','js','html','shtml','htm','xml','txt','svg','md','text','json']/>
<div class="pageHeader card">
    <form class="pagerForm" autocomplete="off" onsubmit="return navTabSearch(this);" method="post">
        <input type="hidden" name="orderField" value="${orderField!}"/>
        <div class="searchBar">
            <ul class="searchContent">
                <li>
                    <label><@t.page 'path'/>:</label>
                    <label>${path?has_content?then(path+'/','')}</label>
                </li>
            </ul>
        </div>
    </form>
</div>
<div class="card">
    <div class="panelBar">
        <ul class="toolBar">
            <li><a href="cmsWebFile/content.html?path=${(path?url)!}" target="navTab" rel="cmsWebFile/content"><i class="icon-plus-sign-alt icon-large"></i><@t.page 'button.create_file'/></a></li>
            <li><a href="cmsWebFile/directory.html?path=${(path?url)!}" target="dialog" mask="true" width="500" height="200"><i class="icon-folder-close-alt icon-large"></i><@t.page 'button.create_directory'/></a></li>
            <li><a href="cmsWebFile/upload.html?path=${(path?url)!}" target="dialog" mask="true" width="500" height="350"><i class="icon-upload icon-large"></i><@t.page 'button.upload_file'/></a></li>
            <li><a href="cmsWebFile/uploadIco.html?path=${(path?url)!}" target="dialog" mask="true" width="1200" height="600"><i class="icon-upload icon-large"></i><@t.page 'button.generate_ico'/></a></li>
            <li><a href="cmsWebFile/zip?path=${path?has_content?then(path+'/','')}&_csrf=<@tools.csrfToken admin=true/>" title="<@t.page 'confirm.compress_directory'/>" target="ajaxTodo"><i class="icon-upload icon-large"></i><@t.page 'button.compress_current_directory'/></a></li>
            <li><a href="cmsWebFile/delete?_csrf=<@tools.csrfToken admin=true/>" title="<@t.page 'confirm.batch_delete_file'/>" target="selectedTodo" rel="paths"><i class="icon-trash icon-large"></i><@t.page 'button.batch_delete'/></a></li>
            <li><a href="cmsFileBackup/list.html?type=file&path=${(path?url)!}" target="navTab" rel="cmsFileBackup/list"><i class="bi bi-recycle"></i><@t.page 'recycle_bin'/></a></li>
        </ul>
    </div>
    <table class="table" width="100%" layoutH orderField="${orderField!}" orderType="${orderType!}">
        <thead>
            <tr>
                <th width="20"><input type="checkbox" group="paths" class="checkboxCtrl"></th>
                <th orderField="fileName"><@t.page 'name'/></th>
                <th orderField="modifiedDate"><@t.page 'modified_date'/></th>
                <th orderField="createDate"><@t.page 'create_date'/></th>
                <th orderField="fileSize"><@t.page 'file.size'/></th>
                <th><@t.page 'operate'/></th>
            </tr>
        </thead>
        <tbody>
    <@tools.fileList type='file' path=path orderField=orderField>
        <#if path?has_content>
            <tr>
                <td></td>
                <td>
                    <span class="bi bi-folder2-open"></span>
                    <a href="cmsWebFile/list.html?path=${path?contains('/')?then(path?keep_before_last('/'),'')?url}" data-change-title="false" target="navTab" rel="cmsWebFile/list">
                        <@t.page 'button.return'/>
                    </a>
                </td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
        </#if>
        <#list list as a>
            <#if !a.directory><@t.merge 'paths' path?has_content?then(path+'/','')+a.fileName/></#if>
        </#list>
        <@sys.lock userId=admin.id itemType='file' itemIds=t.paths><#assign lockMap=map!/></@sys.lock>
        <#if lockMap?has_content>
            <#list lockMap as k,lock>
                <#if lock.userId?has_content><@t.merge 'userIds' lock.userId/></#if>
            </#list>
        </#if>
        <@sys.user ids=t.userIds><#assign userMap=map!/></@sys.user>
        <#list list as a>
            <#assign filePath=path?has_content?then(path+'/','')+a.fileName/>
            <tr>
                <td><input name="paths" value="${filePath}" type="checkbox"></td>
                <td>
                    <#if a.directory>
                        <span class="bi bi-folder"></span>
                        <a href="cmsWebFile/list.html?path=${filePath?url}" data-change-title="false" target="navTab" rel="cmsWebFile/list">
                            ${a.fileName}
                        </a>
                    <#else>
                        <#if lockMap?has_content && lockMap[filePath]?has_content>
                            <#assign lockUser=(userMap[lockMap[filePath].userId?string].nickname)!''/>
                            <i class="icon-lock icon-large" title="<@t.page 'lock.message' lockUser/> ${lockMap[filePath].createDate}"></i>
                        </#if>
                        <span class="bi bi-file-text"></span> ${a.fileName}
                    </#if>
                </td>
                <td>${a.lastModifiedTime?datetime}</td>
                <td>${a.creationTime?datetime}</td>
                <td><@t.fileSize a.size/></td>
                <td class="wrap">
                    <#if a.directory>
                        <a href="cmsWebFile/zip?path=${filePath?url}&_csrf=<@tools.csrfToken admin=true/>" class="btnText blue" title="<@t.page 'confirm.compress_directory'/>" target="ajaxTodo"><@t.page 'button.compress'/></a>
                    <#else>
                        <#if a.fileName?ends_with('.zip')>
                            <a href="cmsWebFile/unzipParameters.html?path=${filePath?url}" class="btnText blue" target="dialog" mask="true" width="500" height="250"><@t.page 'button.decompress'/></a>
                        </#if>
                        <#if editableSubfix?seq_contains(a.fileName?keep_after_last('.')?lower_case)>
                          <a href="cmsWebFile/content.html?path=${filePath?url}" class="edit btnText blue" target="navTab" rel="cmsWebFile/content:${filePath}" title="${a.fileName}"><i class="icon-edit"></i><@t.page 'button.edit'/></a>
                        </#if>
                        <a href="${getUrl(filePath?url_path)}" class="btnText" target="_blank"><i class="icon-external-link"></i><@t.page 'button.view'/></a>
                    </#if>
                </td>
            </tr>
        </#list>
    </@tools.fileList>
        </tbody>
    </table>
</div>