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

META-INF.resources.admin.common.select_parent.jsp Maven / Gradle / Ivy

There is a newer version: 5.0.146
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="/admin/common/init.jsp" %>

<%
int status = (Integer)request.getAttribute(KBWebKeys.KNOWLEDGE_BASE_STATUS);

resourceClassNameId = ParamUtil.getLong(request, "resourceClassNameId");
resourcePrimKey = ParamUtil.getLong(request, "resourcePrimKey");
long parentResourceClassNameId = ParamUtil.getLong(request, "parentResourceClassNameId", kbFolderClassNameId);
long parentResourcePrimKey = ParamUtil.getLong(request, "parentResourcePrimKey", KBFolderConstants.DEFAULT_PARENT_FOLDER_ID);
long originalParentResourcePrimKey = ParamUtil.getLong(request, "originalParentResourcePrimKey");
double priority = ParamUtil.getDouble(request, "priority", KBArticleConstants.DEFAULT_PRIORITY);

long kbArticleClassNameId = PortalUtil.getClassNameId(KBArticleConstants.getClassName());

long[] selectableClassNameIds = ParamUtil.getLongValues(request, "selectableClassNameIds", new long[] {kbFolderClassNameId, kbArticleClassNameId});

String eventName = ParamUtil.getString(request, "eventName", liferayPortletResponse.getNamespace() + "selectKBObject");

String parentTitle = LanguageUtil.get(request, "home");

if (parentResourcePrimKey != KBFolderConstants.DEFAULT_PARENT_FOLDER_ID) {
	if (parentResourceClassNameId == kbFolderClassNameId) {
		KBFolder parentKBFolder = KBFolderLocalServiceUtil.fetchKBFolder(parentResourcePrimKey);

		if ((parentKBFolder == null) || !KBFolderPermission.contains(permissionChecker, parentKBFolder, ActionKeys.VIEW)) {
			parentResourceClassNameId = kbFolderClassNameId;

			parentResourcePrimKey = KBFolderConstants.DEFAULT_PARENT_FOLDER_ID;
		}
		else {
			parentTitle = parentKBFolder.getName();
		}
	}
	else {
		KBArticle parentKBArticle = KBArticleLocalServiceUtil.fetchLatestKBArticle(parentResourcePrimKey, status);

		if ((parentKBArticle == null) || !KBArticlePermission.contains(permissionChecker, parentKBArticle, ActionKeys.VIEW)) {
			parentResourceClassNameId = kbFolderClassNameId;

			parentResourcePrimKey = KBFolderConstants.DEFAULT_PARENT_FOLDER_ID;
		}
		else {
			parentTitle = parentKBArticle.getTitle();
		}
	}
}

SearchContainer kbObjectSearchContainer = new SearchContainer(renderRequest, null, null, SearchContainer.DEFAULT_CUR_PARAM, SearchContainer.DEFAULT_DELTA, currentURLObj, null, "there-are-no-entries");

boolean kbFolderView = (resourceClassNameId == kbFolderClassNameId);

if (kbFolderView) {
	kbObjectSearchContainer.setTotal(KBFolderServiceUtil.getKBFoldersCount(scopeGroupId, parentResourcePrimKey));
	kbObjectSearchContainer.setResults(KBFolderServiceUtil.getKBFolders(scopeGroupId, parentResourcePrimKey, kbObjectSearchContainer.getStart(), kbObjectSearchContainer.getEnd()));
}
else {
	kbObjectSearchContainer.setTotal(KBFolderServiceUtil.getKBFoldersAndKBArticlesCount(scopeGroupId, parentResourcePrimKey, WorkflowConstants.STATUS_APPROVED));
	kbObjectSearchContainer.setResults(KBFolderServiceUtil.getKBFoldersAndKBArticles(scopeGroupId, parentResourcePrimKey, WorkflowConstants.STATUS_APPROVED, kbObjectSearchContainer.getStart(), kbObjectSearchContainer.getEnd(), new KBObjectsTitleComparator()));
}
%>

<% KBSelectParentDisplayContext kbSelectParentDisplayContext = new KBSelectParentDisplayContext(parentResourceClassNameId, parentResourcePrimKey, request, liferayPortletResponse); kbSelectParentDisplayContext.populatePortletBreadcrumbEntries(currentURLObj); %> <% Map data = new HashMap(); data.put("priority", priority); data.put("resourceClassNameId", parentResourceClassNameId); data.put("resourcePrimKey", parentResourcePrimKey); data.put("title", parentTitle); %> <% KBFolder kbFolder = (KBFolder)kbObject; kbFolder = kbFolder.toEscapedModel(); %> <% int kbArticlesCount = KBArticleServiceUtil.getKBArticlesCount(scopeGroupId, kbFolder.getKbFolderId(), status); int kbFoldersCount = KBFolderServiceUtil.getKBFoldersCount(scopeGroupId, kbFolder.getKbFolderId()); if ((kbFolder.getKbFolderId() == resourcePrimKey) || ((kbArticlesCount == 0) && (kbFoldersCount == 0))) { rowURL = null; } %> <%= kbFolder.getName() %> <%= kbFolder.getName() %> <% Map data = new HashMap(); data.put("priority", KBArticleConstants.DEFAULT_PRIORITY); data.put("resourceClassNameId", kbFolder.getClassNameId()); data.put("resourcePrimKey", kbFolder.getKbFolderId()); data.put("title", kbFolder.getName()); %> <% KBArticle kbArticle = (KBArticle)kbObject; kbArticle = kbArticle.toEscapedModel(); %> <% int kbArticlesCount = KBArticleServiceUtil.getKBArticlesCount(scopeGroupId, kbArticle.getResourcePrimKey(), status); if ((kbArticle.getResourcePrimKey() == resourcePrimKey) || (kbArticlesCount == 0)) { rowURL = null; } %> <%= kbArticle.getTitle() %> <%= kbArticle.getTitle() %> <% Map data = new HashMap(); data.put("priority", kbArticle.getPriority()); data.put("resourceClassNameId", kbArticle.getClassNameId()); data.put("resourcePrimKey", kbArticle.getResourcePrimKey()); data.put("title", kbArticle.getTitle()); %>
Liferay.Util.selectEntityHandler('#fm', '<%= HtmlUtil.escape(eventName) %>');