<%--
/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * The contents of this file are subject to the terms of the Liferay Enterprise
 * Subscription License ("License"). You may not use this file except in
 * compliance with the License. You can obtain a copy of the License by
 * contacting Liferay, Inc. See the License for the specific language governing
 * permissions and limitations under the License, including but not limited to
 * distribution rights of the Software.
 *
 *
 *
 */
--%>

<%@ include file="/init.jsp" %>

<%
String redirect = ParamUtil.getString(request, "redirect");

String backURL = ParamUtil.getString(request, "backURL", redirect);

LayoutsSEODisplayContext layoutsSEODisplayContext = (LayoutsSEODisplayContext)request.getAttribute(LayoutSEOWebKeys.LAYOUT_PAGE_LAYOUT_SEO_DISPLAY_CONTEXT);

if (Validator.isNull(backURL)) {
	backURL = PortalUtil.getLayoutFullURL(layoutsSEODisplayContext.getSelLayout(), themeDisplay);
}
%>

<aui:form action="<%= layoutsSEODisplayContext.getEditCustomMetaTagsURL() %>" method="post" name="fm">
	<aui:input name="redirect" type="hidden" value="<%= layoutsSEODisplayContext.getRedirectURL() %>" />
	<aui:input name="portletResource" type="hidden" value='<%= ParamUtil.getString(request, "portletResource") %>' />
	<aui:input name="groupId" type="hidden" value="<%= layoutsSEODisplayContext.getGroupId() %>" />
	<aui:input name="privateLayout" type="hidden" value="<%= layoutsSEODisplayContext.isPrivateLayout() %>" />
	<aui:input name="layoutId" type="hidden" value="<%= layoutsSEODisplayContext.getLayoutId() %>" />

	<clay:sheet>
		<clay:sheet-header>
			<h2 class="sheet-title"><liferay-ui:message key="custom-meta-tags" /></h2>

			<p class="text-muted">
				<liferay-ui:message key="custom-meta-tags-description" />
			</p>
		</clay:sheet-header>

		<liferay-ui:error exception="<%= DDMFormValuesValidationException.class %>" message="field-validation-failed" />

		<liferay-ui:error exception="<%= DDMFormValuesValidationException.RequiredValue.class %>">

			<%
			DDMFormValuesValidationException.RequiredValue rv = (DDMFormValuesValidationException.RequiredValue)errorException;

			String fieldLabelValue = rv.getFieldLabelValue(themeDisplay.getLocale());

			if (Validator.isNull(fieldLabelValue)) {
				fieldLabelValue = rv.getFieldName();
			}
			%>

			<liferay-ui:message arguments="<%= HtmlUtil.escape(fieldLabelValue) %>" key="no-value-is-defined-for-field-x" translateArguments="<%= false %>" />
		</liferay-ui:error>

		<liferay-ddm:html
			classNameId="<%= PortalUtil.getClassNameId(com.liferay.dynamic.data.mapping.model.DDMStructure.class) %>"
			classPK="<%= layoutsSEODisplayContext.getDDMStructurePrimaryKey() %>"
			ddmFormValues="<%= layoutsSEODisplayContext.getDDMFormValues() %>"
			defaultEditLocale="<%= PortalUtil.getSiteDefaultLocale(layoutsSEODisplayContext.getGroupId()) %>"
			defaultLocale="<%= PortalUtil.getSiteDefaultLocale(layoutsSEODisplayContext.getGroupId()) %>"
			fieldsNamespace="<%= String.valueOf(layoutsSEODisplayContext.getDDMStructurePrimaryKey()) %>"
			groupId="<%= layoutsSEODisplayContext.getGroupId() %>"
			requestedLocale="<%= locale %>"
		/>

		<clay:sheet-footer>
			<aui:button primary="<%= true %>" type="submit" />

			<clay:button
				displayType="secondary"
				label='<%= LanguageUtil.get(request, "cancel") %>'
				onClick='<%= "Liferay.Util.navigate('" + HtmlUtil.escape(backURL) + "')" %>'
				type="button"
			/>
		</clay:sheet-footer>
	</clay:sheet>
</aui:form>