<%--
/**
 * 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="/asset_metadata/init.jsp" %>

<%
AssetEntry assetEntry = (AssetEntry)request.getAttribute("liferay-asset:asset-metadata:assetEntry");
String[] metadataFields = (String[])request.getAttribute("liferay-asset:asset-metadata:metadataFields");
%>

<liferay-util:html-top>
	<link href="<%= PortalUtil.getStaticResourceURL(request, PortalUtil.getPathProxy() + application.getContextPath() + "/css/main.css") %>" rel="stylesheet" type="text/css" />
</liferay-util:html-top>

<dl class="taglib-asset-metadata">
	<c:choose>
		<c:when test="<%= metadataFields.length == 1 %>">

			<%
			request.setAttribute("liferay-asset:asset-metadata:metadataField", metadataFields[0]);
			%>

			<liferay-util:include page="/asset_metadata/metadata_entry.jsp" servletContext="<%= application %>" />
		</c:when>
		<c:otherwise>
			<c:if test='<%= ArrayUtil.contains(metadataFields, String.valueOf("author")) %>'>

				<%
				request.setAttribute("liferay-asset:asset-metadata:metadataField", "author");

				metadataFields = ArrayUtil.remove(metadataFields, String.valueOf("author"));
				%>

				<liferay-util:include page="/asset_metadata/metadata_entry.jsp" servletContext="<%= application %>" />
			</c:if>

			<liferay-util:buffer
				var="metadataPanelContent"
			>

				<%
				for (String metadataField : metadataFields) {
					request.setAttribute("liferay-asset:asset-metadata:metadataField", metadataField);
				%>

					<liferay-util:include page="/asset_metadata/metadata_entry.jsp" servletContext="<%= application %>" />

				<%
				}
				%>

			</liferay-util:buffer>

			<c:if test="<%= Validator.isNotNull(metadataPanelContent) %>">
				<liferay-ui:panel
					collapsible="<%= true %>"
					cssClass="asset-metadata-panel"
					defaultState="closed"
					extended="<%= false %>"
					id='<%= "metadataPanel" + assetEntry.getEntryId() %>'
					persistState="<%= false %>"
					title="more-details"
				>
					<%= metadataPanelContent %>
				</liferay-ui:panel>
			</c:if>
		</c:otherwise>
	</c:choose>
</dl>