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

<%
CPContentConfigurationDisplayContext cpContentConfigurationDisplayContext = (CPContentConfigurationDisplayContext)request.getAttribute(WebKeys.PORTLET_DISPLAY_CONTEXT);
CPContentHelper cpContentHelper = (CPContentHelper)request.getAttribute(CPContentWebKeys.CP_CONTENT_HELPER);

Map<String, Object> contextObjects = HashMapBuilder.<String, Object>put(
	"cpContentHelper", cpContentHelper
).build();

CPCatalogEntry cpCatalogEntry = cpContentHelper.getCPCatalogEntry(request);

CPInstance cpInstance = cpContentHelper.getDefaultCPInstance(request);

request.setAttribute("cpCatalogEntry", cpCatalogEntry);
request.setAttribute("cpInstance", cpInstance);
%>

<c:choose>
	<c:when test="<%= cpContentConfigurationDisplayContext.isSelectionStyleADT() %>">
		<liferay-ddm:template-renderer
			className="<%= CPContentPortlet.class.getName() %>"
			contextObjects="<%= contextObjects %>"
			displayStyle="<%= cpContentConfigurationDisplayContext.getDisplayStyle() %>"
			displayStyleGroupId="<%= cpContentConfigurationDisplayContext.getDisplayStyleGroupId() %>"
			entries="<%= Collections.singletonList(cpCatalogEntry) %>"
		/>
	</c:when>
	<c:when test="<%= cpContentConfigurationDisplayContext.isSelectionStyleCustomRenderer() %>">
		<c:choose>
			<c:when test="<%= cpCatalogEntry == null %>">
				<c:if test="<%= permissionChecker.isCompanyAdmin() || permissionChecker.isGroupAdmin(scopeGroupId) %>">
					<div class="alert alert-info">
						<liferay-ui:message key="there-is-no-product-to-display" />
					</div>
				</c:if>
			</c:when>
			<c:otherwise>

				<%
				cpContentHelper.renderCPType(request, response);
				%>

			</c:otherwise>
		</c:choose>
	</c:when>
	<c:otherwise>
	</c:otherwise>
</c:choose>