<%--
/**
 * 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");

AssetEntry assetEntry = workflowTaskDisplayContext.getAssetEntry();

AssetRenderer<?> assetRenderer = workflowTaskDisplayContext.getAssetRenderer(workflowTaskDisplayContext.getWorkflowTask());

AssetRendererFactory<?> assetRendererFactory = workflowTaskDisplayContext.getAssetRendererFactory();

String languageId = LanguageUtil.getLanguageId(request);

String[] availableLanguageIds = assetRenderer.getAvailableLanguageIds();

if (ArrayUtil.isNotEmpty(availableLanguageIds) && !ArrayUtil.contains(availableLanguageIds, languageId)) {
	languageId = assetRenderer.getDefaultLanguageId();
}

request.setAttribute(WebKeys.WORKFLOW_ASSET_PREVIEW, Boolean.TRUE);

portletDisplay.setShowBackIcon(true);
portletDisplay.setURLBack(redirect);

renderResponse.setTitle(assetRenderer.getTitle(workflowTaskDisplayContext.getTaskContentLocale()));
%>

<clay:container-fluid
	cssClass="main-content-body"
>
	<clay:col
		cssClass="lfr-asset-column lfr-asset-column-details"
		md="12"
	>
		<div class="card-horizontal main-content-card">
			<div class="panel-body">
				<c:if test="<%= assetEntry != null %>">
					<c:if test="<%= assetRenderer.isLocalizable() %>">
						<div class="locale-actions">
							<liferay-ui:language
								formAction="<%= currentURL %>"
								languageId="<%= languageId %>"
								languageIds="<%= availableLanguageIds %>"
							/>
						</div>
					</c:if>

					<liferay-asset:asset-display
						assetEntry="<%= assetEntry %>"
						assetRenderer="<%= assetRenderer %>"
						assetRendererFactory="<%= assetRendererFactory %>"
					/>
				</c:if>

				<%
				String viewInContextURL = assetRenderer.getURLViewInContext(liferayPortletRequest, liferayPortletResponse, null);
				%>

				<c:if test="<%= viewInContextURL != null %>">
					<div class="asset-more">
						<aui:a href="<%= viewInContextURL %>"><liferay-ui:message key="view-in-context" /> &raquo;</aui:a>
					</div>
				</c:if>
			</div>
		</div>
	</clay:col>
</clay:container-fluid>