<@tools.placeMetadata path=path><#assign a=object/></@tools.placeMetadata>
<@tools.fileExist path='/include'+(path!)><#assign exists=object&&path?has_content></@tools.fileExist>
<form method="post" autocomplete="off" action="cmsTemplate/savePlaceMetadata?navTabId=placeTemplate/list" 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="cmsTemplate/deletePlace?path=${(path?url)!}&navTabId=placeTemplate/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>
            <li><a class="button" href="cmsPlace/list.html?path=${(path?url)!}" target="navTab" rel="cmsPlace/list"><@t.page 'place.management'/></a></li>
            <li><a class="button" href="placeTemplate/content.html?path=${(path?url)!}" target="ajax" rel="cmsTemplatePlace"><@t.page 'template.content'/></a></li>
        </#if>
            <li><button type="submit" class="buttonActive" title="ctrl+s"<#if path?has_content> lock-url="common/lock?itemType=placeTemplate&itemId=${(path?url)!}" close-url="common/unlock?itemType=placeTemplate&itemId=${(path?url)!}"</#if>><@t.page 'button.save'/></button></li>
        </ul>
    </div>
    <div class="card">
        <div class="pageFormContent" layoutH>
            <dl class="nowrap">
                <dt><@t.page 'path'/>:</dt></dt>
                <dd>
                    <input name="path" type="text" value="${path!}${exists?then('','/'+getUUID()+'.html')}" size="40"/>
                    <span class="info"><@t.page 'template_path.description'/></span>
                </dd>
            </dl>
            <dl class="nowrap">
                <dt><@t.page 'alias'/>:</dt></dt>
                <dd>
                    <input class="required" name="alias" type="text" maxlength="50" size="20" value="${(a.alias)!}"/>
                    <span class="placeExtend">
                        <label>
                            <input name="allowContribute" type="checkbox"class="form-check-input"/>
                            <@t.page 'allow_contribute'/>
                        </label>
                        <label class="allowContribute hide">
                            <input name="allowAnonymous" type="checkbox"class="form-check-input"${((a.allowAnonymous)?has_content&&a.allowAnonymous)?then(' checked="checked"','')?no_esc}/>
                            <@t.page 'allow_anonymous_contribute'/>
                        </label>
                    </span>
                </dd>
            </dl>
            <dl class="nowrap">
                <dt><@t.page 'place_data.page_size'/>:</dt>
                <dd>
                    <input name="size" class="required digits" type="number" value="${(a.size)!0}"/>
                    <span class="info"><@t.page 'place_data.page_size.description'/></span>
                </dd>
            </dl>
            <dl class="nowrap placeExtend">
                <dt><@t.page 'item_type'/>:</dt>
                <dd>
                    <label><input name="acceptItemTypes" type="checkbox" class="form-check-input" value="content"<#if (a.acceptItemTypes)?has_content&&a.acceptItemTypes?seq_contains('content')> checked="checked"</#if>/><@t.page 'content'/></label>
                    <label><input name="acceptItemTypes" type="checkbox" class="form-check-input" value="page"<#if (a.acceptItemTypes)?has_content&&a.acceptItemTypes?seq_contains('page')> checked="checked"</#if>/><@t.page 'page'/></label>
                    <label><input name="acceptItemTypes" type="checkbox" class="form-check-input" value="category"<#if (a.acceptItemTypes)?has_content&&a.acceptItemTypes?seq_contains('category')> checked="checked"</#if>/><@t.page 'category'/></label>
                    <span class="info"><#noparse>${(place.itemType)!}:${(place.itemId)!}</#noparse></span>
                </dd>
            </dl>
            <dl class="nowrap placeExtend">
                <dt><@t.page 'place_data.master'/>:</dt>
                <dd>
                    <input name="userId" type="hidden"/>
                    <input name="nickname" type="hidden"/>
                    <label><a class="btnLook" href="sysUser/lookup.html" width="920" lookupGroup=""><@t.page 'user.select'/></a></label>
                    <div class="tagsBox adminIds"></div>
                </dd>
            </dl>
            <dl class="nowrap placeExtend">
                <dt><@t.page 'workflow.check'/>:</dt>
                <dd>
                    <input name="workflowId" type="hidden" value="${(a.workflowId)!}"/>
                    <input name="workflowName" type="text" value="<#if a?has_content><@sys.workflow id=a.workflowId;workflow>${workflow.name}</@sys.workflow></#if>"/>
                    <a class="btnLook" href="sysWorkflow/lookup.html" width="920" lookupGroup=""><@t.page 'select'/></a>
                </dd>
            </dl>
            <fieldset class="placeExtend systemField">
                <legend><@t.page 'place.system_field'/></legend>
                <dl>
                    <dt>
                        <label><@t.page 'field.title'/>:</label>
                    </dt>
                    <dd>
                        <input name="fieldTextMap[title]" class="required" type="text" maxlength="20" size="10" value="${(a.fieldTextMap['title'])!t.pageMessage('title')}"/>
                        <span class="info"><#noparse>${(place.title)!}</#noparse></span>
                    </dd>
                </dl>
                <dl>
                    <dt>
                        <label><input name="fieldList" type="checkbox" class="form-check-input" value="url"/><@t.page 'field.url'/></label>
                    </dt>
                    <dd>
                        <label><@t.page 'text'/>:</label>
                        <input name="fieldTextMap[url]" type="text" maxlength="20" size="10" value="${(a.fieldTextMap['url'])!t.pageMessage('url')}"/>
                        <label><input name="requiredFieldList" type="checkbox" class="form-check-input" value="url"/><@t.page 'required'/></label>
                        <span class="info"><#noparse>${(place.url)!}</#noparse></span>
                    </dd>
                </dl>
                <dl>
                    <dt>
                        <label><input name="fieldList" type="checkbox" class="form-check-input" value="description"/><@t.page 'description'/></label>
                    </dt>
                    <dd>
                        <label><@t.page 'text'/>:</label>
                        <input name="fieldTextMap[description]" type="text" maxlength="20" size="10" value="${(a.fieldTextMap['description'])!t.pageMessage('description')}"/>
                        <label><input name="requiredFieldList" type="checkbox" class="form-check-input" value="description"/><@t.page 'required'/></label>
                        <span class="info"><#noparse>&lt;#list (place.description!'')?split("\n") as a&gt;${a}&lt;#sep&gt;&lt;br/&gt;&lt;/#list&gt;</#noparse></span>
                    </dd>
                </dl>
                <dl>
                    <dt>
                        <label><input name="fieldList" type="checkbox" class="form-check-input" value="maxClicks"/><@t.page 'max_clicks'/></label>
                    </dt>
                    <dd>
                        <label><@t.page 'max_clicks'/>:</label>
                        <input name="fieldTextMap[maxClicks]" type="text" maxlength="20" size="10" value="${(a.fieldTextMap['maxClicks'])!t.pageMessage('max_clicks')}"/>
                        <span class="info"><#noparse>${(place.maxClicks)!}</#noparse></span>
                    </dd>
                </dl>
                <dl class="nowrap">
                    <dt>
                        <label><input name="fieldList" type="checkbox" class="form-check-input" value="cover"/><@t.page 'cover'/></label>
                    </dt>
                    <dd>
                        <label><@t.page 'text'/>:</label>
                        <input name="fieldTextMap[cover]" type="text" maxlength="20" size="10" value="${(a.fieldTextMap['cover'])!t.pageMessage('cover')}"/>
                        <label><input name="requiredFieldList" type="checkbox" class="form-check-input" value="cover"/><@t.page 'required'/></label>
                        <label><@t.page 'width'/></label><input name="coverWidth" type="number" size="5" value="${(a.coverWidth)!}"/>
                        <label><@t.page 'height'/></label><input name="coverHeight" type="number" size="5" value="${(a.coverHeight)!}"/>
                        <span class="info"><#noparse>&lt;img src="${(place.cover)!}" alt="${(place.title)!}"/&gt;</#noparse></span>
                    </dd>
                </dl>
            </fieldset>
            <fieldset class="placeExtend">
                <legend><@t.page 'place_data.extend_field'/></legend>
                <span class="info"><@t.page 'extend_field.use.place'/>;<@t.page 'metadata.default_value_description'/></span>
                <#include '../include_page/extends.html'/>
                <#assign extendList=(a.extendList)![]/>
                <@extends 'extendList' extendList/>
                <span class="info"><@t.page 'extend_field.name.description'/></span>
            </fieldset>
            <fieldset>
                <legend><@t.page 'metadata.extend_field'/></legend>
                <span class="info"><@t.page 'extend_field.use.metadata'/>;<@t.page 'metadata.default_value_description'/></span>
                <#assign metadataExtendList=(a.metadataExtendList)![]/>
                <@extends 'metadataExtendList' metadataExtendList/>
            </fieldset>
    <script>
    $('input[name=allowContribute]',navTab.getCurrentPanel()).on("click", function(){
        if($(this).is(':checked')) {
            $('.allowContribute',navTab.getCurrentPanel()).show();
        } else {
            $('.allowContribute',navTab.getCurrentPanel()).hide();
        }
    });
    $('.systemField dt [type=checkbox]',navTab.getCurrentPanel()).each(function(){
        var box = $(this).parent().parent().parent();
        box.find('dd').hide();
        $(this).on("click", function(){
            if( $(this).is(':checked') ) {
                box.find('dd').show().find('input[type=text]').addClass('required');
            } else {
                box.find('dd').hide().find('input[type=text]').removeClass('required').val('');
            }
        });
    });
    <#if a?has_content&&a.allowContribute>
        $('input[name=allowContribute]',navTab.getCurrentPanel()).trigger("click");
    </#if>
    <#if (a.fieldList)?has_content>
    <#list a.fieldList as field>
        $('input[name=fieldList][value=${field}]',navTab.getCurrentPanel()).trigger("click");
    </#list>
    </#if>
    <#if (a.requiredFieldList)?has_content>
    <#list a.requiredFieldList as field>
        $('input[name=requiredFieldList][value=${field}]',navTab.getCurrentPanel()).trigger("click");
    </#list>
    </#if>
    $('input[name=size]',navTab.getCurrentPanel()).on('change',function(){
        checkPageSize();
    });
    $('input[name=nickname]',navTab.getCurrentPanel()).on('change',function(){
        addUser($('input[name=\'userId\']',navTab.getCurrentPanel()).val(),$(this).val());
    });
    $('.adminIds',navTab.getCurrentPanel()).on('click','span>a',function(){
        $(this).parent().remove();
        return false;
    });
    checkPageSize();
    <#if (a.adminIds)?has_content>
        <@sys.user ids=a.adminIds>
            <#list map as k,user>
            addUser('${k}','${user.nickname}');
            </#list>
        </@sys.user>
    </#if>
    </script>
            <textarea name="content" class="hide" escape="true"></textarea>
            <textarea class="placeContent hide"><#if exists && ((a.size)!0) gt 0><@tools.fileContent path='/include'+path>${(object)!}</@tools.fileContent><#else><#noparse>
<#list page.list>
    <ul data-diy="place" data-diy-id="${path}">
    <#items as place>
        <li data-diy-item="${place.id}">
            <figure>
                <#-- data type: ${place.itemType!},data id: ${place.itemId!},place/redirect:count and jump to place.url,found[true:302,false:301,default:false] -->
                <a href="${site.dynamicPath}place/redirect?id=${place.id!}&found=false" target="_blank"><img src="${place.cover!}"></a>
                <figcaption><a href="${place.url!}" target="_blank">${place.title!}</a>(${place.clicks!})</figcaption>
                <p><#list (place.description!'')?split('\n') as line>${line}<#sep><br/></#list></p>
                </#noparse><@t.page 'extend_field'/>:${(place.attribute.your_extend_code)!}<#noparse>
            </figure>
        </li>
    </#items>
    </ul>
</#list>
</#noparse></#if></textarea>
    <textarea class="content hide"><#if exists && ((a.size)!0)=0><@tools.fileContent path='/include'+path>${(object)!}</@tools.fileContent><#else><#noparse>
<div data-diy="place" data-diy-id="${path}">

</div>
</#noparse></#if></textarea>
        </div>
    </div>
</form>