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

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

	<%
	buffer.append("<a href=\"");
	buffer.append(rowURL);
	buffer.append("\">");
	buffer.append("<strong>");
	buffer.append(curCategory.getName());
	buffer.append("</strong>");

	if (Validator.isNotNull(curCategory.getDescription())) {
		buffer.append("<br />");
		buffer.append(curCategory.getDescription());
	}

	buffer.append("</a>");

	List subcategories = MBCategoryServiceUtil.getCategories(scopeGroupId, curCategory.getCategoryId(), 0, 5);

	int subcategoriesCount = MBCategoryServiceUtil.getCategoriesCount(scopeGroupId, curCategory.getCategoryId());

	if (subcategoriesCount > 0) {
		buffer.append("<br /><span class=\"subcategories\">");
		buffer.append(LanguageUtil.get(pageContext, "subcategories"));
		buffer.append("</span>: ");

		for (int j = 0; j < subcategories.size(); j++) {
			MBCategory subcategory = (MBCategory)subcategories.get(j);

			rowURL.setParameter("mbCategoryId", String.valueOf(subcategory.getCategoryId()));

			buffer.append("<a href=\"");
			buffer.append(rowURL);
			buffer.append("\">");
			buffer.append(subcategory.getName());
			buffer.append("</a>");

			if ((j + 1) < subcategories.size()) {
				buffer.append(", ");
			}
		}

		if (subcategoriesCount > subcategories.size()) {
			rowURL.setParameter("mbCategoryId", String.valueOf(curCategory.getCategoryId()));

			buffer.append(", <a href=\"");
			buffer.append(rowURL);
			buffer.append("\">");
			buffer.append(LanguageUtil.get(pageContext, "more"));
			buffer.append(" &raquo;");
			buffer.append("</a>");
		}

		rowURL.setParameter("mbCategoryId", String.valueOf(curCategory.getCategoryId()));
	}
	%>

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

<liferay-ui:search-container-column-jsp
	align="right"
	path="/html/portlet/message_boards/category_action.jsp"
/>