List of usage examples for com.liferay.portal.kernel.model Layout isContentDisplayPage
public boolean isContentDisplayPage();
true if the current layout can be used as a content display page. From source file:com.liferay.layout.internal.util.LayoutsTreeImpl.java
License:Open Source License
private JSONObject _toJSONObject(HttpServletRequest request, long groupId, LayoutTreeNodes layoutTreeNodes, LayoutSetBranch layoutSetBranch) throws Exception { if (_log.isDebugEnabled()) { StringBundler sb = new StringBundler(5); sb.append("_toJSON(groupId="); sb.append(groupId);/*w w w. j a v a2 s .co m*/ sb.append(", layoutTreeNodes="); sb.append(layoutTreeNodes); sb.append(StringPool.CLOSE_PARENTHESIS); _log.debug(sb.toString()); } ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); boolean hasManageLayoutsPermission = GroupPermissionUtil.contains(themeDisplay.getPermissionChecker(), groupId, ActionKeys.MANAGE_LAYOUTS); boolean mobile = BrowserSnifferUtil.isMobile(request); for (LayoutTreeNode layoutTreeNode : layoutTreeNodes) { JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); JSONObject childrenJSONObject = _toJSONObject(request, groupId, layoutTreeNode.getChildLayoutTreeNodes(), layoutSetBranch); jsonObject.put("children", childrenJSONObject); Layout layout = layoutTreeNode.getLayout(); jsonObject.put("contentDisplayPage", layout.isContentDisplayPage()); jsonObject.put("deleteable", _isDeleteable(layout, themeDisplay, layoutSetBranch)); jsonObject.put("friendlyURL", layout.getFriendlyURL()); if (layout instanceof VirtualLayout) { VirtualLayout virtualLayout = (VirtualLayout) layout; jsonObject.put("groupId", virtualLayout.getSourceGroupId()); } else { jsonObject.put("groupId", layout.getGroupId()); } jsonObject.put("hasChildren", layout.hasChildren()); jsonObject.put("layoutId", layout.getLayoutId()); jsonObject.put("name", layout.getName(themeDisplay.getLocale())); jsonObject.put("parentable", LayoutPermissionUtil.contains(themeDisplay.getPermissionChecker(), layout, ActionKeys.ADD_LAYOUT)); jsonObject.put("parentLayoutId", layout.getParentLayoutId()); jsonObject.put("plid", layout.getPlid()); jsonObject.put("priority", layout.getPriority()); jsonObject.put("privateLayout", layout.isPrivateLayout()); jsonObject.put("regularURL", layout.getRegularURL(request)); jsonObject.put("sortable", hasManageLayoutsPermission && !mobile && SitesUtil.isLayoutSortable(layout)); jsonObject.put("type", layout.getType()); jsonObject.put("updateable", LayoutPermissionUtil.contains(themeDisplay.getPermissionChecker(), layout, ActionKeys.UPDATE)); jsonObject.put("uuid", layout.getUuid()); LayoutRevision layoutRevision = LayoutStagingUtil.getLayoutRevision(layout); if (layoutRevision != null) { long layoutSetBranchId = layoutRevision.getLayoutSetBranchId(); if (_staging.isIncomplete(layout, layoutSetBranchId)) { jsonObject.put("incomplete", true); } LayoutSetBranch boundLayoutSetBranch = _layoutSetBranchLocalService .getLayoutSetBranch(layoutSetBranchId); LayoutBranch layoutBranch = layoutRevision.getLayoutBranch(); if (!layoutBranch.isMaster()) { jsonObject.put("layoutBranchId", layoutBranch.getLayoutBranchId()); jsonObject.put("layoutBranchName", layoutBranch.getName()); } if (layoutRevision.isHead()) { jsonObject.put("layoutRevisionHead", true); } jsonObject.put("layoutRevisionId", layoutRevision.getLayoutRevisionId()); jsonObject.put("layoutSetBranchId", layoutSetBranchId); jsonObject.put("layoutSetBranchName", boundLayoutSetBranch.getName()); } jsonArray.put(jsonObject); } JSONObject responseJSONObject = JSONFactoryUtil.createJSONObject(); responseJSONObject.put("layouts", jsonArray); responseJSONObject.put("total", layoutTreeNodes.getTotal()); return responseJSONObject; }
From source file:com.liferay.layout.item.selector.web.internal.display.context.LayoutItemSelectorViewDisplayContext.java
License:Open Source License
private JSONArray _getLayoutsJSONArray(long groupId, boolean privateLayout, long parentLayoutId, String selectedLayoutUuid) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); List<Layout> layouts = LayoutLocalServiceUtil.getLayouts(groupId, privateLayout, parentLayoutId); for (Layout layout : layouts) { if (StagingUtil.isIncomplete(layout)) { continue; }//w w w .j a v a 2 s . com JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); JSONArray childrenJSONArray = _getLayoutsJSONArray(groupId, privateLayout, layout.getLayoutId(), selectedLayoutUuid); if (childrenJSONArray.length() > 0) { jsonObject.put("children", childrenJSONArray); } if ((_layoutItemSelectorCriterion.isCheckDisplayPage() && !layout.isContentDisplayPage()) || (!_layoutItemSelectorCriterion.isEnableCurrentPage() && (layout.getPlid() == _getSelPlid()))) { jsonObject.put("disabled", true); } jsonObject.put("groupId", layout.getGroupId()); jsonObject.put("icon", "page"); jsonObject.put("id", layout.getUuid()); jsonObject.put("layoutId", layout.getLayoutId()); jsonObject.put("name", layout.getName(themeDisplay.getLocale())); jsonObject.put("privateLayout", layout.isPrivateLayout()); jsonObject.put("url", PortalUtil.getLayoutURL(layout, themeDisplay)); if (Objects.equals(layout.getUuid(), selectedLayoutUuid)) { jsonObject.put("selected", true); } jsonObject.put("value", _getLayoutBreadcrumb(layout)); jsonArray.put(jsonObject); } return jsonArray; }