All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.asset_tags_navigation.page.jsp Maven / Gradle / Ivy

There is a newer version: 7.4.3.112-ga112
Show newest version
<%--
/**
 * Copyright (c) 2000-present 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.
 */
--%>

<%@ include file="/asset_tags_navigation/init.jsp" %>

<%
long classNameId = GetterUtil.getLong((String)request.getAttribute("liferay-asset:asset-tags-navigation:classNameId"));
String displayStyle = (String)request.getAttribute("liferay-asset:asset-tags-navigation:displayStyle");
boolean hidePortletWhenEmpty = GetterUtil.getBoolean((String)request.getAttribute("liferay-asset:asset-tags-navigation:hidePortletWhenEmpty"));
int maxAssetTags = GetterUtil.getInteger((String)request.getAttribute("liferay-asset:asset-tags-navigation:maxAssetTags"));
boolean showAssetCount = GetterUtil.getBoolean((String)request.getAttribute("liferay-asset:asset-tags-navigation:showAssetCount"));
boolean showZeroAssetCount = GetterUtil.getBoolean((String)request.getAttribute("liferay-asset:asset-tags-navigation:showZeroAssetCount"));

String tag = ParamUtil.getString(request, "tag");

PortletURL portletURL = renderResponse.createRenderURL();

String tagsNavigation = _buildTagsNavigation(scopeGroupId, tag, portletURL, classNameId, displayStyle, maxAssetTags, showAssetCount, showZeroAssetCount);

if (Validator.isNotNull(tagsNavigation)) {
%>

	
		<%= tagsNavigation %>
	

<%
}
else {
	if (hidePortletWhenEmpty) {
		renderRequest.setAttribute(WebKeys.PORTLET_CONFIGURATOR_VISIBILITY, Boolean.TRUE);
	}
%>

	
<% } if (Validator.isNotNull(tag)) { PortalUtil.addPortletBreadcrumbEntry(request, tag, currentURL, null, false); } %> <%! private String _buildTagsNavigation(long scopeGroupId, String selectedTagName, PortletURL portletURL, long classNameId, String displayStyle, int maxAssetTags, boolean showAssetCount, boolean showZeroAssetCount) throws Exception { List tags = null; if (showAssetCount && (classNameId > 0)) { tags = AssetTagServiceUtil.getTags(PortalUtil.getSiteGroupId(scopeGroupId), classNameId, null, 0, maxAssetTags, new AssetTagCountComparator()); } else { tags = AssetTagServiceUtil.getGroupTags(PortalUtil.getSiteGroupId(scopeGroupId), 0, maxAssetTags, new AssetTagCountComparator()); } if (tags.isEmpty()) { return null; } tags = ListUtil.sort(tags); StringBundler sb = new StringBundler(); sb.append("
    0) { count = AssetTagServiceUtil.getVisibleAssetsTagsCount(scopeGroupId, classNameId, tagName); } else { count = AssetTagServiceUtil.getVisibleAssetsTagsCount(scopeGroupId, tagName); } if (!showZeroAssetCount && (count == 0)) { continue; } maxCount = Math.max(maxCount, count); minCount = Math.min(minCount, count); } } else { sb.append("tag-list"); } sb.append("\">"); double multiplier = 1; if (maxCount != minCount) { multiplier = (double)5 / (maxCount - minCount); } portletURL.setParameter("tag", StringPool.BLANK); String originalPortletURLString = portletURL.toString(); for (AssetTag tag : tags) { String tagName = tag.getName(); int count = 0; if (classNameId > 0) { count = AssetTagServiceUtil.getVisibleAssetsTagsCount(scopeGroupId, classNameId, tagName); } else { count = AssetTagServiceUtil.getVisibleAssetsTagsCount(scopeGroupId, tagName); } int popularity = (int)(1 + ((maxCount - (maxCount - (count - minCount))) * multiplier)); if (!showZeroAssetCount && (count == 0)) { continue; } sb.append("
  • "); if (tagName.equals(selectedTagName)) { sb.append(""); sb.append(tagName); if (showAssetCount) { sb.append(""); sb.append(StringPool.SPACE); sb.append(StringPool.OPEN_PARENTHESIS); sb.append(count); sb.append(StringPool.CLOSE_PARENTHESIS); sb.append(""); } sb.append("
  • "); } sb.append("
"); return sb.toString(); } %>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy