<@cms.place id=id!copyId absoluteURL=false>
    <#assign a=object/>
</@cms.place>
<@tools.placeMetadata path=(a.path)!path!><#assign metadata=object/></@tools.placeMetadata>
<#if metadata?has_content>
<#if !a?has_content&&itemType?has_content>
<#switch itemType>
    <#case 'content'>
        <@cms.content id=itemId><#assign content=object/></@cms.content>
    <#break>
    <#case 'category'>
        <@cms.category id=itemId><#assign category=object/><#assign categoryDescription=getCategoryAttribute(category.id).description!/></@cms.category>
    <#break>
</#switch>
</#if>
<form method="post" autocomplete="off" action="cmsPlace/save?callbackType=closeCurrent&navTabId=cmsPlace/dataList" class="pageForm required-validate" onsubmit="return validateCallback(this,navTabAjaxDone);">
    <input name="id" type="hidden" value="${id!}"/>
    <input name="itemId" type="hidden" readonly="readonly" value="${(a.itemId)!itemId!}"/>
    <input name="path" type="hidden" value="${(a.path)!(path)!}"/>
    <input type="hidden" name="_csrf" value="<@tools.csrfToken admin=true/>"/>
    <div class="formBar card">
        <ul>
            <li><button type="submit" class="buttonActive" title="ctrl+s"<#if id?has_content> lock-url="common/lock?itemType=place&itemId=${id}" close-url="common/unlock?itemType=place&itemId=${id}"</#if>><@t.page 'button.save'/></button></li>
            <li><button type="button" class="button close"><@t.page 'button.close'/></button></li>
        </ul>
    </div>
    <div class="card">
        <div class="pageFormContent" layoutH>
            <#assign fieldList=metadata.fieldList![]/>
            <#assign requiredFieldList=metadata.requiredFieldList![]/>
            <dl class="nowrap">
                <dt>${(metadata.fieldTextMap['title'])!t.pageMessage('title')}:</dt>
                <dd>
                    <input class="required" name="title" type="text" maxlength="255" size="60" value="${(a.title)!(content.title)!(category.name)!}"/>
                    <#if (metadata.acceptItemTypes)?has_content>
                        <a class="btnLook" href="cmsPlace/lookup.html?acceptItemTypes=<#list metadata.acceptItemTypes as a>${a}<#sep>,</#list>" lookupGroup="" width="1200"  height="600"><@t.page 'select'/></a>
                        <input class="required" name="itemType" type="text" readonly="readonly" value="${(a.itemType)!itemType!}"/>
                    <#else>
                        <a class="btnLook" href="cmsPlace/lookup.html" lookupGroup="" width="1200" height="600"><@t.page 'select'/></a>
                        <input name="itemType" type="hidden" value="${(a.itemType)!itemType!}"/>
                    </#if>
                </dd>
            </dl>
        <#if fieldList?seq_contains('url')>
            <dl class="nowrap">
                <dt>${(metadata.fieldTextMap['url'])}:</dt>
                <dd><input name="url" type="text"<#if requiredFieldList?seq_contains('url')> class="required"</#if> maxlength="1000" size="60" value="${(a.url)!(content.url)!(category.url)!url!}"/></dd>
            </dl>
        </#if>
            <dl>
                <dt><@t.page 'publish_date'/>:</dt>
                <dd>
                    <input type="text" name="publishDate" class="date" size="20" dateFmt="yyyy-MM-dd HH:mm:ss" value="<#if a?has_content && id?has_content>${(a.publishDate)!}<#else>${(content.publishDate)!}</#if>"/>
                    <a class="inputDateButton" href="javascript:void(0);"></a>
                </dd>
            </dl>
            <dl>
                <dt><@t.page 'expiry_date'/>:</dt>
                <dd>
                    <input type="text" name="expiryDate" class="date" size="20" dateFmt="yyyy-MM-dd HH:mm:ss" value="${(a.expiryDate)!(content.expiryDate)!}"/>
                    <a class="inputDateButton" href="javascript:void(0);"></a>
                </dd>
            </dl>
        <#if fieldList?seq_contains('maxClicks')>
            <dl>
                <dt>${(metadata.fieldTextMap['maxClicks'])!}:</dt>
                <dd>
                    <input type="number" name="maxClicks" class="required digits" size="20" value="${(a.maxClicks)!0}"/>
                    <span class="info"><@t.page 'max_clicks.description'/><#if a?has_content>,<@t.page 'clicks'/>:${a.clicks!}</#if></span>
                </dd>
            </dl>
        </#if>
        <#if fieldList?seq_contains('description')>
            <dl class="nowrap">
                <dt>${(metadata.fieldTextMap['description'])!}:</dt>
                <dd>
                    <textarea name="description"<#if requiredFieldList?seq_contains('description')> class="required"</#if> maxlength="300" cols="80" rows="4">${(a.description)!(content.description)!(categoryDescription)!}</textarea>
                </dd>
            </dl>
        </#if>
        <#if fieldList?seq_contains('cover')>
            <dl class="nowrap">
                <dt>${(metadata.fieldTextMap['cover'])}:</dt>
                <dd>
                    <input name="cover" value="${(a.cover)!(content.cover)!}" class="preview<#if requiredFieldList?seq_contains('cover')> required</#if>" maxlength="300" size="50" type="text"/>
                    <a class="btnAttach" href="common/upload.html?field=cover&fileTypes=image&width=${(metadata.coverWidth)!}&height=${(metadata.coverHeight)!}" lookupGroup="" width="1000" height="600"><@t.page 'image'/></a>
                    <a class="view icon-eye-open" ref="cover" data-prefix="${getFileUploadPrefix()}" href="javascript:void(0);" target="_blank"><@t.page 'button.view'/></a>
                    <#if (metadata.coverWidth)?has_content && (metadata.coverHeight)?has_content><span class="info">${(metadata.coverWidth)!}*${(metadata.coverHeight)!}</span></#if>
                </dd>
            </dl>
        </#if>
            <#include "../include_page/extendData.html"/>
            <@tools.placeMetadata path=(a.path)!path!''><#assign metadata=object/></@tools.placeMetadata>
            <#assign attribute=getPlaceAttribute((a.id)!)/>
            <@extendData extendList=metadata.extendList extendValues=attribute historyItemType='placeExtend' historyItemId=id/>
        </div>
    </div>
</form>
</#if>