List of usage examples for com.liferay.portal.kernel.theme PortletDisplay getId
public String getId()
From source file:blade.document.action.displaycontext.BladeActionDisplayContext.java
License:Apache License
/** * Read settings from page Documents And Media portlet "Show Actions" portlet configuration.<br/> * But for Documents And Media admin portlet, it will always be true. *///from w w w . j a v a2 s . c om private boolean _showAction() throws SettingsException { PortletDisplay portletDisplay = _themeDisplay.getPortletDisplay(); String portletName = portletDisplay.getPortletName(); if (portletName.equals(PortletKeys.DOCUMENT_LIBRARY_ADMIN)) { return true; } Settings settings = SettingsFactoryUtil .getSettings(new PortletInstanceSettingsLocator(_themeDisplay.getLayout(), portletDisplay.getId())); TypedSettings typedSettings = new TypedSettings(settings); return typedSettings.getBooleanValue("showActions"); }
From source file:com.liferay.asset.internal.util.AssetHelperImpl.java
License:Open Source License
@Override public PortletURL getAddPortletURL(LiferayPortletRequest liferayPortletRequest, LiferayPortletResponse liferayPortletResponse, long groupId, String className, long classTypeId, long[] allAssetCategoryIds, String[] allAssetTagNames, String redirect) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY); AssetRendererFactory<?> assetRendererFactory = AssetRendererFactoryRegistryUtil .getAssetRendererFactoryByClassName(className); if ((assetRendererFactory == null) || !assetRendererFactory .hasAddPermission(themeDisplay.getPermissionChecker(), groupId, classTypeId)) { return null; }//from w w w .ja va 2 s . c o m if (groupId > 0) { Group group = _groupLocalService.fetchGroup(groupId); liferayPortletRequest.setAttribute(WebKeys.ASSET_RENDERER_FACTORY_GROUP, group); } PortletURL addPortletURL = assetRendererFactory.getURLAdd(liferayPortletRequest, liferayPortletResponse, classTypeId); if (addPortletURL == null) { return null; } if (redirect != null) { addPortletURL.setParameter("redirect", redirect); } String referringPortletResource = ParamUtil.getString(liferayPortletRequest, "portletResource"); if (Validator.isNotNull(referringPortletResource)) { addPortletURL.setParameter("referringPortletResource", referringPortletResource); } else { PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); addPortletURL.setParameter("referringPortletResource", portletDisplay.getId()); if (allAssetCategoryIds != null) { Map<Long, String> assetVocabularyAssetCategoryIds = new HashMap<>(); for (long assetCategoryId : allAssetCategoryIds) { AssetCategory assetCategory = _assetCategoryLocalService.fetchAssetCategory(assetCategoryId); if (assetCategory == null) { continue; } long assetVocabularyId = assetCategory.getVocabularyId(); if (assetVocabularyAssetCategoryIds.containsKey(assetVocabularyId)) { String assetCategoryIds = assetVocabularyAssetCategoryIds.get(assetVocabularyId); assetVocabularyAssetCategoryIds.put(assetVocabularyId, assetCategoryIds + StringPool.COMMA + assetCategoryId); } else { assetVocabularyAssetCategoryIds.put(assetVocabularyId, String.valueOf(assetCategoryId)); } } for (Map.Entry<Long, String> entry : assetVocabularyAssetCategoryIds.entrySet()) { long assetVocabularyId = entry.getKey(); String assetCategoryIds = entry.getValue(); addPortletURL.setParameter("assetCategoryIds_" + assetVocabularyId, assetCategoryIds); } } if (allAssetTagNames != null) { addPortletURL.setParameter("assetTagNames", StringUtil.merge(allAssetTagNames)); } } addPortletURL.setPortletMode(PortletMode.VIEW); addPortletURL.setWindowState(LiferayWindowState.POP_UP); return addPortletURL; }
From source file:com.liferay.asset.publisher.web.display.context.AssetPublisherDisplayContext.java
License:Open Source License
public boolean isDefaultAssetPublisher() { if (_defaultAssetPublisher != null) { return _defaultAssetPublisher; }//from w ww .j a v a2 s .c om ThemeDisplay themeDisplay = (ThemeDisplay) _request.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); _defaultAssetPublisher = _assetPublisherWebUtil.isDefaultAssetPublisher(themeDisplay.getLayout(), portletDisplay.getId(), getPortletResource()); return _defaultAssetPublisher; }
From source file:com.liferay.asset.publisher.web.internal.portlet.toolbar.contributor.AssetPublisherPortletToolbarContributor.java
License:Open Source License
private URLMenuItem _getPortletTitleAddAssetEntryMenuItem(ThemeDisplay themeDisplay, AssetPublisherDisplayContext assetPublisherDisplayContext, long groupId, AssetPublisherAddItemHolder assetPublisherAddItemHolder) { URLMenuItem urlMenuItem = new URLMenuItem(); Map<String, Object> data = new HashMap<>(); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); data.put("id", HtmlUtil.escape(portletDisplay.getNamespace()) + "editAsset"); String message = assetPublisherAddItemHolder.getModelResource(); String title = LanguageUtil.format(themeDisplay.getLocale(), "new-x", message, false); data.put("title", title); urlMenuItem.setData(data);/* www . j av a 2 s . c o m*/ urlMenuItem.setLabel(HtmlUtil.escape(message)); long curGroupId = groupId; Group group = _groupLocalService.fetchGroup(groupId); if (!group.isStagedPortlet(assetPublisherAddItemHolder.getPortletId()) && !group.isStagedRemotely()) { curGroupId = group.getLiveGroupId(); } boolean addDisplayPageParameter = _assetPublisherWebUtil.isDefaultAssetPublisher(themeDisplay.getLayout(), portletDisplay.getId(), assetPublisherDisplayContext.getPortletResource()); String url = _assetHelper.getAddURLPopUp(curGroupId, themeDisplay.getPlid(), assetPublisherAddItemHolder.getPortletURL(), addDisplayPageParameter, themeDisplay.getLayout()); urlMenuItem.setURL(url); urlMenuItem.setUseDialog(true); return urlMenuItem; }
From source file:com.liferay.asset.taglib.internal.util.AssetCategoryUtil.java
License:Open Source License
public static void addPortletBreadcrumbEntries(long assetCategoryId, HttpServletRequest request, PortletURL portletURL) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); boolean portletBreadcrumbEntry = false; if (Validator.isNotNull(portletDisplay.getId()) && !portletDisplay.isFocused()) { portletBreadcrumbEntry = true;/*from w w w .j a v a2 s. c o m*/ } addPortletBreadcrumbEntries(assetCategoryId, request, portletURL, portletBreadcrumbEntry); }
From source file:com.liferay.blogs.editor.configuration.internal.BlogsContentEditorOptionsContributor.java
License:Open Source License
@Override public void populateEditorOptions(EditorOptions editorOptions, Map<String, Object> inputEditorTaglibAttributes, ThemeDisplay themeDisplay, RequestBackedPortletURLFactory requestBackedPortletURLFactory) { PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); if (Validator.isNull(portletDisplay.getId())) { return;/* ww w .ja va 2s . co m*/ } PortletURL portletURL = requestBackedPortletURLFactory.createActionURL(portletDisplay.getId()); portletURL.setParameter(ActionRequest.ACTION_NAME, "/blogs/upload_temp_image"); editorOptions.setUploadURL(portletURL.toString()); }
From source file:com.liferay.bookmarks.web.internal.portlet.toolbar.contributor.BookmarksPortletToolbarContributor.java
License:Open Source License
protected void addPortletTitleAddBookmarkMenuItem(List<MenuItem> menuItems, BookmarksFolder folder, ThemeDisplay themeDisplay, PortletRequest portletRequest) throws PortalException { long folderId = _getFolderId(folder); if (!containsPermission(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), folderId, ActionKeys.ADD_ENTRY)) {//from w w w . j a va 2 s.c om return; } URLMenuItem urlMenuItem = new URLMenuItem(); urlMenuItem.setLabel(LanguageUtil.get(PortalUtil.getHttpServletRequest(portletRequest), "bookmark")); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); PortletURL portletURL = PortletURLFactoryUtil.create(portletRequest, portletDisplay.getId(), themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "/bookmarks/edit_entry"); portletURL.setParameter("redirect", PortalUtil.getCurrentURL(portletRequest)); portletURL.setParameter("folderId", String.valueOf(folderId)); urlMenuItem.setURL(portletURL.toString()); menuItems.add(urlMenuItem); }
From source file:com.liferay.bookmarks.web.internal.portlet.toolbar.contributor.BookmarksPortletToolbarContributor.java
License:Open Source License
protected void addPortletTitleAddFolderMenuItem(List<MenuItem> menuItems, BookmarksFolder folder, ThemeDisplay themeDisplay, PortletRequest portletRequest) throws PortalException { long folderId = _getFolderId(folder); if (!containsPermission(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), folderId, ActionKeys.ADD_FOLDER)) {// ww w.j a v a 2 s. co m return; } URLMenuItem urlMenuItem = new URLMenuItem(); urlMenuItem.setLabel(LanguageUtil.get(PortalUtil.getHttpServletRequest(portletRequest), (folder != null) ? "subfolder" : "folder")); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); PortletURL portletURL = PortletURLFactoryUtil.create(portletRequest, portletDisplay.getId(), themeDisplay.getPlid(), PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "/bookmarks/edit_folder"); portletURL.setParameter("redirect", PortalUtil.getCurrentURL(portletRequest)); portletURL.setParameter("parentFolderId", String.valueOf(folderId)); urlMenuItem.setURL(portletURL.toString()); menuItems.add(urlMenuItem); }
From source file:com.liferay.comment.taglib.servlet.taglib.DiscussionTag.java
License:Open Source License
protected String getPaginationURL(HttpServletRequest request) { ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String portletId = portletDisplay.getId(); return StringBundler.concat(themeDisplay.getPathMain(), "/portal/comment/discussion/get_comments?p_p_isolated=1&", "portletId=", portletId); }
From source file:com.liferay.contacts.web.internal.portlet.ContactsCenterPortlet.java
License:Open Source License
protected JSONObject getContactsJSONObject(PortletRequest portletRequest, PortletResponse portletResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); String redirect = ParamUtil.getString(portletRequest, "redirect"); String filterBy = ParamUtil.getString(portletRequest, "filterBy"); String keywords = ParamUtil.getString(portletRequest, "keywords"); int start = ParamUtil.getInteger(portletRequest, "start"); int end = ParamUtil.getInteger(portletRequest, "end"); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); JSONObject optionsJSONObject = JSONFactoryUtil.createJSONObject(); optionsJSONObject.put("end", end); optionsJSONObject.put("filterBy", filterBy); optionsJSONObject.put("keywords", keywords); optionsJSONObject.put("start", start); jsonObject.put("options", optionsJSONObject); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); String portletId = portletDisplay.getId(); JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); if (filterBy.equals(ContactsConstants.FILTER_BY_DEFAULT) && !portletId.equals(ContactsPortletKeys.MEMBERS)) { List<BaseModel<?>> contacts = entryLocalService.searchUsersAndContacts(themeDisplay.getCompanyId(), themeDisplay.getUserId(), keywords, start, end); int contactsCount = entryLocalService.searchUsersAndContactsCount(themeDisplay.getCompanyId(), themeDisplay.getUserId(), keywords); jsonObject.put("count", contactsCount); for (BaseModel<?> contact : contacts) { JSONObject contactJSONObject = null; if (contact instanceof User) { contactJSONObject = getUserJSONObject(portletResponse, themeDisplay, (User) contact); } else { contactJSONObject = getEntryJSONObject(portletResponse, themeDisplay, (Entry) contact, redirect);//from ww w . j a v a 2 s .c o m } jsonArray.put(contactJSONObject); } } else if (filterBy.equals(ContactsConstants.FILTER_BY_FOLLOWERS) && !portletId.equals(ContactsPortletKeys.MEMBERS)) { List<SocialRelation> socialRelations = socialRelationLocalService.getInverseRelations( themeDisplay.getUserId(), SocialRelationConstants.TYPE_UNI_FOLLOWER, start, end); for (SocialRelation socialRelation : socialRelations) { jsonArray.put(getUserJSONObject(portletResponse, themeDisplay, socialRelation.getUserId1())); } } else if (filterBy.equals(ContactsConstants.FILTER_BY_TYPE_MY_CONTACTS) && !portletId.equals(ContactsPortletKeys.MEMBERS)) { List<Entry> entries = entryLocalService.search(themeDisplay.getUserId(), keywords, start, end); int entriesCount = entryLocalService.searchCount(themeDisplay.getUserId(), keywords); jsonObject.put("count", entriesCount); for (Entry entry : entries) { JSONObject contactJSONObject = getEntryJSONObject(portletResponse, themeDisplay, entry, redirect); jsonArray.put(contactJSONObject); } } else { LinkedHashMap<String, Object> params = new LinkedHashMap<>(); params.put("inherit", Boolean.TRUE); Group group = themeDisplay.getScopeGroup(); Layout layout = themeDisplay.getLayout(); if (group.isUser() && layout.isPublicLayout()) { params.put("socialRelationType", new Long[] { group.getClassPK(), (long) SocialRelationConstants.TYPE_BI_CONNECTION }); } else if (filterBy.startsWith(ContactsConstants.FILTER_BY_TYPE)) { params.put("socialRelationType", new Long[] { themeDisplay.getUserId(), ContactsUtil.getSocialRelationType(filterBy) }); } if (portletId.equals(ContactsPortletKeys.MEMBERS)) { params.put("usersGroups", group.getGroupId()); } else if (filterBy.startsWith(ContactsConstants.FILTER_BY_GROUP)) { params.put("usersGroups", ContactsUtil.getGroupId(filterBy)); } List<User> usersList = null; if (filterBy.equals(ContactsConstants.FILTER_BY_ADMINS)) { Role siteAdministratorRole = roleLocalService.getRole(group.getCompanyId(), RoleConstants.SITE_ADMINISTRATOR); params.put("userGroupRole", new Long[] { group.getGroupId(), siteAdministratorRole.getRoleId() }); Set<User> users = new HashSet<>(); users.addAll(userLocalService.search(themeDisplay.getCompanyId(), keywords, WorkflowConstants.STATUS_APPROVED, params, QueryUtil.ALL_POS, QueryUtil.ALL_POS, (OrderByComparator) null)); Role siteOwnerRole = roleLocalService.getRole(group.getCompanyId(), RoleConstants.SITE_OWNER); params.put("userGroupRole", new Long[] { group.getGroupId(), siteOwnerRole.getRoleId() }); users.addAll(userLocalService.search(themeDisplay.getCompanyId(), keywords, WorkflowConstants.STATUS_APPROVED, params, QueryUtil.ALL_POS, QueryUtil.ALL_POS, (OrderByComparator) null)); usersList = new ArrayList<>(users); ListUtil.sort(usersList, new UserLastNameComparator(true)); } else { int usersCount = userLocalService.searchCount(themeDisplay.getCompanyId(), keywords, WorkflowConstants.STATUS_APPROVED, params); jsonObject.put("count", usersCount); usersList = userLocalService.search(themeDisplay.getCompanyId(), keywords, WorkflowConstants.STATUS_APPROVED, params, start, end, new UserLastNameComparator(true)); } for (User user : usersList) { JSONObject userJSONObject = getUserJSONObject(portletResponse, themeDisplay, user); jsonArray.put(userJSONObject); } } jsonObject.put("users", jsonArray); return jsonObject; }