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

<%
BlogsEntry entry = (BlogsEntry)request.getAttribute("entry_toolbar.jsp-entry");
RatingsEntry ratingsEntry = (RatingsEntry)request.getAttribute("view_entry_content.jsp-ratingsEntry");
RatingsStats ratingsStats = (RatingsStats)request.getAttribute("view_entry_content.jsp-ratingsStats");

boolean showFlags = ParamUtil.getBoolean(request, "showFlags");
boolean showOnlyIcons = ParamUtil.getBoolean(request, "showOnlyIcons");

BlogsPortletInstanceConfiguration blogsPortletInstanceConfiguration = BlogsPortletInstanceConfigurationUtil.getBlogsPortletInstanceConfiguration(themeDisplay);
%>

<clay:content-row
	cssClass="widget-toolbar"
	floatElements="end"
	verticalAlign="center"
>
	<c:if test="<%= blogsPortletInstanceConfiguration.enableComments() %>">
		<clay:content-col>

			<%
			int messagesCount = CommentManagerUtil.getCommentsCount(BlogsEntry.class.getName(), entry.getEntryId());
			%>

			<portlet:renderURL var="viewEntryCommentsURL">
				<portlet:param name="mvcRenderCommandName" value="/blogs/view_entry" />
				<portlet:param name="scroll" value='<%= liferayPortletResponse.getNamespace() + "discussionContainer" %>' />

				<c:choose>
					<c:when test="<%= Validator.isNotNull(entry.getUrlTitle()) %>">
						<portlet:param name="urlTitle" value="<%= entry.getUrlTitle() %>" />
					</c:when>
					<c:otherwise>
						<portlet:param name="entryId" value="<%= String.valueOf(entry.getEntryId()) %>" />
					</c:otherwise>
				</c:choose>
			</portlet:renderURL>

			<liferay-util:whitespace-remover>
				<a class="btn btn-outline-borderless btn-outline-secondary btn-sm" href="<%= viewEntryCommentsURL.toString() %>" title="<liferay-ui:message key="comments" />">
					<span class="inline-item inline-item-before">
						<clay:icon
							symbol="comments"
						/>
					</span>

					<c:choose>
						<c:when test="<%= showOnlyIcons %>">
							<%= messagesCount %>
						</c:when>
						<c:otherwise>
							<liferay-ui:message arguments="<%= messagesCount %>" key="comment-x" />
						</c:otherwise>
					</c:choose>
				</a>
			</liferay-util:whitespace-remover>
		</clay:content-col>
	</c:if>

	<c:if test="<%= blogsPortletInstanceConfiguration.enableRatings() %>">
		<clay:content-col>
			<liferay-ratings:ratings
				className="<%= BlogsEntry.class.getName() %>"
				classPK="<%= entry.getEntryId() %>"
				inTrash="<%= entry.isInTrash() %>"
				ratingsEntry="<%= ratingsEntry %>"
				ratingsStats="<%= ratingsStats %>"
			/>
		</clay:content-col>
	</c:if>

	<c:if test="<%= blogsPortletInstanceConfiguration.enableFlags() && showFlags %>">
		<clay:content-col>
			<div class="flags">
				<liferay-flags:flags
					className="<%= BlogsEntry.class.getName() %>"
					classPK="<%= entry.getEntryId() %>"
					contentTitle="<%= BlogsEntryUtil.getDisplayTitle(resourceBundle, entry) %>"
					enabled="<%= !entry.isInTrash() %>"
					message='<%= entry.isInTrash() ? "flags-are-disabled-because-this-entry-is-in-the-recycle-bin" : null %>'
					reportedUserId="<%= entry.getUserId() %>"
				/>
			</div>
		</clay:content-col>
	</c:if>

	<clay:content-col
		cssClass="autofit-col-end"
	>
		<liferay-portlet:renderURL varImpl="bookmarkURL" windowState="<%= WindowState.NORMAL.toString() %>">
			<portlet:param name="mvcRenderCommandName" value="/blogs/view_entry" />

			<c:choose>
				<c:when test="<%= Validator.isNotNull(entry.getUrlTitle()) %>">
					<portlet:param name="urlTitle" value="<%= entry.getUrlTitle() %>" />
				</c:when>
				<c:otherwise>
					<portlet:param name="entryId" value="<%= String.valueOf(entry.getEntryId()) %>" />
				</c:otherwise>
			</c:choose>
		</liferay-portlet:renderURL>

		<liferay-social-bookmarks:bookmarks
			className="<%= BlogsEntry.class.getName() %>"
			classPK="<%= entry.getEntryId() %>"
			displayStyle='<%= showOnlyIcons ? "inline" : blogsPortletInstanceConfiguration.socialBookmarksDisplayStyle() %>'
			maxInlineItems="<%= showOnlyIcons ? 0 : 3 %>"
			target="_blank"
			title="<%= BlogsEntryUtil.getDisplayTitle(resourceBundle, entry) %>"
			types="<%= SocialBookmarksUtil.getSocialBookmarksTypes(blogsPortletInstanceConfiguration) %>"
			urlImpl="<%= bookmarkURL %>"
		/>
	</clay:content-col>
</clay:content-row>