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

<%
PortalPreferences portalPrefs = PortletPreferencesFactoryUtil.getPortalPreferences(request);

PortletURL portletURL = renderResponse.createRenderURL();

portletURL.setParameter("struts_action", "/portlet_configuration/edit_configuration");
portletURL.setParameter("redirect", redirect);
portletURL.setParameter("backURL", redirect);
portletURL.setParameter("portletResource", portletResource);
portletURL.setParameter("typeSelection", JournalArticle.class.getName());
portletURL.setParameter("assetOrder", String.valueOf(assetOrder));
%>

<liferay-ui:header
	backURL="<%= configurationRenderURL.toString() %>"
	title="web-content"
/>

<%
ArticleSearch searchContainer = new ArticleSearch(renderRequest, portletURL);
%>

<liferay-ui:search-form
	page="/html/portlet/asset_publisher/article_search.jsp"
	searchContainer="<%= searchContainer %>"
/>

<%
ArticleSearchTerms searchTerms = (ArticleSearchTerms)searchContainer.getSearchTerms();
%>

<%@ include file="/html/portlet/journal/article_search_results.jspf" %>

<div class="separator"><!-- --></div>

<%
List resultRows = searchContainer.getResultRows();

for (int i = 0; i < results.size(); i++) {
	JournalArticle article = (JournalArticle)results.get(i);

	long articleResourceId = article.getResourcePrimKey();

	ResultRow row = new ResultRow(article, article.getArticleId() + EditArticleAction.VERSION_SEPARATOR + article.getVersion(), i);

	StringBundler sb = new StringBundler(9);

	sb.append("javascript:");
	sb.append(renderResponse.getNamespace());
	sb.append("selectAsset('");
	sb.append(article.getGroupId());
	sb.append("', '");
	sb.append(article.getArticleId());
	sb.append("', '");
	sb.append(assetOrder);
	sb.append("');");

	String rowHREF = sb.toString();

	// Article id

	row.addText(article.getArticleId(), rowHREF);

	// Title

	row.addText(article.getTitle(), rowHREF);

	// Version

	row.addText(String.valueOf(article.getVersion()), rowHREF);

	// Modified date

	row.addText(dateFormatDate.format(article.getModifiedDate()), rowHREF);

	// Display date

	row.addText(dateFormatDate.format(article.getDisplayDate()), rowHREF);

	// Author

	row.addText(HtmlUtil.escape(PortalUtil.getUserName(article.getUserId(), article.getUserName())), rowHREF);

	// Add result row

	resultRows.add(row);
}
%>

<liferay-ui:search-iterator searchContainer="<%= searchContainer %>" />

<br />