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

<liferay-ui:search-container-column-text
	name="category"
>

	<%
	StringBundler sb = new StringBundler();

	_buildCategoryBreadcrumb(request, themeDisplay, curCategory, sb);
	%>

	<%= sb.toString() %>
</liferay-ui:search-container-column-text>

<liferay-ui:search-container-column-text
	href="<%= rowURL %>"
	name="categories"
	value="<%= String.valueOf(categoryDisplay.getSubcategoriesCount(curCategory)) %>"
/>

<liferay-ui:search-container-column-text
	href="<%= rowURL %>"
	name="threads"
	value="<%= String.valueOf(categoryDisplay.getSubcategoriesThreadsCount(curCategory)) %>"
/>

<liferay-ui:search-container-column-text
	href="<%= rowURL %>"
	name="posts"
	value="<%= String.valueOf(categoryDisplay.getSubcategoriesMessagesCount(curCategory)) %>"
/>

<%@ include file="/message_boards/subscribed_category_columns_action.jspf" %>

<%!
private void _buildCategoryBreadcrumb(HttpServletRequest request, ThemeDisplay themeDisplay, MBCategory category, StringBundler sb) throws Exception {
	List<MBCategory> ancestorCategories = category.getAncestors();

	Collections.reverse(ancestorCategories);

	sb.append("<ul class=\"breadcrumb\">");

	for (int i = 0; i < ancestorCategories.size(); i++) {
		MBCategory ancestorCategory = ancestorCategories.get(i);

		PortletURL portletURL = PortletURLFactoryUtil.create(request, MBPortletKeys.MESSAGE_BOARDS, PortletRequest.RENDER_PHASE);

		portletURL.setParameter("mvcRenderCommandName", "/message_boards/view_category");
		portletURL.setParameter("mbCategoryId", String.valueOf(ancestorCategory.getCategoryId()));

		String cssClass = StringPool.BLANK;

		if (i == 0) {
			cssClass = "first";
		}

		sb.append("<li class=\"");
		sb.append(cssClass);
		sb.append("\"><a href=\"");
		sb.append(portletURL.toString());
		sb.append("\">");
		sb.append(HtmlUtil.escape(ancestorCategory.getName()));
		sb.append("</a></li>");
	}

	PortletURL portletURL = PortletURLFactoryUtil.create(request, MBPortletKeys.MESSAGE_BOARDS, PortletRequest.RENDER_PHASE);

	portletURL.setParameter("mvcRenderCommandName", "/message_boards/view_category");
	portletURL.setParameter("mbCategoryId", String.valueOf(category.getCategoryId()));

	sb.append("<li class=\"active last\">");
	sb.append("<strong>");
	sb.append("<a href=\"");
	sb.append(portletURL.toString());
	sb.append("\">");
	sb.append(category.getName());
	sb.append("</strong>");
	sb.append("</a>");

	if (Validator.isNotNull(category.getDescription())) {
		sb.append("<p>");
		sb.append(category.getDescription());
		sb.append("</p>");
	}

	sb.append("</li>");
	sb.append("</ul>");
}
%>