<#macro input name extend index value='' type='form' safe=true>
    <#local inputName=name+'['+index+'].value'/>
    <input name="${name}[${index}].name" type="hidden" value="${extend.id.code}"/>
    <#switch extend.inputType>
        <#case 'number'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
            <input name="${inputName}" <#if 'customform'!=type>class="number<#if extend.required> required</#if>" </#if>type="number"<#if extend.maxlength?has_content> maxlength="${extend.maxlength}"</#if> value="${(value)!}"/>
            </#if>
            <#break>
        <#case 'file'>
            <#if 'view'=type>
                <a href="${site.sitePath+value}" target="_blank">${(value)!}</a>
            <#else>
                <input name="${inputName}" <#if 'customform'!=type>class="<#if extend.required>required</#if>" type="text" <#else>type="file" </#if>value="${(value)!}"/>
                <#if 'customform'!=type><a class="btnAttach" href="common/upload.html?field=${inputName?url}" lookupGroup="" width="1000" height="600"><@t.page 'attach'/></a></#if>
            </#if>
            <#break>
        <#case 'image'>
            <#if 'view'=type>
                <img src="${site.sitePath+value}" style="max-width:200px;max-height:200px;"/>
                <br/>
                ${(value)!}
            <#else>
                <input name="${inputName}" <#if 'customform'!=type>class="<#if extend.required>required</#if>" type="text" <#else>type="file" accept="image/*" </#if>value="${(value)!}"/>
                <#if 'customform'!=type>
                    <a class="btnAttach" href="common/upload.html?field=${inputName?url}&fileTypes=image" lookupGroup="" width="1000" height="600"><@t.page 'image'/></a>
                    <#if !preview?has_content>
                        <#include "../include_page/preview.html"/>
                    </#if>
                    <@preview extend.id.code 'input[name="${inputName}"]' ''/>
                </#if>
            </#if>
            <#break>
        <#case 'video'>
            <#if 'view'=type>
                <video controls="controls" src="${site.sitePath+value}" style="max-width:500px;max-height:500px;"></video>
                <br/>
                ${(value)!}
            <#else>
                <input name="${inputName}" <#if 'customform'!=type>class="<#if extend.required>required</#if>" type="text" <#else>type="file" accept="video/*"</#if>value="${(value)!}"/>
                <#if 'customform'!=type>
                    <a class="btnAttach" href="common/upload.html?field=${inputName?url}&fileTypes=video" lookupGroup="" width="1000" height="600"><@t.page 'video'/></a>
                </#if>
            </#if>
            <#break>
        <#case 'password'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
                <input name="${inputName}"<#if extend.maxlength?has_content> size="${extend.maxlength}" maxlength="${extend.maxlength}"<#else> size="30"</#if> <#if 'customform'!=type>class="<#if extend.required> required</#if>" </#if>type="password" value="${(value)!}"/>
            </#if>
            <#break>
        <#case 'textarea'>
            <#if 'view'=type>
                <pre>${(value)!}</pre>
            <#else>
                <textarea name="${inputName}"<#if extend.maxlength?has_content> maxlength="${extend.maxlength}"</#if> <#if 'customform'!=type>class="<#if extend.required>required</#if>" </#if>cols="80" rows="4">${(value)!}</textarea>
            </#if>
            <#break>
        <#case 'editor'>
            <#if 'view'=type>
                <#if safe>${(value?no_esc)!}<#else>${value!}</#if>
            <#else>
                <textarea name="${inputName}"<#if extend.maxlength?has_content> maxlength="${extend.maxlength}"</#if> <#if 'customform'!=type>class="editor<#if extend.required> required</#if>" </#if>cols="80" rows="20">${(value)!}</textarea>
            </#if>
            <#break>
        <#case 'ckeditor'>
            <#if 'view'=type>
                <#if safe>${(value?no_esc)!}<#else>${value!}</#if>
            <#else>
                <textarea name="${inputName}"<#if extend.maxlength?has_content> maxlength="${extend.maxlength}"</#if> <#if 'customform'!=type>class="editor<#if extend.required> required</#if>" editorType="ckeditor" </#if>cols="80" rows="20">${(value)!}</textarea>
            </#if>
            <#break>
        <#case 'kindeditor'>
            <#if 'view'=type>
                <#if safe>${(value?no_esc)!}<#else>${value!}</#if>
            <#else>
                <textarea name="${inputName}"<#if extend.maxlength?has_content> maxlength="${extend.maxlength}"</#if> <#if 'customform'!=type>class="editor<#if extend.required> required</#if>" editorType="kindeditor" </#if>cols="80" rows="20">${(value)!}</textarea>
            </#if>
            <#break>
        <#case 'template'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
                <input name="${inputName}"<#if extend.maxlength?has_content> maxlength="${extend.maxlength}"</#if> type="text" maxlength="255" size="40" value="${(value)!}"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="cmsTemplate/lookup.html?field=${inputName?url}" lookupGroup=""><@t.page 'template.select'/></a>
            </#if>
            <#break>
        <#case 'boolean'>
            <#if 'view'=type>
                <#if value?has_content>${('true'=value)?then(t.pageMessage('yes'),t.pageMessage('no'))}</#if>
            <#else>
                <select class="combox" name="${inputName}"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>>
                    <option value="true"${(value?has_content&&'true'=value)?then(' selected="true"','')?no_esc}><@t.page 'yes'/></option>
                    <option value="false"${(!value?has_content||'false'=value)?then(' selected="true"','')?no_esc}><@t.page 'no'/></option>
                </select>
            </#if>
            <#break>
        <#case 'user'>
            <@_sysUser id=value><#local u=object/></@_sysUser>
            <#if 'view'=type>
                ${(value)!}:${(u.nickName)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].nickName" readonly="readonly" size="30" value="${(u.nickName)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="sysUser/lookup.html?field=value" width="920" lookupGroup="${name}[${index}]"><@t.page 'user.select'/></a>
            </#if>
            <#break>
        <#case 'content'>
            <@_content id=value><#local content=object/></@_content>
            <#if 'view'=type>
                ${(value)!}:${(content.title)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].title" readonly="readonly" size="30" value="${(content.title)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="cmsContent/lookup.html?field=value" lookupGroup="${name}[${index}]" width="1000" height="500"><@t.page 'content.select'/></a>
            </#if>
            <#break>
        <#case 'category'>
            <@_category id=value><#local category=object/></@_category>
            <#if 'view'=type>
                ${(value)!}:${(category.name)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].categoryName" readonly="readonly" size="30" value="${(category.name)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="cmsCategory/lookup.html?field=value" lookupGroup="${name}[${index}]" width="1000" height="500"><@t.page 'category.select'/></a>
            </#if>
            <#break>
        <#case 'categoryType'>
            <@_categoryType id=value><#local categoryType=object/></@_categoryType>
            <#if 'view'=type>
                ${(value)!}:${(categoryType.name)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].categoryTypeName" readonly="readonly" size="30" value="${(categoryType.name)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="cmsCategoryType/lookup.html?field=value" lookupGroup="${name}[${index}]" width="1000" height="500"><@t.page 'select'/></a>
            </#if>
            <#break>
        <#case 'tagType'>
            <@_tagType id=value><#local tagType=object/></@_tagType>
            <#if 'view'=type>
                ${(value)!}:${(tagType.name)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].tagTypeName" readonly="readonly" size="30" value="${(tagType.name)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="cmsTagType/lookup.html?field=value" lookupGroup="${name}[${index}]" width="1000" height="500"><@t.page 'select'/></a>
            </#if>
            <#break>
        <#case 'tag'>
            <@_tag id=value><#local tag=object/></@_tag>
            <#if 'view'=type>
                ${(value)!}:${(tag.name)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].tagName" readonly="readonly" size="30" value="${(tag.name)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="cmsTag/lookup.html?field=value" lookupGroup="${name}[${index}]" width="1000" height="500"><@t.page 'select'/></a>
            </#if>
            <#break>
        <#case 'vote'>
            <@_vote id=value><#local vote=object/></@_vote>
            <#if 'view'=type>
                ${(value)!}:${(vote.title)!}
            <#else>
                <input name="${inputName}" value="${(value)!}" type="hidden"/>
                <input name="${name}[${index}].voteName" readonly="readonly" size="30" value="${(vote.title)!}" type="text"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>/>
                <a class="btnLook" href="cmsVote/lookup.html?field=value" lookupGroup="${name}[${index}]" width="1000" height="500"><@t.page 'select'/></a>
            </#if>
            <#break>
        <#case 'dictionary'>
            <@_dictionary id=extend.dictionaryId><#local dictionary=object/></@_dictionary>
            <#if site.parentId?has_content&&!dictionary?has_content><@_dictionary id=extend.dictionaryId siteId=site.parentId><#assign dictionary=object/></@_dictionary></#if>
            <#if dictionary?has_content>
                <#if 'view'=type>
                    <#if dictionary.multiple><@_dictionaryData dictionaryId=extend.dictionaryId values=value><#list map as k,data>${data.text}<#sep>,</#list></@_dictionaryData><#else><@_dictionaryData dictionaryId=extend.dictionaryId value=value>${object.text}</@_dictionaryData></#if>
                <#else>
                    <#if dictionary.multiple>
                        <#if value?has_content>
                            <#local values=value?split(',')/>
                        </#if>
                        <@_dictionaryDataList dictionaryId=extend.dictionaryId>
                            <#list list as d>
                                <label>
                                    <input name="${name}[${index}].values" type="checkbox" value="${d.id.value}"${(values?has_content&&values?seq_contains(d.id.value))?then(' checked="true"','')?no_esc}/>
                                    ${d.text}
                                </label>
                            </#list>
                        </@_dictionaryDataList>
                    <#else>
                        <select class="combox" name="${inputName}"<#if 'customform'!=type> class="<#if extend.required> required</#if>"</#if>>
                        <@_dictionaryDataList dictionaryId=extend.dictionaryId>
                            <#list list as d>
                            <option value="${d.id.value}"${(value?has_content&&d.id.value=value)?then(' selected="true"','')?no_esc}>${d.text}</option>
                            </#list>
                        </@_dictionaryDataList>
                        </select>
                    </#if>
                </#if>
            </#if>
            <#break>
        <#case 'date'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
                <input name="${inputName}" <#if 'customform'!=type>class="date<#if extend.required> required</#if>" autocomplete="off" dateFmt="yyyy-MM-dd" </#if>type="text" size="10" value="${(value)!}"/>
            </#if>
            <#break>
        <#case 'datetime'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
                <input name="${inputName}" <#if 'customform'!=type>class="date<#if extend.required> required</#if>" autocomplete="off" dateFmt="yyyy-MM-dd HH:mm:ss" </#if>type="text" size="20" value="${(value)!}"/>
            </#if>
            <#break>
        <#default>
            <#if 'view'=type>
                ${(value)!}
            <#else>
                <input name="${inputName}"<#if extend.maxlength?has_content> size="${extend.maxlength}" maxlength="${extend.maxlength}"<#else> size="50"</#if> <#if 'customform'!=type>class="<#if extend.required> required</#if>" </#if>type="text" value="${(value)!}"/>
            </#if>
    </#switch>
</#macro>
<#macro extendData name extendList extendValues type='form' fromIndex=0 htmlSafe=false>
    <#list extendList as e>
    <#local value=extendValues[e.id.code]!e.defaultValue!''/>
        <#if 'customform'=type>
    <p><label>${(e.name)}:</label><@input name e e?index+fromIndex value type/></p>
        <#else>
    <dl class="nowrap">
        <dt>${(e.name)}:</dt>
        <dd<#if 'editor'=e.inputType> style="width:90%;"</#if>>
            <@input name e e?index+fromIndex value type/>
            <span class="info">${(htmlSafe?then(e.description?no_esc,e.description))!}</span>
        </dd>
    </dl>
        </#if>
    </#list>
</#macro>