<%
/**
 * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */
%>

<c:if test="<%= BlogsEntryPermission.contains(permissionChecker, entry, ActionKeys.VIEW) %>">
	<div class="entry-content">

		<%
		PortletURL showBlogEntryURL = renderResponse.createRenderURL();

		showBlogEntryURL.setParameter("struts_action", "/blogs_aggregator/view_entry");
		showBlogEntryURL.setParameter("entryId", String.valueOf(entry.getEntryId()));

		StringBundler sb = new StringBundler(8);

		sb.append(themeDisplay.getPathMain());
		sb.append("/blogs/find_entry?redirect=");
		sb.append(HttpUtil.encodeURL(currentURL));
		sb.append("&noSuchEntryRedirect=");
		sb.append(HttpUtil.encodeURL(showBlogEntryURL.toString()));
		sb.append("&entryId=");
		sb.append(entry.getEntryId());

		String viewEntryURL = sb.toString();

		sb.append("&showAllEntries=1");

		String viewAllEntriesURL = sb.toString();

		User user2 = UserLocalServiceUtil.getUserById(entry.getUserId());
		%>

		<c:if test='<%= !displayStyle.endsWith("-without-title") %>'>
			<div class="entry-info">
				<span class="entry-title"><a href="<%= viewEntryURL %>"><%= entry.getTitle() %></a></span>

				<span class="entry-author"><liferay-ui:message key="written-by" /> <a href="<%= viewAllEntriesURL %>"><%= HtmlUtil.escape(PortalUtil.getUserName(entry.getUserId(), entry.getUserName())) %></a>,</span>

				<span class="entry-date"><liferay-ui:message key="on-date" /> <%= dateFormatDateTime.format(entry.getDisplayDate()) %></span>

				<span class="entry-categories">
					<liferay-ui:asset-categories-summary
						className="<%= BlogsEntry.class.getName() %>"
						classPK="<%= entry.getEntryId() %>"
					/>
				</span>

				<c:if test="<%= showTags %>">
					<span class="entry-tags">
						<liferay-ui:asset-tags-summary
							className="<%= BlogsEntry.class.getName() %>"
							classPK="<%= entry.getEntryId() %>"
						/>
					</span>
				</c:if>
			</div>
		</c:if>
	</div>

	<c:if test='<%= !displayStyle.equals("title") %>'>
		<div class="abstract">
			<c:if test='<%= displayStyle.endsWith("-image") %>'>
				<a href="<%= viewAllEntriesURL %>"><img align="left" border="0" hspace="0" src="<%= themeDisplay.getPathImage() %>/user_<%= user2.isFemale() ? "female" : "male" %>_portrait?img_id=<%= user2.getPortraitId() %>&t=<%= ImageServletTokenUtil.getToken(user2.getPortraitId()) %>" width="65" /></a>
			</c:if>
			<c:choose>
				<c:when test='<%= displayStyle.startsWith("abstract") %>'>
					<%= StringUtil.shorten(HtmlUtil.stripHtml(entry.getContent()), 200, StringPool.BLANK) %>
				</c:when>
				<c:when test='<%= displayStyle.startsWith("quote") %>'>
					<span class="quote">
						<a href="<%= viewAllEntriesURL %>">
							&quot;<%= StringUtil.shorten(StringUtil.trim(HtmlUtil.stripHtml(entry.getContent())), 100, StringPool.BLANK) %> ...&quot;

							<span class="nobreak"><liferay-ui:message arguments='<%= new Object[] {"aui-helper-hidden-accessible", entry.getTitle()} %>' key="read-more-x-about-x" /> &raquo;</span>
						</a>
					</span>
				</c:when>
				<c:otherwise>
					<%= entry.getContent() %>
				</c:otherwise>
			</c:choose>
		</div>

		<div class="comments">
			<c:choose>
				<c:when test='<%= displayStyle.startsWith("abstract") %>'>
					<a href="<%= viewEntryURL %>"><liferay-ui:message arguments='<%= new Object[] {"aui-helper-hidden-accessible", entry.getTitle()} %>' key="read-more-x-about-x" /> &raquo;</a>
				</c:when>
				<c:when test='<%= !displayStyle.startsWith("quote") %>'>

					<%
					long classNameId = PortalUtil.getClassNameId(BlogsEntry.class.getName());

					int messagesCount = MBMessageLocalServiceUtil.getDiscussionMessagesCount(classNameId, entry.getEntryId(), WorkflowConstants.STATUS_APPROVED);
					%>

					<a href="<%= viewEntryURL %>#<portlet:namespace />messageScroll0"><%= messagesCount %> <liferay-ui:message key="comments" /></a>
				</c:when>
			</c:choose>
		</div>
	</c:if>

	<div class="separator"><!-- --></div>
</c:if>