<#include "extend/dictionaryElement.html"/>
<#macro input extend value="" type="form" itemType="" itemId="">
    <#local inputName='extendData['+extend.id.code+']'/>
    <#local datetimes=['now','thisSunday','thisMonday','lastMonday','lastSunday','nextMonday','nextSunday']/>
    <#assign values={}/>
    <#switch extend.inputType>
        <#case 'input'>
        <#case 'number'>
        <#case 'user'>
        <#case 'dept'>
        <#case 'content'>
        <#case 'category'>
        <#case 'categoryType'>
        <#case 'tagType'>
        <#case 'tag'>
        <#case 'vote'>
        <#case 'survey'>
        <#case 'dictionary'>
        <#case 'keyvalue'>
        <#case 'keywords'>
        <#case 'sensitivewords'>
            <#include "extend/"+extend.inputType+".html"/>
            <#break>
        <#case 'editor'>
        <#case 'tinymce'>
        <#case 'ckeditor'>
            <#include "extend/editor.html"/>
            <#break>
        <#case 'file'>
            <#if 'view'=type>
                <a href="${getUrl(value?url_path)!}" target="_blank">${(value)!}</a>
            <#else>
        <input name="${inputName}" type="text" maxlength="300" size="50"<#if 'customform'=type><#if extend.required> required="required"</#if><#else><#if extend.required> class="required"</#if></#if> value="<#if 'customform'=type>${r'${(attribute.'+extend.id.code+r')!}'}<#else>${(value)!}</#if>"/>
                <#if 'customform'=type>
                <input type="file" target="${inputName}"/>
                <#else>
                    <a class="btnAttach" href="common/upload.html?field=${inputName?url}" lookupGroup="" width="1000" height="600"><@t.page 'attach'/></a>
                    <a class="view icon-eye-open" ref="${inputName}" data-prefix="${getFileUploadPrefix()}" href="javascript:void(0);" target="_blank"><@t.page 'button.view'/></a>
                </#if>
            </#if>
            <#break>
        <#case 'privatefile'>
            <#if 'view'=type>
                <a href="${getPrivateUrl(value?url_path)!}" target="_blank">${(value)!}</a>
            <#else>
        <input name="${inputName}" type="text" maxlength="300" size="50"<#if 'customform'=type><#if extend.required> required="required"</#if><#else><#if extend.required> class="required"</#if></#if> value="<#if 'customform'=type>${r'${(attribute.'+extend.id.code+r')!}'}<#else>${(value)!}</#if>"/>
                <#if 'customform'=type>
                    <input type="file" target="${inputName}" data-private="true"/>
                <#else>
                    <a class="btnAttach" href="common/upload.html?field=${inputName?url}&privatefile=true" lookupGroup="" width="1000" height="600"><@t.page 'attach'/></a>
                </#if>
            </#if>
            <#break>
        <#case 'image'>
            <#if 'view'=type>
                <img src="${getUrl(value?url_path)!}" alt="image" style="max-width:200px;max-height:200px;"/>
                <br/>
                ${(value)!}
            <#else>
        <input name="${inputName}" type="text" maxlength="300" size="50"<#if 'customform'=type><#if extend.required> required="required"</#if><#else> class="preview<#if extend.required> required</#if>"</#if> value="<#if 'customform'=type>${r'${(attribute.'+extend.id.code+r')!}'}<#else>${(value)!}</#if>"/>
                <#if 'customform'=type>
                    <input type="file" target="${inputName}"/>
                <#else>
                    <a class="btnAttach" href="common/upload.html?field=${inputName?url}&fileTypes=image&width=${extend.width!}&height=${extend.height!}" lookupGroup="" width="1000" height="600"><@t.page 'image'/></a>
                    <a class="view icon-eye-open" ref="${inputName}" data-prefix="${getFileUploadPrefix()}" href="javascript:void(0);" target="_blank"><@t.page 'button.view'/></a>
                    <#if (extend.width)?has_content && (extend.height)?has_content><span class="info">${extend.width!}*${extend.height!}</span></#if>
                </#if>
            </#if>
            <#break>
        <#case 'privateimage'>
            <#if 'view'=type>
                <img src="${getPrivateUrl(value?url_path)!}" alt="image" style="max-width:200px;max-height:200px;"/>
                <br/>
                ${(value)!}
            <#else>
        <input name="${inputName}" type="text" maxlength="300" size="50"<#if 'customform'=type><#if extend.required> required="required"</#if><#else><#if extend.required> class="required"</#if></#if> value="<#if 'customform'=type>${r'${(attribute.'+extend.id.code+r')!}'}<#else>${(value)!}</#if>"/>
                <#if 'customform'=type>
                    <input type="file" target="${inputName}" data-private="true"/>
                <#else>
                    <a class="btnAttach" href="common/upload.html?field=${inputName?url}&fileTypes=image&width=${extend.width!}&height=${extend.height!}&privatefile=true" lookupGroup="" width="1000" height="600"><@t.page 'image'/></a>
                    <#if (extend.width)?has_content && (extend.height)?has_content><span class="info">${extend.width!}*${extend.height!}</span></#if>
                </#if>
            </#if>
            <#break>
        <#case 'video'>
            <#if 'view'=type>
                <video controls="controls" src="${getUrl(value?url_path)!}" style="max-width:500px;max-height:500px;"></video>
                <br/>
                ${(value)!}
            <#else>
        <input name="${inputName}" type="text" maxlength="300" size="50"<#if 'customform'=type><#if extend.required> required="required"</#if><#else><#if extend.required> class="required"</#if></#if> value="<#if 'customform'=type>${r'${(attribute.'+extend.id.code+r')!}'}<#else>${(value)!}</#if>"/>
                <#if 'customform'=type>
                    <input type="file" target="${inputName}"/>
                <#else>
                    <a class="btnAttach" href="common/upload.html?field=${inputName?url}&fileTypes=video" lookupGroup="" width="1000" height="600"><@t.page 'video'/></a>
                    <a class="view icon-eye-open" ref="${inputName}" data-prefix="${getFileUploadPrefix()}" href="javascript:void(0);" target="_blank"><@t.page 'button.view'/></a>
                </#if>
            </#if>
            <#break>
        <#case 'privatevideo'>
            <#if 'view'=type>
                <video controls="controls" src="${getPrivateUrl(value?url_path)!}" style="max-width:500px;max-height:500px;"></video>
                <br/>
                ${(value)!}
            <#else>
        <input name="${inputName}" type="text" maxlength="300" size="50"<#if 'customform'=type><#if extend.required> required="required"</#if><#else><#if extend.required> class="required"</#if></#if> value="<#if 'customform'=type>${r'${(attribute.'+extend.id.code+r')!}'}<#else>${(value)!}</#if>"/>
                <#if 'customform'=type>
                    <input type="file" target="${inputName}" data-private="true"/>
                <#else>
                    <a class="btnAttach" href="common/upload.html?field=${inputName?url}&fileTypes=video&privatefile=true" lookupGroup="" width="1000" height="600"><@t.page 'video'/></a>
                </#if>
            </#if>
            <#break>
        <#case 'password'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
        <input name="${inputName}" type="password"<#if extend.maxlength?has_content> size="${extend.maxlength}" maxlength="${extend.maxlength}"<#else> size="30"</#if><#if 'customform'=type><#if extend.required> required="required"</#if><#else><#if extend.required> class="required"</#if></#if> value="<#if 'customform'=type>${r'${(attribute.'+extend.id.code+r')!}'}<#else>${(value)!}</#if>"/>
            </#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><#if extend.required> required="required"</#if><#else><#if extend.required> class="required"</#if></#if> cols="80" rows="4"><#if 'customform'=type>${r'${(attribute.'+extend.id.code+r')!}'}<#else>${(value)!}</#if></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="50" class="<#if extend.required> required</#if>" value="${(value)!}"/>
                <a class="btnLook" href="cmsTemplate/lookup.html?field=${inputName?url}" lookupGroup=""><@t.page 'template.select'/></a>
            </#if>
            <#break>
        <#case 'templateDirectory'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
                <input name="${inputName}"<#if extend.maxlength?has_content> maxlength="${extend.maxlength}"</#if> type="text" maxlength="255" size="50" class="<#if extend.required> required</#if>" value="${(value)!}"/>
                <a class="btnLook" href="cmsTemplate/directoryLookup.html?field=${inputName?url}" lookupGroup=""><@t.page 'template.directory.select'/></a>
            </#if>
            <#break>
        <#case 'fileDirectory'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
                <input name="${inputName}"<#if extend.maxlength?has_content> maxlength="${extend.maxlength}"</#if> type="text" maxlength="255" size="50" class="<#if extend.required> required</#if>" value="${(value)!}"/>
                <a class="btnLook" href="cmsWebFile/directoryLookup.html?field=${inputName?url}" lookupGroup=""><@t.page 'webfile.directory.select'/></a>
            </#if>
            <#break>
        <#case 'boolean'>
            <#if 'view'=type>
                <#if value?has_content>${t.pageMessage(('true'=value)?then('yes','no'))}</#if>
            <#else>
        <select<#if 'customform'!=type> class="combox<#if extend.required> required</#if>"</#if> name="${inputName}">
            <option value><@t.page 'please_select'/></option>
            <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 '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" type="text"<#else> type="datetime-local"</#if> size="20" value="<#if value?has_content && datetimes?seq_contains(value)><#if 'customform'=type>${r'${getDate(attribute.'+extend.id.code+r')?datetime}'}<#else>${getDate(value)?datetime}</#if><#else>${(value)!}</#if>"/>
                <#if 'customform'!=type><a class="inputDateButton" href="javascript:void(0);"></a></#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" type="text"<#else> type="date"</#if> size="10" value="<#if value?has_content && datetimes?seq_contains(value)><#if 'customform'=type>${r'${getDate(attribute.'+extend.id.code+r')?date}'}<#else>${getDate(value)?date}</#if><#else>${(value)!}</#if>"/>
                <#if 'customform'!=type><a class="inputDateButton" href="javascript:void(0);"></a></#if>
            </#if>
            <#break>
        <#case 'time'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
        <input name="${inputName}" <#if 'customform'!=type>class="date<#if extend.required> required</#if>" autocomplete="off" dateFmt="HH:mm:ss" type="text"<#else> type="time"</#if> size="10" value="<#if value?has_content && 'now'=value><#if 'customform'=type><#noparse>${.now?time}</#noparse><#else>${.now?time}</#if><#else>${(value)!}</#if>"/>
                <#if 'customform'!=type><a class="inputDateButton" href="javascript:void(0);"></a></#if>
            </#if>
            <#break>
        <#case 'color'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
        <input name="${inputName}" <#if 'customform'!=type>class="color<#if extend.required> required</#if>" autocomplete="off" type="text"<#else> type="color"</#if> size="20" value="<#if 'customform'=type>${r'${(attribute.'+extend.id.code+r')!}'}<#else>${(value)!}</#if>"/>
            </#if>
            <#break>
        <#case 'alphaColor'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
        <input name="${inputName}" <#if 'customform'!=type>class="color<#if extend.required> required</#if>" autocomplete="off" showAlpha="true" </#if>type="text" size="20" value="<#if 'customform'=type>${r'${(attribute.'+extend.id.code+r')!}'}<#else>${(value)!}</#if>"/>
            </#if>
            <#break>
        <#case 'categoryPath'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
                <input name="${inputName}" type="text" <#if extend.required> class="required"</#if> autocomplete="on" maxlength="500" size="100" value="${(value)!}"/>
                <a class="btnLook" href="cmsCategory/categoryPath.html?field=${inputName?url}" lookupGroup="" width="920"><@t.page 'select_path'/></a>
            </#if>
            <#break>
        <#case 'module'>
            <#if value?has_content>
                <#local values=value?split(',')/>
            </#if>
            <#if 'view'=type>
                <#if values?has_content>
                    <#list values as a><@t.menu a/><#sep>,</#list>
                </#if>
            <#else>
                <#list ["comment_list","tag_list","vote_list","survey_list","trade","page_diy","page_preview","myself_device","app_client_list"] as a>
                    <label><input name="${inputName}" type="checkbox" value="${a}" class="form-check-input"${(values?has_content&&values?seq_contains(a))?then(' checked="true"','')?no_esc}/><@t.menu a/></label>
                </#list>
            </#if>
            <#break>
        <#case 'lang'>
            <#if value?has_content>
                <#local values=value?split(',')/>
            </#if>
            <#if 'view'=type>
                <#if values?has_content>
                    <#list values as a>${langs[a]}<#sep>,</#list>
                </#if>
            <#else>
                <#list langs as k,v>
                    <label><input name="${inputName}" type="checkbox" class="form-check-input" value="${k}"${(values?has_content&&values?seq_contains(k))?then(' checked="true"','')?no_esc}/>${v}</label>
                </#list>
            </#if>
            <#break>
        <#case 'captcha'>
            <#if value?has_content>
                <#local values=value?split(',')/>
            </#if>
            <#if 'view'=type>
                <#if values?has_content>
                    <#list values as a><@t.page a/><#sep>,</#list>
                </#if>
            <#else>
                <#list ["register","login","management_system","comment","contribute","upload","survey"] as a>
                    <label><input name="${inputName}" type="checkbox" class="form-check-input" value="${a}"${(values?has_content&&values?seq_contains(a))?then(' checked="true"','')?no_esc}/><@t.page a/></label>
                </#list>
            </#if>
            <#break>
        <#case 'contentStatus'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
                <select class="combox<#if extend.required> required</#if>" name="${inputName}">
                    <#list 0..2 as s>
                        <option value="${s}"${(value?has_content&&s?string=value)?then(' selected="true"','')?no_esc}><@t.page 'status.content.'+s/></option>
                    </#list>
                </select>
            </#if>
            <#break>
        <#case 'font'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
                <select class="combox<#if extend.required> required</#if>" name="${inputName}">
                    <#list getFontList() as font>
                    <option value="${font}"${(value?has_content&&font=value)?then(' selected="true"','')?no_esc}>${font}</option>
                    </#list>
                </select>
            </#if>
            <#break>
        <#case 'position'>
            <#if 'view'=type>
                ${(value)!}
            <#else>
                <select class="combox<#if extend.required> required</#if>" name="${inputName}">
                    <#list ["rightBottom","center","leftTop","leftBottom","rightTop"] as s>
                    <option value="${s}"${(value?has_content&&s=value)?then(' selected="true"','')?no_esc}><@t.page 'position.'+s/></option>
                    </#list>
                </select>
            </#if>
            <#break>
        <#default>
            <#include "extend/text.html"/>
    </#switch>
</#macro>
<#macro extendData extendList=[] extendValues={} historyItemType='' historyItemId='' type='form' htmlSafe=false>
    <#list extendList as e>
    <#local value=extendValues[e.id.code]!e.defaultValue!''/>
        <#if 'customform'=type>
    <div>
        <label>${(e.name)}:</label>
        <@input e value type/>
    </div>
        <#else>
    <dl <#if !['number','alphaColor','color','date','datetime','boolean','text','password']?seq_contains(e.inputType)||e.description?has_content||e.multiple||e?is_first>class="nowrap"</#if>>
        <dt>${(e.name)}:</dt>
        <dd<#if 'editor'=e.inputType> style="width:90%;"</#if>>
            <@input e value type historyItemType historyItemId/>
            <#if e.description?has_content><span class="info">${htmlSafe?then(e.description?no_esc,e.description)}</span></#if>
        </dd>
    </dl>
        </#if>
    </#list>
</#macro>