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

<div class="search-info">

	<%
	long folderId = ParamUtil.getLong(request, "folderId");
	String keywords = ParamUtil.getString(request, "keywords");

	boolean searchEverywhere = true;

	long searchFolderId = ParamUtil.getLong(request, "searchFolderId");

	boolean showRerunSearchButton = true;

	if (folderId > DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
		searchEverywhere = false;
	}
	else {
		folderId = searchFolderId;
	}

	if ((folderId == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID) && (searchFolderId == DLFolderConstants.DEFAULT_PARENT_FOLDER_ID)) {
		showRerunSearchButton = false;
	}
	%>

	<c:if test="<%= showRerunSearchButton %>">

		<%
		PortletURL portletURL = (PortletURL)request.getAttribute("liferay-item-selector:repository-entry-browser:portletURL");

		PortletURL searchEverywhereURL = PortletURLBuilder.create(
			PortletURLUtil.clone(portletURL, liferayPortletResponse)
		).setKeywords(
			keywords
		).setParameter(
			"folderId", DLFolderConstants.DEFAULT_PARENT_FOLDER_ID
		).setParameter(
			"searchFolderId", folderId
		).buildPortletURL();
		%>

		<liferay-util:whitespace-remover>
			<liferay-ui:message key="search" />

			<clay:link
				cssClass='<%= searchEverywhere ? "active" : "" %>'
				displayType="secondary"
				href="<%= searchEverywhereURL.toString() %>"
				label="everywhere"
				small="<%= true %>"
				type="button"
			/>

			<%
			Folder folder = DLAppServiceUtil.getFolder(folderId);
			%>

			<clay:link
				cssClass='<%= !searchEverywhere ? "active" : "" %>'
				displayType="secondary"
				href='<%=
					PortletURLBuilder.create(
						PortletURLUtil.clone(searchEverywhereURL, liferayPortletResponse)
					).setParameter(
						"folderId", folderId
					).buildString()
				%>'
				icon="folder"
				label="<%= folder.getName() %>"
				type="button"
			/>
		</liferay-util:whitespace-remover>
	</c:if>
</div>